summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/base.gyp3
-rw-r--r--base/base.gypi10
-rw-r--r--base/message_pump_win.cc60
-rw-r--r--base/message_pump_win.h24
-rw-r--r--base/win/message_window.cc (renamed from remoting/host/win/message_window.cc)15
-rw-r--r--base/win/message_window.h (renamed from remoting/host/win/message_window.h)16
-rw-r--r--base/win/message_window_unittest.cc (renamed from remoting/host/win/message_window_unittest.cc)6
-rw-r--r--remoting/host/clipboard_win.cc10
-rw-r--r--remoting/host/local_input_monitor_win.cc10
-rw-r--r--remoting/host/win/host_service.cc2
-rw-r--r--remoting/host/win/host_service.h6
-rw-r--r--remoting/remoting.gyp3
-rw-r--r--tools/valgrind/tsan/suppressions.txt31
13 files changed, 73 insertions, 123 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 19e8af1..54508bf 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -626,6 +626,7 @@
'win/event_trace_provider_unittest.cc',
'win/i18n_unittest.cc',
'win/iunknown_impl_unittest.cc',
+ 'win/message_window_unittest.cc',
'win/object_watcher_unittest.cc',
'win/pe_image_unittest.cc',
'win/registry_unittest.cc',
@@ -634,9 +635,9 @@
'win/scoped_comptr_unittest.cc',
'win/scoped_handle_unittest.cc',
'win/scoped_process_information_unittest.cc',
+ 'win/scoped_variant_unittest.cc',
'win/shortcut_unittest.cc',
'win/startup_information_unittest.cc',
- 'win/scoped_variant_unittest.cc',
'win/win_util_unittest.cc',
'win/wrapped_window_proc_unittest.cc',
],
diff --git a/base/base.gypi b/base/base.gypi
index abfe1f5..8284f43 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -553,8 +553,8 @@
'nix/mime_util_xdg.h',
'nix/xdg_util.cc',
'nix/xdg_util.h',
- 'win/enum_variant.h',
'win/enum_variant.cc',
+ 'win/enum_variant.h',
'win/event_trace_consumer.h',
'win/event_trace_controller.cc',
'win/event_trace_controller.h',
@@ -564,8 +564,10 @@
'win/i18n.h',
'win/iat_patch_function.cc',
'win/iat_patch_function.h',
- 'win/iunknown_impl.h',
'win/iunknown_impl.cc',
+ 'win/iunknown_impl.h',
+ 'win/message_window.cc',
+ 'win/message_window.h',
'win/metro.cc',
'win/metro.h',
'win/object_watcher.cc',
@@ -598,10 +600,10 @@
'win/startup_information.h',
'win/text_services_message_filter.cc',
'win/text_services_message_filter.h',
- 'win/windows_version.cc',
- 'win/windows_version.h',
'win/win_util.cc',
'win/win_util.h',
+ 'win/windows_version.cc',
+ 'win/windows_version.h',
'win/wrapped_window_proc.cc',
'win/wrapped_window_proc.h',
],
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc
index fb962ca..e6ac6d0 100644
--- a/base/message_pump_win.cc
+++ b/base/message_pump_win.cc
@@ -9,8 +9,6 @@
#include "base/debug/trace_event.h"
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
-#include "base/process_util.h"
-#include "base/win/wrapped_window_proc.h"
namespace {
@@ -25,12 +23,13 @@ enum MessageLoopProblems {
namespace base {
-static const wchar_t kWndClass[] = L"Chrome_MessagePumpWindow";
-
// Message sent to get an additional time slice for pumping (processing) another
// task (a series of such messages creates a continuous task pump).
static const int kMsgHaveWork = WM_USER + 1;
+// Used by MessagePumpUI to wake up the thread and check any pending timers.
+static const int kTimerId = 1;
+
//-----------------------------------------------------------------------------
// MessagePumpWin public:
@@ -96,14 +95,12 @@ int MessagePumpWin::GetCurrentDelay() const {
// MessagePumpForUI public:
MessagePumpForUI::MessagePumpForUI()
- : instance_(NULL),
- message_filter_(new MessageFilter) {
- InitMessageWnd();
+ : message_filter_(new MessageFilter),
+ window_(new win::MessageWindow()) {
+ CHECK(window_->Create(this));
}
MessagePumpForUI::~MessagePumpForUI() {
- DestroyWindow(message_hwnd_);
- UnregisterClass(kWndClass, instance_);
}
void MessagePumpForUI::ScheduleWork() {
@@ -111,8 +108,7 @@ void MessagePumpForUI::ScheduleWork() {
return; // Someone else continued the pumping.
// Make sure the MessagePump does some work for us.
- BOOL ret = PostMessage(message_hwnd_, kMsgHaveWork,
- reinterpret_cast<WPARAM>(this), 0);
+ BOOL ret = PostMessage(window_->hwnd(), kMsgHaveWork, 0, 0);
if (ret)
return; // There was room in the Window Message queue.
@@ -159,8 +155,7 @@ void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) {
// Create a WM_TIMER event that will wake us up to check for any pending
// timers (in case we are running within a nested, external sub-pump).
- BOOL ret = SetTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this),
- delay_msec, NULL);
+ BOOL ret = SetTimer(window_->hwnd(), kTimerId, delay_msec, NULL);
if (ret)
return;
// If we can't set timers, we are in big trouble... but cross our fingers for
@@ -197,18 +192,23 @@ void MessagePumpForUI::PumpOutPendingPaintMessages() {
//-----------------------------------------------------------------------------
// MessagePumpForUI private:
-// static
-LRESULT CALLBACK MessagePumpForUI::WndProcThunk(
- HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
+bool MessagePumpForUI::HandleMessage(HWND hwnd,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam,
+ LRESULT* result) {
switch (message) {
case kMsgHaveWork:
- reinterpret_cast<MessagePumpForUI*>(wparam)->HandleWorkMessage();
+ HandleWorkMessage();
break;
+
case WM_TIMER:
- reinterpret_cast<MessagePumpForUI*>(wparam)->HandleTimerMessage();
+ HandleTimerMessage();
break;
}
- return DefWindowProc(hwnd, message, wparam, lparam);
+
+ // Do default processing for all messages.
+ return false;
}
void MessagePumpForUI::DoRunLoop() {
@@ -249,7 +249,7 @@ void MessagePumpForUI::DoRunLoop() {
// don't want to disturb that timer if it is already in flight. However,
// if we did do all remaining delayed work, then lets kill the WM_TIMER.
if (more_work_is_plausible && delayed_work_time_.is_null())
- KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
+ KillTimer(window_->hwnd(), kTimerId);
if (state_->should_quit)
break;
@@ -267,20 +267,6 @@ void MessagePumpForUI::DoRunLoop() {
}
}
-void MessagePumpForUI::InitMessageWnd() {
- WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(wc);
- wc.lpfnWndProc = base::win::WrappedWindowProc<WndProcThunk>;
- wc.hInstance = base::GetModuleFromAddress(wc.lpfnWndProc);
- wc.lpszClassName = kWndClass;
- instance_ = wc.hInstance;
- RegisterClassEx(&wc);
-
- message_hwnd_ =
- CreateWindow(kWndClass, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, instance_, 0);
- DCHECK(message_hwnd_);
-}
-
void MessagePumpForUI::WaitForWork() {
// Wait until a message is available, up to the time needed by the timer
// manager to fire the next set of timers.
@@ -338,7 +324,7 @@ void MessagePumpForUI::HandleWorkMessage() {
}
void MessagePumpForUI::HandleTimerMessage() {
- KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
+ KillTimer(window_->hwnd(), kTimerId);
// If we are being called outside of the context of Run, then don't do
// anything. This could correspond to a MessageBox call or something of
@@ -382,7 +368,7 @@ bool MessagePumpForUI::ProcessMessageHelper(const MSG& msg) {
}
// While running our main message pump, we discard kMsgHaveWork messages.
- if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_)
+ if (msg.message == kMsgHaveWork && msg.hwnd == window_->hwnd())
return ProcessPumpReplacementMessage();
if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode))
@@ -429,7 +415,7 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() {
}
DCHECK(!have_message || kMsgHaveWork != msg.message ||
- msg.hwnd != message_hwnd_);
+ msg.hwnd != window_->hwnd());
// Since we discarded a kMsgHaveWork message, we must update the flag.
int old_have_work = InterlockedExchange(&have_work_, 0);
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_;
};
//-----------------------------------------------------------------------------
diff --git a/remoting/host/win/message_window.cc b/base/win/message_window.cc
index b36b3f6..10d20ec 100644
--- a/remoting/host/win/message_window.cc
+++ b/base/win/message_window.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/win/message_window.h"
+#include "base/win/message_window.h"
#include "base/logging.h"
#include "base/process_util.h"
@@ -10,9 +10,9 @@
#include "base/utf_string_conversions.h"
#include "base/win/wrapped_window_proc.h"
-const char kClassNameFormat[] = "Chromoting_MessageWindow_%p";
+const char kClassNameFormat[] = "Chrome_MessageWindow_%p";
-namespace remoting {
+namespace base {
namespace win {
MessageWindow::MessageWindow()
@@ -24,13 +24,6 @@ MessageWindow::MessageWindow()
&base::win::WrappedWindowProc<WindowProc>));
}
-MessageWindow::MessageWindow(const std::string& class_name, HINSTANCE instance)
- : atom_(0),
- class_name_(class_name),
- instance_(instance),
- window_(NULL) {
-}
-
MessageWindow::~MessageWindow() {
DCHECK(CalledOnValidThread());
@@ -115,4 +108,4 @@ LRESULT CALLBACK MessageWindow::WindowProc(HWND hwnd,
}
} // namespace win
-} // namespace remoting
+} // namespace base
diff --git a/remoting/host/win/message_window.h b/base/win/message_window.h
index ecd2a36..9cc4573 100644
--- a/remoting/host/win/message_window.h
+++ b/base/win/message_window.h
@@ -2,25 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_HOST_WIN_MESSAGE_WINDOW_H_
-#define REMOTING_HOST_WIN_MESSAGE_WINDOW_H_
+#ifndef BASE_WIN_MESSAGE_WINDOW_H_
+#define BASE_WIN_MESSAGE_WINDOW_H_
#include <windows.h>
#include <string>
+#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/threading/non_thread_safe.h"
-namespace remoting {
+namespace base {
namespace win {
// Implements a message-only window.
-class MessageWindow : base::NonThreadSafe {
+class BASE_EXPORT MessageWindow : base::NonThreadSafe {
public:
// Handles incoming window messages.
- class Delegate {
+ class BASE_EXPORT Delegate {
public:
virtual ~Delegate() {}
@@ -32,7 +33,6 @@ class MessageWindow : base::NonThreadSafe {
};
MessageWindow();
- MessageWindow(const std::string& class_name, HINSTANCE instance);
~MessageWindow();
// Registers the window class and creates the window. The incoming messages
@@ -62,6 +62,6 @@ class MessageWindow : base::NonThreadSafe {
};
} // namespace win
-} // namespace remoting
+} // namespace base
-#endif // REMOTING_HOST_WIN_MESSAGE_WINDOW_H_
+#endif // BASE_WIN_MESSAGE_WINDOW_H_
diff --git a/remoting/host/win/message_window_unittest.cc b/base/win/message_window_unittest.cc
index d12af7b..5910a7b 100644
--- a/remoting/host/win/message_window_unittest.cc
+++ b/base/win/message_window_unittest.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/win/message_window.h"
+#include "base/win/message_window.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace remoting {
+namespace base {
namespace {
@@ -58,4 +58,4 @@ TEST(MessageWindowTest, SendMessage) {
EXPECT_EQ(SendMessage(window.hwnd(), WM_USER, 100, 0), 100);
}
-} // namespace remoting
+} // namespace base
diff --git a/remoting/host/clipboard_win.cc b/remoting/host/clipboard_win.cc
index 419316a4..fb32dd0 100644
--- a/remoting/host/clipboard_win.cc
+++ b/remoting/host/clipboard_win.cc
@@ -13,12 +13,12 @@
#include "base/string16.h"
#include "base/threading/platform_thread.h"
#include "base/utf_string_conversions.h"
+#include "base/win/message_window.h"
#include "base/win/scoped_hglobal.h"
#include "base/win/windows_version.h"
#include "base/win/wrapped_window_proc.h"
#include "remoting/base/constants.h"
#include "remoting/base/util.h"
-#include "remoting/host/win/message_window.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/clipboard_stub.h"
@@ -101,7 +101,7 @@ typedef BOOL (WINAPI RemoveClipboardFormatListenerFn)(HWND);
namespace remoting {
class ClipboardWin : public Clipboard,
- public win::MessageWindow::Delegate {
+ public base::win::MessageWindow::Delegate {
public:
ClipboardWin();
@@ -114,7 +114,7 @@ class ClipboardWin : public Clipboard,
private:
void OnClipboardUpdate();
- // win::MessageWindow::Delegate interface.
+ // base::win::MessageWindow::Delegate interface.
virtual bool HandleMessage(HWND hwnd,
UINT message,
WPARAM wparam,
@@ -126,7 +126,7 @@ class ClipboardWin : public Clipboard,
RemoveClipboardFormatListenerFn* remove_clipboard_format_listener_;
// Used to subscribe to WM_CLIPBOARDUPDATE messages.
- scoped_ptr<win::MessageWindow> window_;
+ scoped_ptr<base::win::MessageWindow> window_;
DISALLOW_COPY_AND_ASSIGN(ClipboardWin);
};
@@ -162,7 +162,7 @@ void ClipboardWin::Start(
LOG(WARNING) << "AddClipboardFormatListener() is not available.";
}
- window_.reset(new win::MessageWindow());
+ window_.reset(new base::win::MessageWindow());
if (!window_->Create(this)) {
LOG(ERROR) << "Couldn't create clipboard window.";
window_.reset();
diff --git a/remoting/host/local_input_monitor_win.cc b/remoting/host/local_input_monitor_win.cc
index 98cd8a4..5d4ce8c 100644
--- a/remoting/host/local_input_monitor_win.cc
+++ b/remoting/host/local_input_monitor_win.cc
@@ -11,8 +11,8 @@
#include "base/single_thread_task_runner.h"
#include "base/stringprintf.h"
#include "base/threading/non_thread_safe.h"
+#include "base/win/message_window.h"
#include "remoting/host/client_session_control.h"
-#include "remoting/host/win/message_window.h"
#include "third_party/skia/include/core/SkPoint.h"
namespace remoting {
@@ -37,7 +37,7 @@ class LocalInputMonitorWin : public base::NonThreadSafe,
private:
// The actual implementation resides in LocalInputMonitorWin::Core class.
class Core : public base::RefCountedThreadSafe<Core>,
- public win::MessageWindow::Delegate {
+ public base::win::MessageWindow::Delegate {
public:
Core(scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
@@ -56,7 +56,7 @@ class LocalInputMonitorWin : public base::NonThreadSafe,
// Handles WM_INPUT messages.
LRESULT OnInput(HRAWINPUT input_handle);
- // win::MessageWindow::Delegate interface.
+ // base::win::MessageWindow::Delegate interface.
virtual bool HandleMessage(HWND hwnd,
UINT message,
WPARAM wparam,
@@ -70,7 +70,7 @@ class LocalInputMonitorWin : public base::NonThreadSafe,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Used to receive raw input.
- scoped_ptr<win::MessageWindow> window_;
+ scoped_ptr<base::win::MessageWindow> window_;
// Points to the object receiving mouse event notifications.
base::WeakPtr<ClientSessionControl> client_session_control_;
@@ -127,7 +127,7 @@ LocalInputMonitorWin::Core::~Core() {
void LocalInputMonitorWin::Core::StartOnUiThread() {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
- window_.reset(new win::MessageWindow());
+ window_.reset(new base::win::MessageWindow());
if (!window_->Create(this)) {
LOG_GETLASTERROR(ERROR) << "Failed to create the raw input window";
window_.reset();
diff --git a/remoting/host/win/host_service.cc b/remoting/host/win/host_service.cc
index 42a8ed0..679603a 100644
--- a/remoting/host/win/host_service.cc
+++ b/remoting/host/win/host_service.cc
@@ -385,7 +385,7 @@ int HostService::RunInConsole() {
}
// Create a window for receiving session change notifications.
- win::MessageWindow window;
+ base::win::MessageWindow window;
if (!window.Create(this)) {
LOG_GETLASTERROR(ERROR)
<< "Failed to create the session notification window";
diff --git a/remoting/host/win/host_service.h b/remoting/host/win/host_service.h
index aa1d9ab..20b290f 100644
--- a/remoting/host/win/host_service.h
+++ b/remoting/host/win/host_service.h
@@ -12,8 +12,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "base/synchronization/waitable_event.h"
+#include "base/win/message_window.h"
#include "net/base/ip_endpoint.h"
-#include "remoting/host/win/message_window.h"
#include "remoting/host/win/wts_terminal_monitor.h"
class CommandLine;
@@ -28,7 +28,7 @@ class AutoThreadTaskRunner;
class Stoppable;
class WtsTerminalObserver;
-class HostService : public win::MessageWindow::Delegate,
+class HostService : public base::win::MessageWindow::Delegate,
public WtsTerminalMonitor {
public:
static HostService* GetInstance();
@@ -70,7 +70,7 @@ class HostService : public win::MessageWindow::Delegate,
// console application).
int RunInConsole();
- // win::MessageWindow::Delegate interface.
+ // base::win::MessageWindow::Delegate interface.
virtual bool HandleMessage(HWND hwnd,
UINT message,
WPARAM wparam,
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index b883868..5c6eb3c 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -464,8 +464,6 @@
'host/vlog_net_log.h',
'host/win/launch_process_with_token.cc',
'host/win/launch_process_with_token.h',
- 'host/win/message_window.cc',
- 'host/win/message_window.h',
'host/win/omaha.cc',
'host/win/omaha.h',
'host/win/rdp_client.cc',
@@ -2642,7 +2640,6 @@
'host/setup/pin_validator_unittest.cc',
'host/token_validator_factory_impl_unittest.cc',
'host/video_scheduler_unittest.cc',
- 'host/win/message_window_unittest.cc',
'host/win/rdp_client_unittest.cc',
'host/win/worker_process_launcher.cc',
'host/win/worker_process_launcher.h',
diff --git a/tools/valgrind/tsan/suppressions.txt b/tools/valgrind/tsan/suppressions.txt
index a771a48..2650100 100644
--- a/tools/valgrind/tsan/suppressions.txt
+++ b/tools/valgrind/tsan/suppressions.txt
@@ -1126,34 +1126,3 @@
...
fun:media::FFmpegVideoDecoder::Decode
}
-{
- bug_241939a
- ThreadSanitizer:Race
- fun:CreateDialogParamW
- fun:CharPrevW
- fun:SystemParametersInfoW
- fun:RegisterClassExW
- fun:base::MessagePumpForUI::InitMessageWnd
- fun:base::MessagePumpForUI::MessagePumpForUI
- fun:base::MessageLoop::MessageLoop
- fun:remoting::AutoThread::ThreadMain
-}
-{
- bug_241939b
- ThreadSanitizer:Race
- fun:GetWindowLongW
- fun:GetWindowLongW
- fun:GetWindowLongW
- fun:PostMessageW
- fun:PostMessageW
- fun:SetWindowTextW
- fun:KiUserCallbackDispatcher
- fun:LoadStringA
- fun:LoadStringA
- fun:LoadStringA
- fun:CreateWindowExW
- fun:base::MessagePumpForUI::InitMessageWnd
- fun:base::MessagePumpForUI::MessagePumpForUI
- fun:base::MessageLoop::MessageLoop
- fun:remoting::AutoThread::ThreadMain
-}