| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PUMP_DISPATCHER_H | 5 #ifndef BASE_MESSAGE_PUMP_DISPATCHER_H |
| 6 #define BASE_MESSAGE_PUMP_DISPATCHER_H | 6 #define BASE_MESSAGE_PUMP_DISPATCHER_H |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
| 10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 | 13 |
| 14 // Dispatcher is used during a nested invocation of Run to dispatch | 14 // Dispatcher is used during a nested invocation of Run to dispatch |
| 15 // events when |MessageLoop::RunWithDispatcher| is invoked. If | 15 // events when |MessageLoop::RunWithDispatcher| is invoked. If |
| 16 // |MessageLoop::Run| is invoked, MessageLoop does not dispatch events | 16 // |MessageLoop::Run| is invoked, MessageLoop does not dispatch events |
| 17 // (or invoke TranslateMessage), rather every message is passed to | 17 // (or invoke TranslateMessage), rather every message is passed to |
| 18 // Dispatcher's Dispatch method for dispatch. It is up to the | 18 // Dispatcher's Dispatch() method for dispatch. It is up to the |
| 19 // Dispatcher whether or not to dispatch the event. | 19 // Dispatcher whether or not to dispatch the event. Additionally, before |
| 20 // any Tasks are processed ShouldExit() is invoked. |
| 20 // | 21 // |
| 21 // The nested loop is exited by either posting a quit, or returning false | 22 // The nested loop is exited by either posting a quit, or returning false from |
| 22 // from Dispatch. | 23 // Dispatch() or ShouldExit(). |
| 23 class BASE_EXPORT MessagePumpDispatcher { | 24 class BASE_EXPORT MessagePumpDispatcher { |
| 24 public: | 25 public: |
| 25 virtual ~MessagePumpDispatcher() {} | 26 virtual ~MessagePumpDispatcher() {} |
| 26 | 27 |
| 27 // Dispatches the event. If true is returned processing continues as | 28 // Dispatches the event. If true is returned processing continues as |
| 28 // normal. If false is returned, the nested loop exits immediately. | 29 // normal. If false is returned, the nested loop exits immediately. |
| 29 virtual bool Dispatch(const NativeEvent& event) = 0; | 30 virtual bool Dispatch(const NativeEvent& event) = 0; |
| 31 |
| 32 // Returns true if the loop should exit before processing a task. |
| 33 // NOTE: this is currently only wired up on Linux. |
| 34 virtual bool ShouldExit() = 0; |
| 30 }; | 35 }; |
| 31 | 36 |
| 32 } // namespace base | 37 } // namespace base |
| 33 | 38 |
| 34 #endif // BASE_MESSAGE_PUMP_DISPATCHER_H | 39 #endif // BASE_MESSAGE_PUMP_DISPATCHER_H |
| OLD | NEW |