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

Side by Side Diff: base/win/message_window.cc

Issue 2824533002: Migrate Bind to BindOnce or BindRepeating in //base/message_loop (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « base/win/message_window.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/message_window.h" 5 #include "base/win/message_window.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/win/current_module.h" 10 #include "base/win/current_module.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 MessageWindow::~MessageWindow() { 75 MessageWindow::~MessageWindow() {
76 DCHECK(CalledOnValidThread()); 76 DCHECK(CalledOnValidThread());
77 77
78 if (window_ != NULL) { 78 if (window_ != NULL) {
79 BOOL result = DestroyWindow(window_); 79 BOOL result = DestroyWindow(window_);
80 DCHECK(result); 80 DCHECK(result);
81 } 81 }
82 } 82 }
83 83
84 bool MessageWindow::Create(const MessageCallback& message_callback) { 84 bool MessageWindow::Create(MessageCallback message_callback) {
85 return DoCreate(message_callback, NULL); 85 return DoCreate(std::move(message_callback), NULL);
dcheng 2017/04/17 17:59:30 Actually, I do have one question here: this avoid
tzik 2017/04/18 05:20:29 I believe the pass-by-value of Callback is lightwe
86 } 86 }
87 87
88 bool MessageWindow::CreateNamed(const MessageCallback& message_callback, 88 bool MessageWindow::CreateNamed(MessageCallback message_callback,
89 const string16& window_name) { 89 const string16& window_name) {
90 return DoCreate(message_callback, window_name.c_str()); 90 return DoCreate(std::move(message_callback), window_name.c_str());
91 } 91 }
92 92
93 // static 93 // static
94 HWND MessageWindow::FindWindow(const string16& window_name) { 94 HWND MessageWindow::FindWindow(const string16& window_name) {
95 return FindWindowEx(HWND_MESSAGE, NULL, kMessageWindowClassName, 95 return FindWindowEx(HWND_MESSAGE, NULL, kMessageWindowClassName,
96 window_name.c_str()); 96 window_name.c_str());
97 } 97 }
98 98
99 bool MessageWindow::DoCreate(const MessageCallback& message_callback, 99 bool MessageWindow::DoCreate(MessageCallback message_callback,
100 const wchar_t* window_name) { 100 const wchar_t* window_name) {
101 DCHECK(CalledOnValidThread()); 101 DCHECK(CalledOnValidThread());
102 DCHECK(message_callback_.is_null()); 102 DCHECK(message_callback_.is_null());
103 DCHECK(!window_); 103 DCHECK(!window_);
104 104
105 message_callback_ = message_callback; 105 message_callback_ = std::move(message_callback);
106 106
107 WindowClass& window_class = g_window_class.Get(); 107 WindowClass& window_class = g_window_class.Get();
108 window_ = CreateWindow(MAKEINTATOM(window_class.atom()), window_name, 0, 0, 0, 108 window_ = CreateWindow(MAKEINTATOM(window_class.atom()), window_name, 0, 0, 0,
109 0, 0, HWND_MESSAGE, 0, window_class.instance(), this); 109 0, 0, HWND_MESSAGE, 0, window_class.instance(), this);
110 if (!window_) { 110 if (!window_) {
111 PLOG(ERROR) << "Failed to create a message-only window"; 111 PLOG(ERROR) << "Failed to create a message-only window";
112 return false; 112 return false;
113 } 113 }
114 114
115 return true; 115 return true;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 LRESULT message_result; 156 LRESULT message_result;
157 if (self->message_callback_.Run(message, wparam, lparam, &message_result)) 157 if (self->message_callback_.Run(message, wparam, lparam, &message_result))
158 return message_result; 158 return message_result;
159 } 159 }
160 160
161 return DefWindowProc(hwnd, message, wparam, lparam); 161 return DefWindowProc(hwnd, message, wparam, lparam);
162 } 162 }
163 163
164 } // namespace win 164 } // namespace win
165 } // namespace base 165 } // namespace base
OLDNEW
« no previous file with comments | « base/win/message_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698