summaryrefslogtreecommitdiffstats
path: root/base/win/message_window.cc
diff options
context:
space:
mode:
authordbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 04:29:15 +0000
committerdbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 04:29:15 +0000
commit61cd852a6fd0ecc6454a2df1030fa55e580a3d1e (patch)
tree060ef13df1f6a534b11c2ffc4ce025ac145ee41b /base/win/message_window.cc
parentd68bbd5dd956b7e8593e4410d15931ff6f8c1aca (diff)
downloadchromium_src-61cd852a6fd0ecc6454a2df1030fa55e580a3d1e.zip
chromium_src-61cd852a6fd0ecc6454a2df1030fa55e580a3d1e.tar.gz
chromium_src-61cd852a6fd0ecc6454a2df1030fa55e580a3d1e.tar.bz2
Revert 201955 "Allow multiple base::MessagePumpForUI instances t..."
Broke browser_tests on XP Tests (dbg)(4): http://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%28dbg%29%284%29/builds/33253 [844:3260:0523/194017:1212046:FATAL:message_window.cc(28)] Check failed: CalledOnValidThread(). Backtrace: base::Histogram::GetCountAndBucketData [0x08408FD1+2262176] base::Histogram::GetCountAndBucketData [0x0827FBBE+651405] base::Histogram::GetCountAndBucketData [0x082E1E60+1053487] base::Histogram::GetCountAndBucketData [0x0825CC46+508181] base::Histogram::GetCountAndBucketData [0x0825BB66+503861] base::Histogram::GetCountAndBucketData [0x0825A534+498179] base::Histogram::GetCountAndBucketData [0x08256C16+483557] base::Histogram::GetCountAndBucketData [0x08256C82+483665] base::Histogram::GetCountAndBucketData [0x08256324+481267] base::Histogram::GetCountAndBucketData [0x081F59AF+85630] base::Histogram::GetCountAndBucketData [0x081F84AC+96635] base::Histogram::GetCountAndBucketData [0x081F5917+85478] base::Histogram::GetCountAndBucketData [0x08249FD3+431266] base::Histogram::GetCountAndBucketData [0x08249255+427812] base::Histogram::GetCountAndBucketData [0x082462CD+415644] base::Histogram::GetCountAndBucketData [0x0831D883+1297746] base::Histogram::GetCountAndBucketData [0x0831D602+1297105] ViewHostMsg_TextInputStateChanged::Read [0x0D3DD6F9+6214944] ViewHostMsg_TextInputStateChanged::Read [0x0D3DD584+6214571] ViewHostMsg_TextInputStateChanged::Read [0x0D33048E+5505717] ViewHostMsg_TextInputStateChanged::Read [0x0D3303FA+5505569] ViewHostMsg_TextInputStateChanged::Read [0x0D32DDEA+5495825] ViewHostMsg_TextInputStateChanged::Read [0x0D32BAC7+5486830] ViewHostMsg_TextInputStateChanged::Read [0x0D3DC9B6+6211549] ViewHostMsg_TextInputStateChanged::Read [0x0D367071+5729944] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x03E93429+30896697] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x025BD0DF+4853487] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x02701C3F+6183503] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x026EECCB+6105819] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x026EF6DD+6108397] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x026EFEAF+6110399] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x026F673D+6137165] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x02702637+6186055] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x026F4FA0+6131120] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x0262E070+5316224] (No symbol) [0x00632BF5] RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x03E2BD73+30473091] (No symbol) [0x00632975] std::_Init_locks::operator= [0x03F5574F+5791] std::_Init_locks::operator= [0x03F5557F+5327] RegisterWaitForInputIdle [0x7C817077+73] > 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 TBR=alexeypa@chromium.org Review URL: https://codereview.chromium.org/15973003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win/message_window.cc')
-rw-r--r--base/win/message_window.cc111
1 files changed, 0 insertions, 111 deletions
diff --git a/base/win/message_window.cc b/base/win/message_window.cc
deleted file mode 100644
index 10d20ec..0000000
--- a/base/win/message_window.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/win/message_window.h"
-
-#include "base/logging.h"
-#include "base/process_util.h"
-#include "base/stringprintf.h"
-#include "base/utf_string_conversions.h"
-#include "base/win/wrapped_window_proc.h"
-
-const char kClassNameFormat[] = "Chrome_MessageWindow_%p";
-
-namespace base {
-namespace win {
-
-MessageWindow::MessageWindow()
- : atom_(0),
- instance_(NULL),
- window_(NULL) {
- class_name_ = base::StringPrintf(kClassNameFormat, this);
- instance_ = base::GetModuleFromAddress(static_cast<WNDPROC>(
- &base::win::WrappedWindowProc<WindowProc>));
-}
-
-MessageWindow::~MessageWindow() {
- DCHECK(CalledOnValidThread());
-
- if (window_ != NULL) {
- DestroyWindow(window_);
- window_ = NULL;
- }
-
- if (atom_ != 0) {
- UnregisterClass(MAKEINTATOM(atom_), instance_);
- atom_ = 0;
- }
-}
-
-bool MessageWindow::Create(Delegate* delegate) {
- DCHECK(CalledOnValidThread());
- DCHECK(!atom_);
- DCHECK(!window_);
-
- // Register a separate window class for each instance of |MessageWindow|.
- string16 class_name = UTF8ToUTF16(class_name_);
- WNDCLASSEX window_class;
- window_class.cbSize = sizeof(window_class);
- window_class.style = 0;
- window_class.lpfnWndProc = &base::win::WrappedWindowProc<WindowProc>;
- window_class.cbClsExtra = 0;
- window_class.cbWndExtra = 0;
- window_class.hInstance = instance_;
- window_class.hIcon = NULL;
- window_class.hCursor = NULL;
- window_class.hbrBackground = NULL;
- window_class.lpszMenuName = NULL;
- window_class.lpszClassName = class_name.c_str();
- window_class.hIconSm = NULL;
- atom_ = RegisterClassEx(&window_class);
- if (atom_ == 0) {
- LOG_GETLASTERROR(ERROR)
- << "Failed to register the window class '" << class_name_ << "'";
- return false;
- }
-
- window_ = CreateWindow(MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0,
- instance_, delegate);
- if (!window_) {
- LOG_GETLASTERROR(ERROR) << "Failed to create a message-only window";
- return false;
- }
-
- return true;
-}
-
-// static
-LRESULT CALLBACK MessageWindow::WindowProc(HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam) {
- Delegate* delegate = NULL;
-
- // Set up the delegate before handling WM_CREATE.
- if (message == WM_CREATE) {
- CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lparam);
- delegate = reinterpret_cast<Delegate*>(cs->lpCreateParams);
-
- // Store pointer to the delegate to the window's user data.
- SetLastError(ERROR_SUCCESS);
- LONG_PTR result = SetWindowLongPtr(
- hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(delegate));
- CHECK(result != 0 || GetLastError() == ERROR_SUCCESS);
- } else {
- delegate = reinterpret_cast<Delegate*>(GetWindowLongPtr(hwnd,
- GWLP_USERDATA));
- }
-
- // Handle the message.
- if (delegate) {
- LRESULT message_result;
- if (delegate->HandleMessage(hwnd, message, wparam, lparam, &message_result))
- return message_result;
- }
-
- return DefWindowProc(hwnd, message, wparam, lparam);
-}
-
-} // namespace win
-} // namespace base