1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
11 #include "base/base_export.h"
12 #include "base/basictypes.h"
13 #include "base/callback_forward.h"
14 #include "base/location.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/incoming_task_queue.h"
18 #include "base/message_loop/message_loop_proxy.h"
19 #include "base/message_loop/message_loop_proxy_impl.h"
20 #include "base/message_loop/message_pump.h"
21 #include "base/observer_list.h"
22 #include "base/pending_task.h"
23 #include "base/sequenced_task_runner_helpers.h"
24 #include "base/synchronization/lock.h"
25 #include "base/time/time.h"
26 #include "base/tracking_info.h"
28 // TODO(sky): these includes should not be necessary. Nuke them.
30 #include "base/message_loop/message_pump_win.h"
32 #include "base/message_loop/message_pump_io_ios.h"
33 #elif defined(OS_POSIX)
34 #include "base/message_loop/message_pump_libevent.h"
35 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
37 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL)
38 #include "base/message_loop/message_pump_x11.h"
39 #elif defined(USE_OZONE) && !defined(OS_NACL)
40 #include "base/message_loop/message_pump_ozone.h"
42 #define USE_GTK_MESSAGE_PUMP
43 #include "base/message_loop/message_pump_gtk.h"
44 #if defined(TOOLKIT_GTK)
45 #include "base/message_loop/message_pump_x11.h"
55 class MessagePumpObserver;
57 class ThreadTaskRunnerHandle;
58 #if defined(OS_ANDROID)
59 class MessagePumpForUI;
63 // A MessageLoop is used to process events for a particular thread. There is
64 // at most one MessageLoop instance per thread.
66 // Events include at a minimum Task instances submitted to PostTask and its
67 // variants. Depending on the type of message pump used by the MessageLoop
68 // other events such as UI messages may be processed. On Windows APC calls (as
69 // time permits) and signals sent to a registered set of HANDLEs may also be
72 // NOTE: Unless otherwise specified, a MessageLoop's methods may only be called
73 // on the thread where the MessageLoop's Run method executes.
75 // NOTE: MessageLoop has task reentrancy protection. This means that if a
76 // task is being processed, a second task cannot start until the first task is
77 // finished. Reentrancy can happen when processing a task, and an inner
78 // message pump is created. That inner pump then processes native messages
79 // which could implicitly start an inner task. Inner message pumps are created
80 // with dialogs (DialogBox), common dialogs (GetOpenFileName), OLE functions
81 // (DoDragDrop), printer functions (StartDoc) and *many* others.
83 // Sample workaround when inner task processing is needed:
86 // MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
87 // hr = DoDragDrop(...); // Implicitly runs a modal message loop.
89 // // Process |hr| (the result returned by DoDragDrop()).
91 // Please be SURE your task is reentrant (nestable) and all global variables
92 // are stable and accessible before calling SetNestableTasksAllowed(true).
94 class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
98 typedef MessagePumpObserver Observer;
99 #elif defined(USE_GTK_MESSAGE_PUMP)
100 typedef MessagePumpGdkObserver Observer;
103 // A MessageLoop has a particular type, which indicates the set of
104 // asynchronous events it may process in addition to tasks and timers.
107 // This type of ML only supports tasks and timers.
110 // This type of ML also supports native UI events (e.g., Windows messages).
111 // See also MessageLoopForUI.
114 // This type of ML also supports native UI events for use in the GPU
115 // process. On Linux this will always be an X11 ML (as compared with the
116 // sometimes-GTK ML in the browser process).
119 // This type of ML also supports asynchronous IO. See also
123 // This type of ML is backed by a Java message handler which is responsible
124 // for running the tasks added to the ML. This is only for use on Android.
125 // TYPE_JAVA behaves in essence like TYPE_UI, except during construction
126 // where it does not use the main thread specific pump factory.
129 // MessagePump was supplied to constructor.
135 #if defined(TOOLKIT_GTK)
139 #if defined(OS_ANDROID)
141 #endif // defined(OS_ANDROID)
144 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it
145 // is typical to make use of the current thread's MessageLoop instance.
146 explicit MessageLoop(Type type = TYPE_DEFAULT);
147 // Creates a TYPE_CUSTOM MessageLoop with the supplied MessagePump, which must
149 explicit MessageLoop(scoped_ptr<base::MessagePump> pump);
150 virtual ~MessageLoop();
152 // Returns the MessageLoop object for the current thread, or null if none.
153 static MessageLoop* current();
155 static void EnableHistogrammer(bool enable_histogrammer);
157 typedef MessagePump* (MessagePumpFactory)();
158 // Uses the given base::MessagePumpForUIFactory to override the default
159 // MessagePump implementation for 'TYPE_UI'. Returns true if the factory
160 // was successfully registered.
161 static bool InitMessagePumpForUIFactory(MessagePumpFactory* factory);
163 // Creates the default MessagePump based on |type|. Caller owns return
165 // TODO(sky): convert this and InitMessagePumpForUIFactory() to return a
167 static MessagePump* CreateMessagePumpForType(Type type);
169 // A DestructionObserver is notified when the current MessageLoop is being
170 // destroyed. These observers are notified prior to MessageLoop::current()
171 // being changed to return NULL. This gives interested parties the chance to
172 // do final cleanup that depends on the MessageLoop.
174 // NOTE: Any tasks posted to the MessageLoop during this notification will
175 // not be run. Instead, they will be deleted.
177 class BASE_EXPORT DestructionObserver {
179 virtual void WillDestroyCurrentMessageLoop() = 0;
182 virtual ~DestructionObserver();
185 // Add a DestructionObserver, which will start receiving notifications
187 void AddDestructionObserver(DestructionObserver* destruction_observer);
189 // Remove a DestructionObserver. It is safe to call this method while a
190 // DestructionObserver is receiving a notification callback.
191 void RemoveDestructionObserver(DestructionObserver* destruction_observer);
193 // The "PostTask" family of methods call the task's Run method asynchronously
194 // from within a message loop at some point in the future.
196 // With the PostTask variant, tasks are invoked in FIFO order, inter-mixed
197 // with normal UI or IO event processing. With the PostDelayedTask variant,
198 // tasks are called after at least approximately 'delay_ms' have elapsed.
200 // The NonNestable variants work similarly except that they promise never to
201 // dispatch the task from a nested invocation of MessageLoop::Run. Instead,
202 // such tasks get deferred until the top-most MessageLoop::Run is executing.
204 // The MessageLoop takes ownership of the Task, and deletes it after it has
207 // PostTask(from_here, task) is equivalent to
208 // PostDelayedTask(from_here, task, 0).
210 // NOTE: These methods may be called on any thread. The Task will be invoked
211 // on the thread that executes MessageLoop::Run().
212 void PostTask(const tracked_objects::Location& from_here,
213 const Closure& task);
215 void PostDelayedTask(const tracked_objects::Location& from_here,
219 void PostNonNestableTask(const tracked_objects::Location& from_here,
220 const Closure& task);
222 void PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
226 // A variant on PostTask that deletes the given object. This is useful
227 // if the object needs to live until the next run of the MessageLoop (for
228 // example, deleting a RenderProcessHost from within an IPC callback is not
231 // NOTE: This method may be called on any thread. The object will be deleted
232 // on the thread that executes MessageLoop::Run(). If this is not the same
233 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit
234 // from RefCountedThreadSafe<T>!
236 void DeleteSoon(const tracked_objects::Location& from_here, const T* object) {
237 base::subtle::DeleteHelperInternal<T, void>::DeleteViaSequencedTaskRunner(
238 this, from_here, object);
241 // A variant on PostTask that releases the given reference counted object
242 // (by calling its Release method). This is useful if the object needs to
243 // live until the next run of the MessageLoop, or if the object needs to be
244 // released on a particular thread.
246 // NOTE: This method may be called on any thread. The object will be
247 // released (and thus possibly deleted) on the thread that executes
248 // MessageLoop::Run(). If this is not the same as the thread that calls
249 // PostDelayedTask(FROM_HERE, ), then T MUST inherit from
250 // RefCountedThreadSafe<T>!
252 void ReleaseSoon(const tracked_objects::Location& from_here,
254 base::subtle::ReleaseHelperInternal<T, void>::ReleaseViaSequencedTaskRunner(
255 this, from_here, object);
258 // Deprecated: use RunLoop instead.
259 // Run the message loop.
262 // Deprecated: use RunLoop instead.
263 // Process all pending tasks, windows messages, etc., but don't wait/sleep.
264 // Return as soon as all items that can be run are taken care of.
267 // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdle().
268 void Quit() { QuitWhenIdle(); }
270 // Deprecated: use RunLoop instead.
272 // Signals the Run method to return when it becomes idle. It will continue to
273 // process pending messages and future messages as long as they are enqueued.
274 // Warning: if the MessageLoop remains busy, it may never quit. Only use this
275 // Quit method when looping procedures (such as web pages) have been shut
278 // This method may only be called on the same thread that called Run, and Run
279 // must still be on the call stack.
281 // Use QuitClosure variants if you need to Quit another thread's MessageLoop,
282 // but note that doing so is fairly dangerous if the target thread makes
283 // nested calls to MessageLoop::Run. The problem being that you won't know
284 // which nested run loop you are quitting, so be careful!
287 // Deprecated: use RunLoop instead.
289 // This method is a variant of Quit, that does not wait for pending messages
290 // to be processed before returning from Run.
293 // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure().
294 static Closure QuitClosure() { return QuitWhenIdleClosure(); }
296 // Deprecated: use RunLoop instead.
297 // Construct a Closure that will call QuitWhenIdle(). Useful to schedule an
298 // arbitrary MessageLoop to QuitWhenIdle.
299 static Closure QuitWhenIdleClosure();
301 // Returns true if this loop is |type|. This allows subclasses (especially
302 // those in tests) to specialize how they are identified.
303 virtual bool IsType(Type type) const;
305 // Returns the type passed to the constructor.
306 Type type() const { return type_; }
308 // Optional call to connect the thread name with this loop.
309 void set_thread_name(const std::string& thread_name) {
310 DCHECK(thread_name_.empty()) << "Should not rename this thread!";
311 thread_name_ = thread_name;
313 const std::string& thread_name() const { return thread_name_; }
315 // Gets the message loop proxy associated with this message loop.
316 scoped_refptr<MessageLoopProxy> message_loop_proxy() {
317 return message_loop_proxy_;
320 // Enables or disables the recursive task processing. This happens in the case
321 // of recursive message loops. Some unwanted message loop may occurs when
322 // using common controls or printer functions. By default, recursive task
323 // processing is disabled.
325 // Please utilize |ScopedNestableTaskAllower| instead of calling these methods
326 // directly. In general nestable message loops are to be avoided. They are
327 // dangerous and difficult to get right, so please use with extreme caution.
329 // The specific case where tasks get queued is:
330 // - The thread is running a message loop.
331 // - It receives a task #1 and execute it.
332 // - The task #1 implicitly start a message loop, like a MessageBox in the
333 // unit test. This can also be StartDoc or GetSaveFileName.
334 // - The thread receives a task #2 before or while in this second message
336 // - With NestableTasksAllowed set to true, the task #2 will run right away.
337 // Otherwise, it will get executed right after task #1 completes at "thread
338 // message loop level".
339 void SetNestableTasksAllowed(bool allowed);
340 bool NestableTasksAllowed() const;
342 // Enables nestable tasks on |loop| while in scope.
343 class ScopedNestableTaskAllower {
345 explicit ScopedNestableTaskAllower(MessageLoop* loop)
347 old_state_(loop_->NestableTasksAllowed()) {
348 loop_->SetNestableTasksAllowed(true);
350 ~ScopedNestableTaskAllower() {
351 loop_->SetNestableTasksAllowed(old_state_);
359 // Returns true if we are currently running a nested message loop.
362 // A TaskObserver is an object that receives task notifications from the
365 // NOTE: A TaskObserver implementation should be extremely fast!
366 class BASE_EXPORT TaskObserver {
370 // This method is called before processing a task.
371 virtual void WillProcessTask(const PendingTask& pending_task) = 0;
373 // This method is called after processing a task.
374 virtual void DidProcessTask(const PendingTask& pending_task) = 0;
377 virtual ~TaskObserver();
380 // These functions can only be called on the same thread that |this| is
382 void AddTaskObserver(TaskObserver* task_observer);
383 void RemoveTaskObserver(TaskObserver* task_observer);
385 // When we go into high resolution timer mode, we will stay in hi-res mode
387 static const int kHighResolutionTimerModeLeaseTimeMs = 1000;
390 void set_os_modal_loop(bool os_modal_loop) {
391 os_modal_loop_ = os_modal_loop;
394 bool os_modal_loop() const {
395 return os_modal_loop_;
399 // Can only be called from the thread that owns the MessageLoop.
400 bool is_running() const;
402 // Returns true if the message loop has high resolution timers enabled.
403 // Provided for testing.
404 bool IsHighResolutionTimerEnabledForTesting();
406 // Returns true if the message loop is "idle". Provided for testing.
407 bool IsIdleForTesting();
409 //----------------------------------------------------------------------------
413 MessagePumpWin* pump_win() {
414 return static_cast<MessagePumpWin*>(pump_.get());
416 #elif defined(OS_POSIX) && !defined(OS_IOS)
417 MessagePumpLibevent* pump_libevent() {
418 return static_cast<MessagePumpLibevent*>(pump_.get());
420 #if defined(TOOLKIT_GTK)
421 friend class MessagePumpX11;
422 MessagePumpX11* pump_gpu() {
423 DCHECK_EQ(TYPE_GPU, type());
424 return static_cast<MessagePumpX11*>(pump_.get());
429 scoped_ptr<MessagePump> pump_;
432 friend class internal::IncomingTaskQueue;
433 friend class RunLoop;
435 // Configures various members for the two constructors.
438 // Invokes the actual run loop using the message pump.
441 // Called to process any delayed non-nestable tasks.
442 bool ProcessNextDelayedNonNestableTask();
444 // Runs the specified PendingTask.
445 void RunTask(const PendingTask& pending_task);
447 // Calls RunTask or queues the pending_task on the deferred task list if it
448 // cannot be run right now. Returns true if the task was run.
449 bool DeferOrRunPendingTask(const PendingTask& pending_task);
451 // Adds the pending task to delayed_work_queue_.
452 void AddToDelayedWorkQueue(const PendingTask& pending_task);
454 // Delete tasks that haven't run yet without running them. Used in the
455 // destructor to make sure all the task's destructors get called. Returns
456 // true if some work was done.
457 bool DeletePendingTasks();
459 // Creates a process-wide unique ID to represent this task in trace events.
460 // This will be mangled with a Process ID hash to reduce the likelyhood of
461 // colliding with MessageLoop pointers on other processes.
462 uint64 GetTaskTraceID(const PendingTask& task);
464 // Loads tasks from the incoming queue to |work_queue_| if the latter is
466 void ReloadWorkQueue();
468 // Wakes up the message pump. Can be called on any thread. The caller is
469 // responsible for synchronizing ScheduleWork() calls.
470 void ScheduleWork(bool was_empty);
472 // Start recording histogram info about events and action IF it was enabled
473 // and IF the statistics recorder can accept a registration of our histogram.
474 void StartHistogrammer();
476 // Add occurrence of event to our histogram, so that we can see what is being
477 // done in a specific MessageLoop instance (i.e., specific thread).
478 // If message_histogram_ is NULL, this is a no-op.
479 void HistogramEvent(int event);
481 // MessagePump::Delegate methods:
482 virtual bool DoWork() OVERRIDE;
483 virtual bool DoDelayedWork(TimeTicks* next_delayed_work_time) OVERRIDE;
484 virtual bool DoIdleWork() OVERRIDE;
485 virtual void GetQueueingInformation(size_t* queue_size,
486 TimeDelta* queueing_delay) OVERRIDE;
490 // A list of tasks that need to be processed by this instance. Note that
491 // this queue is only accessed (push/pop) by our current thread.
492 TaskQueue work_queue_;
494 // Contains delayed tasks, sorted by their 'delayed_run_time' property.
495 DelayedTaskQueue delayed_work_queue_;
497 // A recent snapshot of Time::Now(), used to check delayed_work_queue_.
498 TimeTicks recent_time_;
500 // A queue of non-nestable tasks that we had to defer because when it came
501 // time to execute them we were in a nested message loop. They will execute
502 // once we're out of nested message loops.
503 TaskQueue deferred_non_nestable_work_queue_;
505 ObserverList<DestructionObserver> destruction_observers_;
507 // A recursion block that prevents accidentally running additional tasks when
508 // insider a (accidentally induced?) nested message pump.
509 bool nestable_tasks_allowed_;
512 // Should be set to true before calling Windows APIs like TrackPopupMenu, etc
513 // which enter a modal message loop.
517 std::string thread_name_;
518 // A profiling histogram showing the counts of various messages and events.
519 HistogramBase* message_histogram_;
523 ObserverList<TaskObserver> task_observers_;
525 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_;
527 // The message loop proxy associated with this message loop.
528 scoped_refptr<internal::MessageLoopProxyImpl> message_loop_proxy_;
529 scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_;
531 template <class T, class R> friend class base::subtle::DeleteHelperInternal;
532 template <class T, class R> friend class base::subtle::ReleaseHelperInternal;
534 void DeleteSoonInternal(const tracked_objects::Location& from_here,
535 void(*deleter)(const void*),
537 void ReleaseSoonInternal(const tracked_objects::Location& from_here,
538 void(*releaser)(const void*),
541 DISALLOW_COPY_AND_ASSIGN(MessageLoop);
544 //-----------------------------------------------------------------------------
545 // MessageLoopForUI extends MessageLoop with methods that are particular to a
546 // MessageLoop instantiated with TYPE_UI.
548 // This class is typically used like so:
549 // MessageLoopForUI::current()->...call some method...
551 class BASE_EXPORT MessageLoopForUI : public MessageLoop {
554 typedef MessagePumpForUI::MessageFilter MessageFilter;
557 MessageLoopForUI() : MessageLoop(TYPE_UI) {
560 // Returns the MessageLoopForUI of the current thread.
561 static MessageLoopForUI* current() {
562 MessageLoop* loop = MessageLoop::current();
564 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
565 return static_cast<MessageLoopForUI*>(loop);
568 static bool IsCurrent() {
569 MessageLoop* loop = MessageLoop::current();
570 return loop && loop->type() == MessageLoop::TYPE_UI;
574 // On iOS, the main message loop cannot be Run(). Instead call Attach(),
575 // which connects this MessageLoop to the UI thread's CFRunLoop and allows
576 // PostTask() to work.
580 #if defined(OS_ANDROID)
581 // On Android, the UI message loop is handled by Java side. So Run() should
582 // never be called. Instead use Start(), which will forward all the native UI
583 // events to the Java message loop.
587 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || defined(USE_OZONE) || \
588 defined(OS_WIN) || defined(USE_X11))
589 // Please see message_pump_win/message_pump_glib for definitions of these
591 void AddObserver(Observer* observer);
592 void RemoveObserver(Observer* observer);
596 // Plese see MessagePumpForUI for definitions of this method.
597 void SetMessageFilter(scoped_ptr<MessageFilter> message_filter) {
598 pump_ui()->SetMessageFilter(message_filter.Pass());
604 friend class MessagePumpX11;
606 #if defined(USE_OZONE) && !defined(OS_NACL)
607 friend class MessagePumpOzone;
610 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
611 // TODO(rvargas): Make this platform independent.
612 MessagePumpForUI* pump_ui() {
613 return static_cast<MessagePumpForUI*>(pump_.get());
618 // Do not add any member variables to MessageLoopForUI! This is important b/c
619 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra
620 // data that you need should be stored on the MessageLoop's pump_ instance.
621 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI),
622 MessageLoopForUI_should_not_have_extra_member_variables);
624 //-----------------------------------------------------------------------------
625 // MessageLoopForIO extends MessageLoop with methods that are particular to a
626 // MessageLoop instantiated with TYPE_IO.
628 // This class is typically used like so:
629 // MessageLoopForIO::current()->...call some method...
631 class BASE_EXPORT MessageLoopForIO : public MessageLoop {
634 typedef MessagePumpForIO::IOHandler IOHandler;
635 typedef MessagePumpForIO::IOContext IOContext;
636 typedef MessagePumpForIO::IOObserver IOObserver;
637 #elif defined(OS_IOS)
638 typedef MessagePumpIOSForIO::Watcher Watcher;
639 typedef MessagePumpIOSForIO::FileDescriptorWatcher
640 FileDescriptorWatcher;
641 typedef MessagePumpIOSForIO::IOObserver IOObserver;
644 WATCH_READ = MessagePumpIOSForIO::WATCH_READ,
645 WATCH_WRITE = MessagePumpIOSForIO::WATCH_WRITE,
646 WATCH_READ_WRITE = MessagePumpIOSForIO::WATCH_READ_WRITE
648 #elif defined(OS_POSIX)
649 typedef MessagePumpLibevent::Watcher Watcher;
650 typedef MessagePumpLibevent::FileDescriptorWatcher
651 FileDescriptorWatcher;
652 typedef MessagePumpLibevent::IOObserver IOObserver;
655 WATCH_READ = MessagePumpLibevent::WATCH_READ,
656 WATCH_WRITE = MessagePumpLibevent::WATCH_WRITE,
657 WATCH_READ_WRITE = MessagePumpLibevent::WATCH_READ_WRITE
662 MessageLoopForIO() : MessageLoop(TYPE_IO) {
665 // Returns the MessageLoopForIO of the current thread.
666 static MessageLoopForIO* current() {
667 MessageLoop* loop = MessageLoop::current();
668 DCHECK_EQ(MessageLoop::TYPE_IO, loop->type());
669 return static_cast<MessageLoopForIO*>(loop);
672 static bool IsCurrent() {
673 MessageLoop* loop = MessageLoop::current();
674 return loop && loop->type() == MessageLoop::TYPE_IO;
677 void AddIOObserver(IOObserver* io_observer) {
678 pump_io()->AddIOObserver(io_observer);
681 void RemoveIOObserver(IOObserver* io_observer) {
682 pump_io()->RemoveIOObserver(io_observer);
686 // Please see MessagePumpWin for definitions of these methods.
687 void RegisterIOHandler(HANDLE file, IOHandler* handler);
688 bool RegisterJobObject(HANDLE job, IOHandler* handler);
689 bool WaitForIOCompletion(DWORD timeout, IOHandler* filter);
692 // TODO(rvargas): Make this platform independent.
693 MessagePumpForIO* pump_io() {
694 return static_cast<MessagePumpForIO*>(pump_.get());
697 #elif defined(OS_IOS)
698 // Please see MessagePumpIOSForIO for definition.
699 bool WatchFileDescriptor(int fd,
702 FileDescriptorWatcher *controller,
706 MessagePumpIOSForIO* pump_io() {
707 return static_cast<MessagePumpIOSForIO*>(pump_.get());
710 #elif defined(OS_POSIX)
711 // Please see MessagePumpLibevent for definition.
712 bool WatchFileDescriptor(int fd,
715 FileDescriptorWatcher* controller,
719 MessagePumpLibevent* pump_io() {
720 return static_cast<MessagePumpLibevent*>(pump_.get());
722 #endif // defined(OS_POSIX)
725 // Do not add any member variables to MessageLoopForIO! This is important b/c
726 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
727 // data that you need should be stored on the MessageLoop's pump_ instance.
728 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
729 MessageLoopForIO_should_not_have_extra_member_variables);
733 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_