summaryrefslogtreecommitdiffstats
path: root/base/message_pump_win.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-25 20:33:04 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-25 20:33:04 +0000
commit1a8f5d1d016723fb1fcc49b1fc5290fa1b7f2706 (patch)
tree7843845f2e67e3f021cff8244da0f1c9feae4385 /base/message_pump_win.h
parent8c237a11dcc958f063d14d4419524612ae8c6ac1 (diff)
downloadchromium_src-1a8f5d1d016723fb1fcc49b1fc5290fa1b7f2706.zip
chromium_src-1a8f5d1d016723fb1fcc49b1fc5290fa1b7f2706.tar.gz
chromium_src-1a8f5d1d016723fb1fcc49b1fc5290fa1b7f2706.tar.bz2
As an intermediate step towards having a message pump handling IO through completion ports, this CL creates two types of message pumps for windows: one to handle UI threads and another one to handle IO threads.
I'm basically moving stuff around, except by the fact that now UI threads will not process APCs or wait on objects (those things only happen on message loops of TYPE_IO) Review URL: http://codereview.chromium.org/3094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_win.h')
-rw-r--r--base/message_pump_win.h74
1 files changed, 50 insertions, 24 deletions
diff --git a/base/message_pump_win.h b/base/message_pump_win.h
index 0de3b89..0192e3c 100644
--- a/base/message_pump_win.h
+++ b/base/message_pump_win.h
@@ -62,15 +62,6 @@ namespace base {
//
class MessagePumpWin : public MessagePump {
public:
- // Used with WatchObject to asynchronously monitor the signaled state of a
- // HANDLE object.
- class Watcher {
- public:
- virtual ~Watcher() {}
- // Called from MessageLoop::Run when a signalled object is detected.
- virtual void OnObjectSignaled(HANDLE object) = 0;
- };
-
// An Observer is an object that receives global notifications from the
// MessageLoop.
//
@@ -106,11 +97,7 @@ class MessagePumpWin : public MessagePump {
};
MessagePumpWin();
- ~MessagePumpWin();
-
- // Have the current thread's message loop watch for a signaled object.
- // Pass a null watcher to stop watching the object.
- void WatchObject(HANDLE, Watcher*);
+ virtual ~MessagePumpWin();
// Add an Observer, which will start receiving notifications immediately.
void AddObserver(Observer* observer);
@@ -138,7 +125,7 @@ class MessagePumpWin : public MessagePump {
virtual void ScheduleWork();
virtual void ScheduleDelayedWork(const Time& delayed_work_time);
- private:
+ protected:
struct RunState {
Delegate* delegate;
Dispatcher* dispatcher;
@@ -152,26 +139,18 @@ class MessagePumpWin : public MessagePump {
static LRESULT CALLBACK WndProcThunk(
HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
+ virtual void DoRunLoop() = 0;
void InitMessageWnd();
void HandleWorkMessage();
void HandleTimerMessage();
- void DoRunLoop();
- void WaitForWork();
bool ProcessNextWindowsMessage();
bool ProcessMessageHelper(const MSG& msg);
bool ProcessPumpReplacementMessage();
- bool ProcessNextObject();
- bool SignalWatcher(size_t object_index);
int GetCurrentDelay() const;
// A hidden message-only window.
HWND message_hwnd_;
- // A vector of objects (and corresponding watchers) that are routinely
- // serviced by this message pump.
- std::vector<HANDLE> objects_;
- std::vector<Watcher*> watchers_;
-
ObserverList<Observer> observers_;
// The time at which delayed work should run.
@@ -186,6 +165,53 @@ class MessagePumpWin : public MessagePump {
RunState* state_;
};
+//-----------------------------------------------------------------------------
+// MessagePumpForUI extends MessagePumpWin with methods that are particular to a
+// MessageLoop instantiated with TYPE_UI.
+//
+class MessagePumpForUI : public MessagePumpWin {
+ public:
+ MessagePumpForUI() {}
+ virtual ~MessagePumpForUI() {}
+ private:
+ virtual void DoRunLoop();
+ void WaitForWork();
+};
+
+//-----------------------------------------------------------------------------
+// MessagePumpForIO extends MessagePumpWin with methods that are particular to a
+// MessageLoop instantiated with TYPE_IO.
+//
+class MessagePumpForIO : public MessagePumpWin {
+ public:
+ // Used with WatchObject to asynchronously monitor the signaled state of a
+ // HANDLE object.
+ class Watcher {
+ public:
+ virtual ~Watcher() {}
+ // Called from MessageLoop::Run when a signalled object is detected.
+ virtual void OnObjectSignaled(HANDLE object) = 0;
+ };
+
+ MessagePumpForIO() {}
+ virtual ~MessagePumpForIO() {}
+
+ // Have the current thread's message loop watch for a signaled object.
+ // Pass a null watcher to stop watching the object.
+ void WatchObject(HANDLE, Watcher*);
+
+ private:
+ virtual void DoRunLoop();
+ void WaitForWork();
+ bool ProcessNextObject();
+ bool SignalWatcher(size_t object_index);
+
+ // A vector of objects (and corresponding watchers) that are routinely
+ // serviced by this message pump.
+ std::vector<HANDLE> objects_;
+ std::vector<Watcher*> watchers_;
+};
+
} // namespace base
#endif // BASE_MESSAGE_PUMP_WIN_H_