Chromium Code Reviews| Index: base/win/message_window.cc |
| diff --git a/remoting/host/win/message_window.cc b/base/win/message_window.cc |
| similarity index 74% |
| rename from remoting/host/win/message_window.cc |
| rename to base/win/message_window.cc |
| index f0426f1c28e1ecbbca9e3af80726ab867624cd87..3b64326d390317a9966a0d01749aea1f94aacaea 100644 |
| --- a/remoting/host/win/message_window.cc |
| +++ b/base/win/message_window.cc |
| @@ -2,46 +2,33 @@ |
| // 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" |
| +#include "base/string16.h" |
| #include "base/strings/stringprintf.h" |
| -#include "base/strings/utf_string_conversions.h" |
| #include "base/win/wrapped_window_proc.h" |
| -const char kClassNameFormat[] = "Chromoting_MessageWindow_%p"; |
| +const wchar_t kClassNameFormat[] = L"Chrome_MessageWindow_%p"; |
|
cpu_(ooo_6.6-7.5)
2013/06/14 22:49:32
const string16
Sergey Ulanov
2013/06/14 22:53:06
Wouldn't that introduce static intializer/finializ
alexeypa (please no reviews)
2013/06/17 18:09:25
Global constants are required to be POD types.
cpu_(ooo_6.6-7.5)
2013/06/18 23:59:58
yeah my bad.
|
| -namespace remoting { |
| +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(const std::string& class_name, HINSTANCE instance) |
| - : atom_(0), |
| - class_name_(class_name), |
| - instance_(instance), |
| window_(NULL) { |
| } |
| MessageWindow::~MessageWindow() { |
| DCHECK(CalledOnValidThread()); |
| - if (window_ != NULL) { |
| + if (window_ != NULL) |
| DestroyWindow(window_); |
| - window_ = NULL; |
| - } |
| if (atom_ != 0) { |
| - UnregisterClass(MAKEINTATOM(atom_), instance_); |
| - atom_ = 0; |
| + UnregisterClass(MAKEINTATOM(atom_), |
|
cpu_(ooo_6.6-7.5)
2013/06/14 22:49:32
in many files we use :: for windows calls, so here
alexeypa (please no reviews)
2013/06/17 18:09:25
I prefer to avoid using explicit scope.
This poin
cpu_(ooo_6.6-7.5)
2013/06/18 23:59:58
It was all based on personal taste. I think that l
|
| + base::GetModuleFromAddress(&MessageWindow::WindowProc)); |
| } |
| } |
| @@ -51,14 +38,16 @@ bool MessageWindow::Create(Delegate* delegate) { |
| DCHECK(!window_); |
| // Register a separate window class for each instance of |MessageWindow|. |
| - string16 class_name = UTF8ToUTF16(class_name_); |
| + string16 class_name = base::StringPrintf(kClassNameFormat, this); |
|
cpu_(ooo_6.6-7.5)
2013/06/14 22:49:32
so one of the main uses is for example in our proc
alexeypa (please no reviews)
2013/06/17 18:09:25
I was going to update MessageWindow at some point
cpu_(ooo_6.6-7.5)
2013/06/18 23:59:58
I don't see how lazy class registration solves the
alexeypa (please no reviews)
2013/06/19 00:04:57
With lazy initialization there will be a single wi
|
| + HINSTANCE instance = base::GetModuleFromAddress(&MessageWindow::WindowProc); |
| + |
| 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.hInstance = instance; |
| window_class.hIcon = NULL; |
| window_class.hCursor = NULL; |
| window_class.hbrBackground = NULL; |
| @@ -68,12 +57,12 @@ bool MessageWindow::Create(Delegate* delegate) { |
| atom_ = RegisterClassEx(&window_class); |
| if (atom_ == 0) { |
| LOG_GETLASTERROR(ERROR) |
| - << "Failed to register the window class '" << class_name_ << "'"; |
| + << "Failed to register the window class for a message-only window"; |
| return false; |
| } |
| window_ = CreateWindow(MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, |
| - instance_, delegate); |
| + instance, delegate); |
| if (!window_) { |
| LOG_GETLASTERROR(ERROR) << "Failed to create a message-only window"; |
| return false; |
| @@ -115,4 +104,4 @@ LRESULT CALLBACK MessageWindow::WindowProc(HWND hwnd, |
| } |
| } // namespace win |
| -} // namespace remoting |
| +} // namespace base |