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(). |