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

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 | « no previous file | 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 // We need to unregister the window as late as possible so that we can detect
203 // another instance of chrome running. Otherwise we may end up writing out
204 // data while a new chrome is starting up.
205 if (window_) {
206 ::DestroyWindow(window_);
207 ::UnregisterClass(chrome::kMessageWindowClass,
208 base::GetModuleFromAddress(&ThunkWndProc));
209 window_ = NULL;
jam 2012/06/15 21:56:22 nit: this was never needed before, so feel free to
210 }
203 } 211 }
204 212
205 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { 213 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
206 if (is_virtualized_) 214 if (is_virtualized_)
207 return PROCESS_NOTIFIED; // We already spawned the process in this case. 215 return PROCESS_NOTIFIED; // We already spawned the process in this case.
208 else if (!remote_window_) 216 else if (!remote_window_)
209 return PROCESS_NONE; 217 return PROCESS_NONE;
210 218
211 // Found another window, send our command line to it 219 // Found another window, send our command line to it
212 // format is "START\0<<<current directory>>>\0<<<commandline>>>". 220 // format is "START\0<<<current directory>>>\0<<<commandline>>>".
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 DCHECK(!remote_window_); 303 DCHECK(!remote_window_);
296 DCHECK(notification_callback_.is_null()); 304 DCHECK(notification_callback_.is_null());
297 305
298 if (window_ != NULL) 306 if (window_ != NULL)
299 notification_callback_ = notification_callback; 307 notification_callback_ = notification_callback;
300 308
301 return window_ != NULL; 309 return window_ != NULL;
302 } 310 }
303 311
304 void ProcessSingleton::Cleanup() { 312 void ProcessSingleton::Cleanup() {
305 // Window classes registered by DLLs are not cleaned up automatically on
306 // 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 ::DestroyWindow(window_);
313 ::UnregisterClass(chrome::kMessageWindowClass,
314 base::GetModuleFromAddress(&ThunkWndProc));
315 window_ = NULL;
316 }
317 } 313 }
318 314
319 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { 315 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
320 // If locked, it means we are not ready to process this message because 316 // If locked, it means we are not ready to process this message because
321 // we are probably in a first run critical phase. 317 // we are probably in a first run critical phase.
322 if (locked_) { 318 if (locked_) {
323 #if defined(USE_AURA) 319 #if defined(USE_AURA)
324 NOTIMPLEMENTED(); 320 NOTIMPLEMENTED();
325 #else 321 #else
326 // Attempt to place ourselves in the foreground / flash the task bar. 322 // Attempt to place ourselves in the foreground / flash the task bar.
(...skipping 25 matching lines...) Expand all
352 switch (message) { 348 switch (message) {
353 case WM_COPYDATA: 349 case WM_COPYDATA:
354 return OnCopyData(reinterpret_cast<HWND>(wparam), 350 return OnCopyData(reinterpret_cast<HWND>(wparam),
355 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 351 reinterpret_cast<COPYDATASTRUCT*>(lparam));
356 default: 352 default:
357 break; 353 break;
358 } 354 }
359 355
360 return ::DefWindowProc(hwnd, message, wparam, lparam); 356 return ::DefWindowProc(hwnd, message, wparam, lparam);
361 } 357 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698