summaryrefslogtreecommitdiffstats
path: root/base/message_pump_win.h
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 01:34:51 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 01:34:51 +0000
commitd5eb9ccc118f56565325cff1cbb24571511d1925 (patch)
treee5b9c05d2954b4c1f416970c8647463587aa73a1 /base/message_pump_win.h
parent3214fd26bb2ccd17e2611f69c895f4b43cf87bf1 (diff)
downloadchromium_src-d5eb9ccc118f56565325cff1cbb24571511d1925.zip
chromium_src-d5eb9ccc118f56565325cff1cbb24571511d1925.tar.gz
chromium_src-d5eb9ccc118f56565325cff1cbb24571511d1925.tar.bz2
Allow multiple base::MessagePumpForUI instances to be created simultanenously on Windows.
The current implementation of base::MessagePumpForUI on Windows registers a window class with a predefined name in order to create a message-only window. The window class is unregistered when base::MessagePumpForUI is deleted. This causes issues when two or more instances of base::MessagePumpForUI are created/destroyed simultanenously on different threads. For instance once thread can unregister the window class right before the other thread is trying to create a window using this class. The CL addresses this problem by switching MessageWindow to implement a message-only window. It also moves MessageWindow from remoting/host/win to base/win along with the corresponding unit test. MessageWindow registers a uniquely named window class per MessageWindow instance making sure that different MessageWindow objects do not share any resources. In the future this can be optimized further by registering a common window class shared by all MessageWindow objects in a thread-safe manner (by using LazyInstance for example). BUG=241939 Review URL: https://chromiumcodereview.appspot.com/15261005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_win.h')
-rw-r--r--base/message_pump_win.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/base/message_pump_win.h b/base/message_pump_win.h
index 5ea195f..67b076d 100644
--- a/base/message_pump_win.h
+++ b/base/message_pump_win.h
@@ -17,6 +17,7 @@
#include "base/message_pump_observer.h"
#include "base/observer_list.h"
#include "base/time.h"
+#include "base/win/message_window.h"
#include "base/win/scoped_handle.h"
namespace base {
@@ -125,7 +126,9 @@ 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 MessagePumpWin,
+ public win::MessageWindow::Delegate {
public:
// A MessageFilter implements the common Peek/Translate/Dispatch code to deal
// with windows messages.
@@ -175,12 +178,14 @@ class BASE_EXPORT MessagePumpForUI : public MessagePumpWin {
void PumpOutPendingPaintMessages();
private:
- static LRESULT CALLBACK WndProcThunk(HWND window_handle,
- UINT message,
- WPARAM wparam,
- LPARAM lparam);
+ // win::MessageWindow::Delegate interface.
+ virtual bool HandleMessage(HWND hwnd,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam,
+ LRESULT* result) OVERRIDE;
+
virtual void DoRunLoop();
- void InitMessageWnd();
void WaitForWork();
void HandleWorkMessage();
void HandleTimerMessage();
@@ -188,13 +193,10 @@ class BASE_EXPORT MessagePumpForUI : public MessagePumpWin {
bool ProcessMessageHelper(const MSG& msg);
bool ProcessPumpReplacementMessage();
- // Instance of the module containing the window procedure.
- HMODULE instance_;
+ scoped_ptr<MessageFilter> message_filter_;
// A hidden message-only window.
- HWND message_hwnd_;
-
- scoped_ptr<MessageFilter> message_filter_;
+ scoped_ptr<win::MessageWindow> window_;
};
//-----------------------------------------------------------------------------