OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // | 104 // |
105 enum Type { | 105 enum Type { |
106 TYPE_DEFAULT, | 106 TYPE_DEFAULT, |
107 TYPE_UI, | 107 TYPE_UI, |
108 TYPE_IO | 108 TYPE_IO |
109 }; | 109 }; |
110 | 110 |
111 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it | 111 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it |
112 // is typical to make use of the current thread's MessageLoop instance. | 112 // is typical to make use of the current thread's MessageLoop instance. |
113 explicit MessageLoop(Type type = TYPE_DEFAULT); | 113 explicit MessageLoop(Type type = TYPE_DEFAULT); |
114 ~MessageLoop(); | 114 virtual ~MessageLoop(); |
115 | 115 |
116 // Returns the MessageLoop object for the current thread, or null if none. | 116 // Returns the MessageLoop object for the current thread, or null if none. |
117 static MessageLoop* current(); | 117 static MessageLoop* current(); |
118 | 118 |
119 static void EnableHistogrammer(bool enable_histogrammer); | 119 static void EnableHistogrammer(bool enable_histogrammer); |
120 | 120 |
121 // A DestructionObserver is notified when the current MessageLoop is being | 121 // A DestructionObserver is notified when the current MessageLoop is being |
122 // destroyed. These obsevers are notified prior to MessageLoop::current() | 122 // destroyed. These obsevers are notified prior to MessageLoop::current() |
123 // being changed to return NULL. This gives interested parties the chance to | 123 // being changed to return NULL. This gives interested parties the chance to |
124 // do final cleanup that depends on the MessageLoop. | 124 // do final cleanup that depends on the MessageLoop. |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 #endif // defined(OS_POSIX) | 690 #endif // defined(OS_POSIX) |
691 }; | 691 }; |
692 | 692 |
693 // Do not add any member variables to MessageLoopForIO! This is important b/c | 693 // Do not add any member variables to MessageLoopForIO! This is important b/c |
694 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 694 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
695 // data that you need should be stored on the MessageLoop's pump_ instance. | 695 // data that you need should be stored on the MessageLoop's pump_ instance. |
696 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 696 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
697 MessageLoopForIO_should_not_have_extra_member_variables); | 697 MessageLoopForIO_should_not_have_extra_member_variables); |
698 | 698 |
699 #endif // BASE_MESSAGE_LOOP_H_ | 699 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |