Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3494)

Unified Diff: base/win/message_window.cc

Issue 2667513003: Remove some LazyInstance use in base/ (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/win/message_window.cc
diff --git a/base/win/message_window.cc b/base/win/message_window.cc
index 26b64a533887e0e619d7b50a4d36f2de69d6303e..186377b5ae41e4925f203f128ce9b6bcfb3e9b48 100644
--- a/base/win/message_window.cc
+++ b/base/win/message_window.cc
@@ -4,7 +4,6 @@
#include "base/win/message_window.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/win/current_module.h"
@@ -15,8 +14,8 @@ const wchar_t kMessageWindowClassName[] = L"Chrome_MessageWindow";
namespace base {
namespace win {
-// Used along with LazyInstance to register a window class for message-only
-// windows created by MessageWindow.
+// Used along with a threadsafe static pointer to register a window class for
+// message-only windows created by MessageWindow.
class MessageWindow::WindowClass {
public:
WindowClass();
@@ -32,9 +31,6 @@ class MessageWindow::WindowClass {
DISALLOW_COPY_AND_ASSIGN(WindowClass);
};
-static LazyInstance<MessageWindow::WindowClass> g_window_class =
Mark Mentovai 2017/01/31 14:37:01 This wasn’t leaky, and WindowClass has a destructo
scottmg 2017/01/31 18:19:16 For general process shutdown, there's little point
- LAZY_INSTANCE_INITIALIZER;
-
MessageWindow::WindowClass::WindowClass()
: atom_(0), instance_(CURRENT_MODULE()) {
WNDCLASSEX window_class;
@@ -104,9 +100,10 @@ bool MessageWindow::DoCreate(const MessageCallback& message_callback,
message_callback_ = message_callback;
- WindowClass& window_class = g_window_class.Get();
- window_ = CreateWindow(MAKEINTATOM(window_class.atom()), window_name, 0, 0, 0,
- 0, 0, HWND_MESSAGE, 0, window_class.instance(), this);
+ static auto window_class = new WindowClass();
+ window_ =
+ CreateWindow(MAKEINTATOM(window_class->atom()), window_name, 0, 0, 0, 0,
+ 0, HWND_MESSAGE, 0, window_class->instance(), this);
if (!window_) {
PLOG(ERROR) << "Failed to create a message-only window";
return false;

Powered by Google App Engine
This is Rietveld 408576698