Commit fd5bba61 authored by WebKit Team's avatar WebKit Team Committed by Jocelyn Turcotte
Browse files

Support using MessagePumpForUIQt in standalone base::Threads


We currently assume that MessagePumpForUIQt will only be used on Qt's
GUI thread but OSX and Windows do have some cases where TYPE_UI is
used for non-UI threads. This currently causes asserts in debug on
OSX since the DNS thread quits prematurely.

Instead of overriding all those edge cases to use TYPE_DEFAULT,
properly support MessagePumpForUIQt::Run by using a QEventLoop.

Change-Id: Icdb65966867ca6fd3679c75a698007f63848babc
Reviewed-by: default avatarAndras Becsi <andras.becsi@digia.com>
parent 5b8e3ecf
Branches
Tags
No related merge requests found
Showing with 10 additions and 3 deletions
...@@ -99,18 +99,24 @@ public: ...@@ -99,18 +99,24 @@ public:
// Usually this gets passed through Run, but since we have // Usually this gets passed through Run, but since we have
// our own event loop, attach it explicitly ourselves. // our own event loop, attach it explicitly ourselves.
: m_delegate(base::MessageLoopForUI::current()) : m_delegate(base::MessageLoopForUI::current())
, m_explicitLoop(0)
{ {
} }
virtual void Run(Delegate *delegate) Q_DECL_OVERRIDE virtual void Run(Delegate *delegate) Q_DECL_OVERRIDE
{ {
// FIXME: This could be needed if we want to run Chromium tests. Q_ASSERT(delegate == m_delegate);
// We could run a QEventLoop here. // This is used only when MessagePumpForUIQt is used outside of the GUI thread.
QEventLoop loop;
m_explicitLoop = &loop;
loop.exec();
m_explicitLoop = 0;
} }
virtual void Quit() Q_DECL_OVERRIDE virtual void Quit() Q_DECL_OVERRIDE
{ {
Q_UNREACHABLE(); Q_ASSERT(m_explicitLoop);
m_explicitLoop->quit();
} }
virtual void ScheduleWork() Q_DECL_OVERRIDE virtual void ScheduleWork() Q_DECL_OVERRIDE
...@@ -159,6 +165,7 @@ private: ...@@ -159,6 +165,7 @@ private:
} }
Delegate *m_delegate; Delegate *m_delegate;
QEventLoop *m_explicitLoop;
}; };
scoped_ptr<base::MessagePump> messagePumpFactory() scoped_ptr<base::MessagePump> messagePumpFactory()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment