| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // that doing so is fairly dangerous if the target thread makes nested calls | 240 // that doing so is fairly dangerous if the target thread makes nested calls |
| 241 // to MessageLoop::Run. The problem being that you won't know which nested | 241 // to MessageLoop::Run. The problem being that you won't know which nested |
| 242 // run loop you are quiting, so be careful! | 242 // run loop you are quiting, so be careful! |
| 243 // | 243 // |
| 244 void Quit(); | 244 void Quit(); |
| 245 | 245 |
| 246 // This method is a variant of Quit, that does not wait for pending messages | 246 // This method is a variant of Quit, that does not wait for pending messages |
| 247 // to be processed before returning from Run. | 247 // to be processed before returning from Run. |
| 248 void QuitNow(); | 248 void QuitNow(); |
| 249 | 249 |
| 250 // Cancels the signal to quit once the pending messages are processed. This |
| 251 // method may only be called on the same thread that called Run, and Run must |
| 252 // still be on the call stack. |
| 253 void CancelQuit(); |
| 254 |
| 250 // Invokes Quit on the current MessageLoop when run. Useful to schedule an | 255 // Invokes Quit on the current MessageLoop when run. Useful to schedule an |
| 251 // arbitrary MessageLoop to Quit. | 256 // arbitrary MessageLoop to Quit. |
| 252 class QuitTask : public Task { | 257 class QuitTask : public Task { |
| 253 public: | 258 public: |
| 254 virtual void Run() { | 259 virtual void Run() { |
| 255 MessageLoop::current()->Quit(); | 260 MessageLoop::current()->Quit(); |
| 256 } | 261 } |
| 257 }; | 262 }; |
| 258 | 263 |
| 259 // Returns the type passed to the constructor. | 264 // Returns the type passed to the constructor. |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 #endif // defined(OS_POSIX) | 693 #endif // defined(OS_POSIX) |
| 689 }; | 694 }; |
| 690 | 695 |
| 691 // Do not add any member variables to MessageLoopForIO! This is important b/c | 696 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 692 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 697 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 693 // data that you need should be stored on the MessageLoop's pump_ instance. | 698 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 694 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 699 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 695 MessageLoopForIO_should_not_have_extra_member_variables); | 700 MessageLoopForIO_should_not_have_extra_member_variables); |
| 696 | 701 |
| 697 #endif // BASE_MESSAGE_LOOP_H_ | 702 #endif // BASE_MESSAGE_LOOP_H_ |
| OLD | NEW |