| Index: base/message_loop/message_pump_win.h
|
| diff --git a/base/message_loop/message_pump_win.h b/base/message_loop/message_pump_win.h
|
| index 6f4b699cefdfce5a3fac2249d6ebbcc2bf4c5bed..69291dc78a83370634370e78612318d70fda47ce 100644
|
| --- a/base/message_loop/message_pump_win.h
|
| +++ b/base/message_loop/message_pump_win.h
|
| @@ -22,7 +22,7 @@ namespace base {
|
| // controlling the lifetime of the message pump.
|
| class BASE_EXPORT MessagePumpWin : public MessagePump {
|
| public:
|
| - MessagePumpWin() : have_work_(0), state_(NULL) {}
|
| + MessagePumpWin() : work_state_(READY), state_(NULL) {}
|
|
|
| // MessagePump methods:
|
| void Run(Delegate* delegate) override;
|
| @@ -39,22 +39,69 @@ class BASE_EXPORT MessagePumpWin : public MessagePump {
|
| int run_depth;
|
| };
|
|
|
| + // State used with work_state_ variable.
|
| + enum WorkState {
|
| + READY = 0, // Ready to accept new work.
|
| + HAVE_WORK = 1, // New work has been signalled.
|
| + WORKING = 2 // Handling the work.
|
| + };
|
| +
|
| virtual void DoRunLoop() = 0;
|
| int GetCurrentDelay() const;
|
|
|
| // The time at which delayed work should run.
|
| TimeTicks delayed_work_time_;
|
|
|
| - // A boolean value used to indicate if there is a kMsgDoWork message pending
|
| + // A value used to indicate if there is a kMsgDoWork message pending
|
| // in the Windows Message queue. There is at most one such message, and it
|
| // can drive execution of tasks when a native message pump is running.
|
| - LONG have_work_;
|
| + LONG work_state_;
|
|
|
| // State for the current invocation of Run.
|
| RunState* state_;
|
| };
|
|
|
| //-----------------------------------------------------------------------------
|
| +// MessagePumpForUIBase serves as a base class for for specialized versions of
|
| +// MessagePump instantiated with TYPE_UI. It provides basic functionality for
|
| +// creating a hidden window with a message queue and handling window messages,
|
| +// including the special kMsgHaveWork message that indicates the scheduled work,
|
| +// handling timers, etc.
|
| +//
|
| +class BASE_EXPORT MessagePumpForUIBase : public MessagePumpWin {
|
| + public:
|
| + // The application-defined code passed to the hook procedure.
|
| + static const int kMessageFilterCode = 0x5001;
|
| +
|
| + MessagePumpForUIBase();
|
| + ~MessagePumpForUIBase() override;
|
| +
|
| + // MessagePump methods:
|
| + void ScheduleWork() override;
|
| +
|
| + protected:
|
| + virtual void HandleWorkMessage() = 0;
|
| + virtual void HandleTimerMessage() = 0;
|
| +
|
| + bool IsWorkMessage(const MSG& msg) const;
|
| + void SetTimer(int delay_msec);
|
| + void KillTimer();
|
| +
|
| + private:
|
| + static LRESULT CALLBACK WndProcThunk(HWND window_handle,
|
| + UINT message,
|
| + WPARAM wparam,
|
| + LPARAM lparam);
|
| + void InitMessageWnd();
|
| +
|
| + // Atom representing the registered window class.
|
| + ATOM atom_;
|
| +
|
| + // A hidden message-only window.
|
| + HWND message_hwnd_;
|
| +};
|
| +
|
| +//-----------------------------------------------------------------------------
|
| // MessagePumpForUI extends MessagePumpWin with methods that are particular to a
|
| // MessageLoop instantiated with TYPE_UI.
|
| //
|
| @@ -102,38 +149,53 @@ class BASE_EXPORT MessagePumpWin : public MessagePump {
|
| // an excellent choice. It is also helpful that the starter messages that are
|
| // placed in the queue when new task arrive also awakens DoRunLoop.
|
| //
|
| -class BASE_EXPORT MessagePumpForUI : public MessagePumpWin {
|
| +class BASE_EXPORT MessagePumpForUI : public MessagePumpForUIBase {
|
| public:
|
| - // The application-defined code passed to the hook procedure.
|
| - static const int kMessageFilterCode = 0x5001;
|
| -
|
| MessagePumpForUI();
|
| ~MessagePumpForUI() override;
|
|
|
| + private:
|
| // MessagePump methods:
|
| - void ScheduleWork() override;
|
| + void DoRunLoop() override;
|
| void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override;
|
|
|
| - private:
|
| - static LRESULT CALLBACK WndProcThunk(HWND window_handle,
|
| - UINT message,
|
| - WPARAM wparam,
|
| - LPARAM lparam);
|
| - void DoRunLoop() override;
|
| - void InitMessageWnd();
|
| - void WaitForWork();
|
| - void HandleWorkMessage();
|
| - void HandleTimerMessage();
|
| - void RescheduleTimer();
|
| + void HandleWorkMessage() override;
|
| + void HandleTimerMessage() override;
|
| +
|
| bool ProcessNextWindowsMessage();
|
| + void WaitForWork();
|
| +
|
| bool ProcessMessageHelper(const MSG& msg);
|
| bool ProcessPumpReplacementMessage();
|
| + void RescheduleTimer();
|
| +};
|
|
|
| - // Atom representing the registered window class.
|
| - ATOM atom_;
|
| +//-----------------------------------------------------------------------------
|
| +// MessagePumpForGpu is a simplified version of MessagePumpForUI that is
|
| +// optimized for the GPU process. Unlike MessagePumpForUI it doesn't handle a
|
| +// situation where a native message pump might be used by modal dialogs and
|
| +// message boxes. That allows to skip some system calls like setting and killing
|
| +// timers, getting status of the message queue, etc.
|
|
|
| - // A hidden message-only window.
|
| - HWND message_hwnd_;
|
| +class BASE_EXPORT MessagePumpForGpu : public MessagePumpForUIBase {
|
| + public:
|
| + MessagePumpForGpu();
|
| + ~MessagePumpForGpu() override;
|
| +
|
| + // Factory methods.
|
| + static void InitFactory();
|
| + static scoped_ptr<MessagePump> CreateMessagePumpForGpu();
|
| +
|
| + private:
|
| + // MessagePump methods:
|
| + void DoRunLoop() override;
|
| + void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override;
|
| +
|
| + void HandleWorkMessage() override;
|
| + void HandleTimerMessage() override;
|
| +
|
| + void ProcessWindowsMessages();
|
| + void WaitForWork();
|
| };
|
|
|
| //-----------------------------------------------------------------------------
|
|
|