| 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 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // Creates a TYPE_CUSTOM MessageLoop with the supplied MessagePump, which must | 147 // Creates a TYPE_CUSTOM MessageLoop with the supplied MessagePump, which must |
| 148 // be non-NULL. | 148 // be non-NULL. |
| 149 explicit MessageLoop(scoped_ptr<base::MessagePump> pump); | 149 explicit MessageLoop(scoped_ptr<base::MessagePump> pump); |
| 150 virtual ~MessageLoop(); | 150 virtual ~MessageLoop(); |
| 151 | 151 |
| 152 // Returns the MessageLoop object for the current thread, or null if none. | 152 // Returns the MessageLoop object for the current thread, or null if none. |
| 153 static MessageLoop* current(); | 153 static MessageLoop* current(); |
| 154 | 154 |
| 155 static void EnableHistogrammer(bool enable_histogrammer); | 155 static void EnableHistogrammer(bool enable_histogrammer); |
| 156 | 156 |
| 157 typedef MessagePump* (MessagePumpFactory)(); | 157 typedef scoped_ptr<MessagePump> (MessagePumpFactory)(); |
| 158 // Uses the given base::MessagePumpForUIFactory to override the default | 158 // Uses the given base::MessagePumpForUIFactory to override the default |
| 159 // MessagePump implementation for 'TYPE_UI'. Returns true if the factory | 159 // MessagePump implementation for 'TYPE_UI'. Returns true if the factory |
| 160 // was successfully registered. | 160 // was successfully registered. |
| 161 static bool InitMessagePumpForUIFactory(MessagePumpFactory* factory); | 161 static bool InitMessagePumpForUIFactory(scoped_ptr<MessagePumpFactory> |
| 162 factory); |
| 162 | 163 |
| 163 // Creates the default MessagePump based on |type|. Caller owns return | 164 // Creates the default MessagePump based on |type|. Caller owns return |
| 164 // value. | 165 // value. |
| 165 // TODO(sky): convert this and InitMessagePumpForUIFactory() to return a | 166 static scoped_ptr<MessagePump> CreateMessagePumpForType(Type type); |
| 166 // scoped_ptr. | |
| 167 static MessagePump* CreateMessagePumpForType(Type type); | |
| 168 | |
| 169 // A DestructionObserver is notified when the current MessageLoop is being | 167 // A DestructionObserver is notified when the current MessageLoop is being |
| 170 // destroyed. These observers are notified prior to MessageLoop::current() | 168 // destroyed. These observers are notified prior to MessageLoop::current() |
| 171 // being changed to return NULL. This gives interested parties the chance to | 169 // being changed to return NULL. This gives interested parties the chance to |
| 172 // do final cleanup that depends on the MessageLoop. | 170 // do final cleanup that depends on the MessageLoop. |
| 173 // | 171 // |
| 174 // NOTE: Any tasks posted to the MessageLoop during this notification will | 172 // NOTE: Any tasks posted to the MessageLoop during this notification will |
| 175 // not be run. Instead, they will be deleted. | 173 // not be run. Instead, they will be deleted. |
| 176 // | 174 // |
| 177 class BASE_EXPORT DestructionObserver { | 175 class BASE_EXPORT DestructionObserver { |
| 178 public: | 176 public: |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 | 711 |
| 714 // Do not add any member variables to MessageLoopForIO! This is important b/c | 712 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 715 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 713 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 716 // data that you need should be stored on the MessageLoop's pump_ instance. | 714 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 717 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 715 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 718 MessageLoopForIO_should_not_have_extra_member_variables); | 716 MessageLoopForIO_should_not_have_extra_member_variables); |
| 719 | 717 |
| 720 } // namespace base | 718 } // namespace base |
| 721 | 719 |
| 722 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 720 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| OLD | NEW |