summaryrefslogtreecommitdiffstats
path: root/chromium/base/message_loop/message_loop.cc
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/base/message_loop/message_loop.cc
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
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 <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/base/message_loop/message_loop.cc')
-rw-r--r--chromium/base/message_loop/message_loop.cc134
1 files changed, 74 insertions, 60 deletions
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<MessagePump> 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