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 3 // found in the LICENSE file. 4 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_DISPATCHER_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DISPATCHER_H_ 7 8 #include <stdint.h> 9 10 #include "base/base_export.h" 11 #include "base/event_types.h" 12 13 namespace base { 14 15 // Dispatcher is used during a nested invocation of Run to dispatch events when 16 // |RunLoop(dispatcher).Run()| is used. If |RunLoop().Run()| is invoked, 17 // MessageLoop does not dispatch events (or invoke TranslateMessage), rather 18 // every message is passed to Dispatcher's Dispatch method for dispatch. It is 19 // up to the Dispatcher whether or not to dispatch the event. 20 // 21 // The nested loop is exited by either posting a quit, or setting the 22 // POST_DISPATCH_QUIT_LOOP flag on the return value from Dispatch. 23 class BASE_EXPORT MessagePumpDispatcher { 24 public: 25 enum PostDispatchAction { 26 POST_DISPATCH_NONE = 0x0, 27 POST_DISPATCH_QUIT_LOOP = 0x1, 28 POST_DISPATCH_PERFORM_DEFAULT = 0x2, 29 }; 30 31 virtual ~MessagePumpDispatcher() {} 32 33 // Dispatches the event. The return value can have more than one 34 // PostDispatchAction flags OR'ed together. If POST_DISPATCH_PERFORM_DEFAULT 35 // is set in the returned value, then the message-pump performs the default 36 // action. If POST_DISPATCH_QUIT_LOOP is set, in the return value, then the 37 // nested loop exits immediately. 38 virtual uint32_t Dispatch(const NativeEvent& event) = 0; 39 }; 40 41 } // namespace base 42 43 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_DISPATCHER_H_ 44