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

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

Issue 10557040: Merge 142682 - Move the window destruction and registration out of cleanup and into BrowserProcessI… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1132/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 }
203 } 210 }
204 211
205 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { 212 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
206 if (is_virtualized_) 213 if (is_virtualized_)
207 return PROCESS_NOTIFIED; // We already spawned the process in this case. 214 return PROCESS_NOTIFIED; // We already spawned the process in this case.
208 else if (!remote_window_) 215 else if (!remote_window_)
209 return PROCESS_NONE; 216 return PROCESS_NONE;
210 217
211 // Found another window, send our command line to it 218 // Found another window, send our command line to it
212 // format is "START\0<<<current directory>>>\0<<<commandline>>>". 219 // format is "START\0<<<current directory>>>\0<<<commandline>>>".
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 DCHECK(!remote_window_); 304 DCHECK(!remote_window_);
298 DCHECK(notification_callback_.is_null()); 305 DCHECK(notification_callback_.is_null());
299 306
300 if (window_ != NULL) 307 if (window_ != NULL)
301 notification_callback_ = notification_callback; 308 notification_callback_ = notification_callback;
302 309
303 return window_ != NULL; 310 return window_ != NULL;
304 } 311 }
305 312
306 void ProcessSingleton::Cleanup() { 313 void ProcessSingleton::Cleanup() {
307 // Window classes registered by DLLs are not cleaned up automatically on
308 // process exit, so we must unregister at the earliest chance possible.
309 // During the fast shutdown sequence, ProcessSingleton::Cleanup() is
310 // called if our process was the first to start. Therefore we try cleaning
311 // up here, and again in the destructor if needed to catch as many cases
312 // as possible.
313 if (window_) {
314 ::DestroyWindow(window_);
315 ::UnregisterClass(chrome::kMessageWindowClass,
316 base::GetModuleFromAddress(&ThunkWndProc));
317 window_ = NULL;
318 }
319 } 314 }
320 315
321 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { 316 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
322 // If locked, it means we are not ready to process this message because 317 // If locked, it means we are not ready to process this message because
323 // we are probably in a first run critical phase. 318 // we are probably in a first run critical phase.
324 if (locked_) { 319 if (locked_) {
325 #if defined(USE_AURA) 320 #if defined(USE_AURA)
326 NOTIMPLEMENTED(); 321 NOTIMPLEMENTED();
327 #else 322 #else
328 // Attempt to place ourselves in the foreground / flash the task bar. 323 // Attempt to place ourselves in the foreground / flash the task bar.
(...skipping 25 matching lines...) Expand all
354 switch (message) { 349 switch (message) {
355 case WM_COPYDATA: 350 case WM_COPYDATA:
356 return OnCopyData(reinterpret_cast<HWND>(wparam), 351 return OnCopyData(reinterpret_cast<HWND>(wparam),
357 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 352 reinterpret_cast<COPYDATASTRUCT*>(lparam));
358 default: 353 default:
359 break; 354 break;
360 } 355 }
361 356
362 return ::DefWindowProc(hwnd, message, wparam, lparam); 357 return ::DefWindowProc(hwnd, message, wparam, lparam);
363 } 358 }
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