| 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_LOOP_MESSAGE_PUMP_WIN_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ |
| 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 14 #include "base/message_loop/message_pump.h" | 14 #include "base/message_loop/message_pump.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/win/scoped_handle.h" | 16 #include "base/win/scoped_handle.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 | 19 |
| 20 // MessagePumpWin serves as the base for specialized versions of the MessagePump | 20 // MessagePumpWin serves as the base for specialized versions of the MessagePump |
| 21 // for Windows. It provides basic functionality like handling of observers and | 21 // for Windows. It provides basic functionality like handling of observers and |
| 22 // controlling the lifetime of the message pump. | 22 // controlling the lifetime of the message pump. |
| 23 class BASE_EXPORT MessagePumpWin : public MessagePump { | 23 class BASE_EXPORT MessagePumpWin : public MessagePump { |
| 24 public: | 24 public: |
| 25 MessagePumpWin() : work_state_(READY), state_(NULL) {} | 25 MessagePumpWin(); |
| 26 | 26 |
| 27 // MessagePump methods: | 27 // MessagePump methods: |
| 28 void Run(Delegate* delegate) override; | 28 void Run(Delegate* delegate) override; |
| 29 void Quit() override; | 29 void Quit() override; |
| 30 | 30 |
| 31 protected: | 31 protected: |
| 32 struct RunState { | 32 struct RunState { |
| 33 Delegate* delegate; | 33 Delegate* delegate; |
| 34 | 34 |
| 35 // Used to flag that the current Run() invocation should return ASAP. | 35 // Used to flag that the current Run() invocation should return ASAP. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 | 53 |
| 54 virtual void DoRunLoop() = 0; | 54 virtual void DoRunLoop() = 0; |
| 55 int GetCurrentDelay() const; | 55 int GetCurrentDelay() const; |
| 56 | 56 |
| 57 // The time at which delayed work should run. | 57 // The time at which delayed work should run. |
| 58 TimeTicks delayed_work_time_; | 58 TimeTicks delayed_work_time_; |
| 59 | 59 |
| 60 // A value used to indicate if there is a kMsgDoWork message pending | 60 // A value used to indicate if there is a kMsgDoWork message pending |
| 61 // in the Windows Message queue. There is at most one such message, and it | 61 // in the Windows Message queue. There is at most one such message, and it |
| 62 // can drive execution of tasks when a native message pump is running. | 62 // can drive execution of tasks when a native message pump is running. |
| 63 LONG work_state_; | 63 LONG work_state_ = READY; |
| 64 | 64 |
| 65 // State for the current invocation of Run. | 65 // State for the current invocation of Run. |
| 66 RunState* state_; | 66 RunState* state_ = nullptr; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 //----------------------------------------------------------------------------- | 69 //----------------------------------------------------------------------------- |
| 70 // MessagePumpForUI extends MessagePumpWin with methods that are particular to a | 70 // MessagePumpForUI extends MessagePumpWin with methods that are particular to a |
| 71 // MessageLoop instantiated with TYPE_UI. | 71 // MessageLoop instantiated with TYPE_UI. |
| 72 // | 72 // |
| 73 // MessagePumpForUI implements a "traditional" Windows message pump. It contains | 73 // MessagePumpForUI implements a "traditional" Windows message pump. It contains |
| 74 // a nearly infinite loop that peeks out messages, and then dispatches them. | 74 // a nearly infinite loop that peeks out messages, and then dispatches them. |
| 75 // Intermixed with those peeks are callouts to DoWork for pending tasks, and | 75 // Intermixed with those peeks are callouts to DoWork for pending tasks, and |
| 76 // DoDelayedWork for pending timers. When there are no events to be serviced, | 76 // DoDelayedWork for pending timers. When there are no events to be serviced, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // The completion port associated with this thread. | 284 // The completion port associated with this thread. |
| 285 win::ScopedHandle port_; | 285 win::ScopedHandle port_; |
| 286 // This list will be empty almost always. It stores IO completions that have | 286 // This list will be empty almost always. It stores IO completions that have |
| 287 // not been delivered yet because somebody was doing cleanup. | 287 // not been delivered yet because somebody was doing cleanup. |
| 288 std::list<IOItem> completed_io_; | 288 std::list<IOItem> completed_io_; |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 } // namespace base | 291 } // namespace base |
| 292 | 292 |
| 293 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ | 293 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ |
| OLD | NEW |