OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/debug/task_annotator.h" | 13 #include "base/debug/task_annotator.h" |
| 14 #include "base/gtest_prod_util.h" |
14 #include "base/location.h" | 15 #include "base/location.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop/incoming_task_queue.h" | 19 #include "base/message_loop/incoming_task_queue.h" |
19 #include "base/message_loop/message_loop_task_runner.h" | 20 #include "base/message_loop/message_loop_task_runner.h" |
20 #include "base/message_loop/message_pump.h" | 21 #include "base/message_loop/message_pump.h" |
21 #include "base/message_loop/timer_slack.h" | 22 #include "base/message_loop/timer_slack.h" |
22 #include "base/observer_list.h" | 23 #include "base/observer_list.h" |
23 #include "base/pending_task.h" | 24 #include "base/pending_task.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 397 |
397 //---------------------------------------------------------------------------- | 398 //---------------------------------------------------------------------------- |
398 protected: | 399 protected: |
399 scoped_ptr<MessagePump> pump_; | 400 scoped_ptr<MessagePump> pump_; |
400 | 401 |
401 private: | 402 private: |
402 friend class RunLoop; | 403 friend class RunLoop; |
403 friend class internal::IncomingTaskQueue; | 404 friend class internal::IncomingTaskQueue; |
404 friend class ScheduleWorkTest; | 405 friend class ScheduleWorkTest; |
405 friend class Thread; | 406 friend class Thread; |
| 407 FRIEND_TEST_ALL_PREFIXES(MessageLoopTest, DeleteUnboundLoop); |
406 | 408 |
407 using MessagePumpFactoryCallback = Callback<scoped_ptr<MessagePump>()>; | 409 using MessagePumpFactoryCallback = Callback<scoped_ptr<MessagePump>()>; |
408 | 410 |
409 // Creates a MessageLoop without binding to a thread. | 411 // Creates a MessageLoop without binding to a thread. |
410 // If |type| is TYPE_CUSTOM non-null |pump_factory| must be also given | 412 // If |type| is TYPE_CUSTOM non-null |pump_factory| must be also given |
411 // to create a message pump for this message loop. Otherwise a default | 413 // to create a message pump for this message loop. Otherwise a default |
412 // message pump for the |type| is created. | 414 // message pump for the |type| is created. |
413 // | 415 // |
414 // It is valid to call this to create a new message loop on one thread, | 416 // It is valid to call this to create a new message loop on one thread, |
415 // and then pass it to the thread where the message loop actually runs. | 417 // and then pass it to the thread where the message loop actually runs. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 684 |
683 // Do not add any member variables to MessageLoopForIO! This is important b/c | 685 // Do not add any member variables to MessageLoopForIO! This is important b/c |
684 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 686 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
685 // data that you need should be stored on the MessageLoop's pump_ instance. | 687 // data that you need should be stored on the MessageLoop's pump_ instance. |
686 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 688 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
687 "MessageLoopForIO should not have extra member variables"); | 689 "MessageLoopForIO should not have extra member variables"); |
688 | 690 |
689 } // namespace base | 691 } // namespace base |
690 | 692 |
691 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 693 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |