Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: base/message_loop/message_loop.cc

Issue 61643006: Adds the ability for MessageLoop to take a MessagePump (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TYPE_CUSTOM and some scoped_ptr Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/message_loop/message_loop.cc
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 7cd22a876553817ee788c09cbfdd3c05a45c4695..d6474e92a7bb5900e050c46c9c51d63e7479c915 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -144,14 +144,7 @@ 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);
-
- 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_));
+ Init();
// TODO(rvargas): Get rid of the OS guards.
#if defined(OS_WIN)
@@ -198,6 +191,19 @@ MessageLoop::MessageLoop(Type type)
}
}
+MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump)
+ : pump_(pump.Pass()),
+ type_(TYPE_CUSTOM),
+ exception_restoration_(false),
+ nestable_tasks_allowed_(true),
+#if defined(OS_WIN)
+ os_modal_loop_(false),
+#endif // OS_WIN
+ message_histogram_(NULL),
+ run_loop_(NULL) {
+ Init();
+}
+
MessageLoop::~MessageLoop() {
DCHECK_EQ(this, current());
@@ -397,6 +403,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().

Powered by Google App Engine
This is Rietveld 408576698