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

Side by Side Diff: chrome/browser/process_singleton_win.cc

Issue 10542151: Move the window destruction and registration out of cleanup and into BrowserProcessImpl::EndSession… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/process_singleton.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/process_singleton.h" 5 #include "chrome/browser/process_singleton.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 user_data_dir.value().c_str(), 192 user_data_dir.value().c_str(),
193 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, this); 193 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, this);
194 CHECK(window_); 194 CHECK(window_);
195 } 195 }
196 BOOL success = ReleaseMutex(only_me); 196 BOOL success = ReleaseMutex(only_me);
197 DCHECK(success) << "GetLastError = " << GetLastError(); 197 DCHECK(success) << "GetLastError = " << GetLastError();
198 } 198 }
199 } 199 }
200 200
201 ProcessSingleton::~ProcessSingleton() { 201 ProcessSingleton::~ProcessSingleton() {
202 Cleanup(); 202 Cleanup();
Jói 2012/06/15 10:04:57 nit: since Cleanup() is a no-op now, you could rem
203 // Make sure we unregister the window class during normal shutdown as well.
204 UnregisterWindowClass();
203 } 205 }
204 206
205 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { 207 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
206 if (is_virtualized_) 208 if (is_virtualized_)
207 return PROCESS_NOTIFIED; // We already spawned the process in this case. 209 return PROCESS_NOTIFIED; // We already spawned the process in this case.
208 else if (!remote_window_) 210 else if (!remote_window_)
209 return PROCESS_NONE; 211 return PROCESS_NONE;
210 212
211 // Found another window, send our command line to it 213 // Found another window, send our command line to it
212 // format is "START\0<<<current directory>>>\0<<<commandline>>>". 214 // format is "START\0<<<current directory>>>\0<<<commandline>>>".
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 DCHECK(!remote_window_); 297 DCHECK(!remote_window_);
296 DCHECK(notification_callback_.is_null()); 298 DCHECK(notification_callback_.is_null());
297 299
298 if (window_ != NULL) 300 if (window_ != NULL)
299 notification_callback_ = notification_callback; 301 notification_callback_ = notification_callback;
300 302
301 return window_ != NULL; 303 return window_ != NULL;
302 } 304 }
303 305
304 void ProcessSingleton::Cleanup() { 306 void ProcessSingleton::Cleanup() {
307 }
308
309 void ProcessSingleton::UnregisterWindowClass() {
305 // Window classes registered by DLLs are not cleaned up automatically on 310 // Window classes registered by DLLs are not cleaned up automatically on
306 // process exit, so we must unregister at the earliest chance possible. 311 // process exit, so we must unregister at the earliest chance possible.
307 // During the fast shutdown sequence, ProcessSingleton::Cleanup() is
308 // called if our process was the first to start. Therefore we try cleaning
309 // up here, and again in the destructor if needed to catch as many cases
310 // as possible.
311 if (window_) { 312 if (window_) {
312 ::DestroyWindow(window_); 313 ::DestroyWindow(window_);
313 ::UnregisterClass(chrome::kMessageWindowClass, 314 ::UnregisterClass(chrome::kMessageWindowClass,
314 base::GetModuleFromAddress(&ThunkWndProc)); 315 base::GetModuleFromAddress(&ThunkWndProc));
315 window_ = NULL; 316 window_ = NULL;
316 } 317 }
317 } 318 }
318 319
319 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { 320 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
320 // If locked, it means we are not ready to process this message because 321 // If locked, it means we are not ready to process this message because
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 switch (message) { 353 switch (message) {
353 case WM_COPYDATA: 354 case WM_COPYDATA:
354 return OnCopyData(reinterpret_cast<HWND>(wparam), 355 return OnCopyData(reinterpret_cast<HWND>(wparam),
355 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 356 reinterpret_cast<COPYDATASTRUCT*>(lparam));
356 default: 357 default:
357 break; 358 break;
358 } 359 }
359 360
360 return ::DefWindowProc(hwnd, message, wparam, lparam); 361 return ::DefWindowProc(hwnd, message, wparam, lparam);
361 } 362 }
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698