From 3f0f86b0caed75241fa71c95a5d73bc0164348c5 Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Tue, 18 Mar 2014 13:16:26 +0100 Subject: Update to new stable branch 1750 This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai Reviewed-by: Zeno Albisser --- chromium/base/message_loop/message_loop.cc | 134 ++++++++++++++++------------- 1 file changed, 74 insertions(+), 60 deletions(-) (limited to 'chromium/base/message_loop/message_loop.cc') diff --git a/chromium/base/message_loop/message_loop.cc b/chromium/base/message_loop/message_loop.cc index 87a0b631735..3f9d01c8620 100644 --- a/chromium/base/message_loop/message_loop.cc +++ b/chromium/base/message_loop/message_loop.cc @@ -144,58 +144,23 @@ MessageLoop::MessageLoop(Type type) #endif // OS_WIN message_histogram_(NULL), run_loop_(NULL) { - DCHECK(!current()) << "should only have one message loop per thread"; - lazy_tls_ptr.Pointer()->Set(this); + Init(); - incoming_task_queue_ = new internal::IncomingTaskQueue(this); - message_loop_proxy_ = - new internal::MessageLoopProxyImpl(incoming_task_queue_); - thread_task_runner_handle_.reset( - new ThreadTaskRunnerHandle(message_loop_proxy_)); + pump_.reset(CreateMessagePumpForType(type)); +} -// TODO(rvargas): Get rid of the OS guards. +MessageLoop::MessageLoop(scoped_ptr pump) + : pump_(pump.Pass()), + type_(TYPE_CUSTOM), + exception_restoration_(false), + nestable_tasks_allowed_(true), #if defined(OS_WIN) -#define MESSAGE_PUMP_UI new MessagePumpForUI() -#define MESSAGE_PUMP_IO new MessagePumpForIO() -#elif defined(OS_IOS) -#define MESSAGE_PUMP_UI MessagePumpMac::Create() -#define MESSAGE_PUMP_IO new MessagePumpIOSForIO() -#elif defined(OS_MACOSX) -#define MESSAGE_PUMP_UI MessagePumpMac::Create() -#define MESSAGE_PUMP_IO new MessagePumpLibevent() -#elif defined(OS_NACL) -// Currently NaCl doesn't have a UI MessageLoop. -// TODO(abarth): Figure out if we need this. -#define MESSAGE_PUMP_UI NULL -// ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and -// doesn't require extra support for watching file descriptors. -#define MESSAGE_PUMP_IO new MessagePumpDefault() -#elif defined(OS_POSIX) // POSIX but not MACOSX. -#define MESSAGE_PUMP_UI new MessagePumpForUI() -#define MESSAGE_PUMP_IO new MessagePumpLibevent() -#else -#error Not implemented -#endif - - if (type_ == TYPE_UI) { - if (message_pump_for_ui_factory_) - pump_.reset(message_pump_for_ui_factory_()); - else - pump_.reset(MESSAGE_PUMP_UI); - } else if (type_ == TYPE_IO) { - pump_.reset(MESSAGE_PUMP_IO); -#if defined(TOOLKIT_GTK) - } else if (type_ == TYPE_GPU) { - pump_.reset(new MessagePumpX11()); -#endif -#if defined(OS_ANDROID) - } else if (type_ == TYPE_JAVA) { - pump_.reset(MESSAGE_PUMP_UI); -#endif - } else { - DCHECK_EQ(TYPE_DEFAULT, type_); - pump_.reset(new MessagePumpDefault()); - } + os_modal_loop_(false), +#endif // OS_WIN + message_histogram_(NULL), + run_loop_(NULL) { + DCHECK(pump_.get()); + Init(); } MessageLoop::~MessageLoop() { @@ -257,6 +222,51 @@ bool MessageLoop::InitMessagePumpForUIFactory(MessagePumpFactory* factory) { return true; } +// static +MessagePump* MessageLoop::CreateMessagePumpForType(Type type) { +// TODO(rvargas): Get rid of the OS guards. +#if defined(OS_WIN) +#define MESSAGE_PUMP_UI new MessagePumpForUI() +#define MESSAGE_PUMP_IO new MessagePumpForIO() +#elif defined(OS_IOS) +#define MESSAGE_PUMP_UI MessagePumpMac::Create() +#define MESSAGE_PUMP_IO new MessagePumpIOSForIO() +#elif defined(OS_MACOSX) +#define MESSAGE_PUMP_UI MessagePumpMac::Create() +#define MESSAGE_PUMP_IO new MessagePumpLibevent() +#elif defined(OS_NACL) +// Currently NaCl doesn't have a UI MessageLoop. +// TODO(abarth): Figure out if we need this. +#define MESSAGE_PUMP_UI NULL +// ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and +// doesn't require extra support for watching file descriptors. +#define MESSAGE_PUMP_IO new MessagePumpDefault() +#elif defined(OS_POSIX) // POSIX but not MACOSX. +#define MESSAGE_PUMP_UI new MessagePumpForUI() +#define MESSAGE_PUMP_IO new MessagePumpLibevent() +#else +#error Not implemented +#endif + + if (type == MessageLoop::TYPE_UI) { + if (message_pump_for_ui_factory_) + return message_pump_for_ui_factory_(); + return MESSAGE_PUMP_UI; + } + if (type == MessageLoop::TYPE_IO) + return MESSAGE_PUMP_IO; +#if defined(TOOLKIT_GTK) + if (type == MessageLoop::TYPE_GPU) + return new MessagePumpX11(); +#endif +#if defined(OS_ANDROID) + if (type == MessageLoop::TYPE_JAVA) + return MESSAGE_PUMP_UI; +#endif + DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type); + return new MessagePumpDefault(); +} + void MessageLoop::AddDestructionObserver( DestructionObserver* destruction_observer) { DCHECK_EQ(this, current()); @@ -348,13 +358,12 @@ Closure MessageLoop::QuitWhenIdleClosure() { } void MessageLoop::SetNestableTasksAllowed(bool allowed) { - if (nestable_tasks_allowed_ != allowed) { - nestable_tasks_allowed_ = allowed; - if (!nestable_tasks_allowed_) - return; - // Start the native pump if we are not already pumping. + if (allowed) { + // Kick the native pump just in case we enter a OS-driven nested message + // loop. pump_->ScheduleWork(); } + nestable_tasks_allowed_ = allowed; } bool MessageLoop::NestableTasksAllowed() const { @@ -397,6 +406,17 @@ void MessageLoop::LockWaitUnLockForTesting(WaitableEvent* caller_wait, //------------------------------------------------------------------------------ +void MessageLoop::Init() { + DCHECK(!current()) << "should only have one message loop per thread"; + lazy_tls_ptr.Pointer()->Set(this); + + incoming_task_queue_ = new internal::IncomingTaskQueue(this); + message_loop_proxy_ = + new internal::MessageLoopProxyImpl(incoming_task_queue_); + thread_task_runner_handle_.reset( + new ThreadTaskRunnerHandle(message_loop_proxy_)); +} + // Runs the loop in two different SEH modes: // enable_SEH_restoration_ = false : any unhandled exception goes to the last // one that calls SetUnhandledExceptionFilter(). @@ -695,12 +715,6 @@ void MessageLoop::ReleaseSoonInternal( //------------------------------------------------------------------------------ // MessageLoopForUI -#if defined(OS_WIN) -void MessageLoopForUI::DidProcessMessage(const MSG& message) { - pump_win()->DidProcessMessage(message); -} -#endif // defined(OS_WIN) - #if defined(OS_ANDROID) void MessageLoopForUI::Start() { // No Histogram support for UI message loop as it is managed by Java side -- cgit v1.2.3