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

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

Issue 11415237: Move many ProcessSingleton methods to "protected" visibility as an upcoming refactoring of ProcessS… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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
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 <shellapi.h> 7 #include <shellapi.h>
8 #include <shobjidl.h> 8 #include <shobjidl.h>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // data while a new chrome is starting up. 359 // data while a new chrome is starting up.
360 if (window_) { 360 if (window_) {
361 ::DestroyWindow(window_); 361 ::DestroyWindow(window_);
362 ::UnregisterClass(chrome::kMessageWindowClass, 362 ::UnregisterClass(chrome::kMessageWindowClass,
363 base::GetModuleFromAddress(&ThunkWndProc)); 363 base::GetModuleFromAddress(&ThunkWndProc));
364 } 364 }
365 if (lock_file_ != INVALID_HANDLE_VALUE) 365 if (lock_file_ != INVALID_HANDLE_VALUE)
366 CloseHandle(lock_file_); 366 CloseHandle(lock_file_);
367 } 367 }
368 368
369 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate(
370 const NotificationCallback& notification_callback) {
371 NotifyResult result = NotifyOtherProcess();
372 if (result != PROCESS_NONE)
373 return result;
374 return Create(notification_callback) ? PROCESS_NONE : PROFILE_IN_USE;
375 }
376
377 void ProcessSingleton::Cleanup() {
378 }
379
369 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { 380 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
370 if (is_virtualized_) 381 if (is_virtualized_)
371 return PROCESS_NOTIFIED; // We already spawned the process in this case. 382 return PROCESS_NOTIFIED; // We already spawned the process in this case.
372 if (lock_file_ == INVALID_HANDLE_VALUE && !remote_window_) { 383 if (lock_file_ == INVALID_HANDLE_VALUE && !remote_window_) {
373 return LOCK_ERROR; 384 return LOCK_ERROR;
374 } else if (!remote_window_) { 385 } else if (!remote_window_) {
375 g_browser_process->PlatformSpecificCommandLineProcessing( 386 g_browser_process->PlatformSpecificCommandLineProcessing(
376 *CommandLine::ForCurrentProcess()); 387 *CommandLine::ForCurrentProcess());
377 return PROCESS_NONE; 388 return PROCESS_NONE;
378 } 389 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // The user denied. Quit silently. 483 // The user denied. Quit silently.
473 return PROCESS_NOTIFIED; 484 return PROCESS_NOTIFIED;
474 } 485 }
475 486
476 // Time to take action. Kill the browser process. 487 // Time to take action. Kill the browser process.
477 base::KillProcessById(process_id, content::RESULT_CODE_HUNG, true); 488 base::KillProcessById(process_id, content::RESULT_CODE_HUNG, true);
478 remote_window_ = NULL; 489 remote_window_ = NULL;
479 return PROCESS_NONE; 490 return PROCESS_NONE;
480 } 491 }
481 492
482 ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate(
483 const NotificationCallback& notification_callback) {
484 NotifyResult result = NotifyOtherProcess();
485 if (result != PROCESS_NONE)
486 return result;
487 return Create(notification_callback) ? PROCESS_NONE : PROFILE_IN_USE;
488 }
489
490 // On Windows, there is no need to call Create() since the message 493 // On Windows, there is no need to call Create() since the message
491 // window is created in the constructor but to avoid having more 494 // window is created in the constructor but to avoid having more
492 // platform specific code in browser_main.cc we tolerate calls to 495 // platform specific code in browser_main.cc we tolerate calls to
493 // Create(). 496 // Create().
494 bool ProcessSingleton::Create( 497 bool ProcessSingleton::Create(
495 const NotificationCallback& notification_callback) { 498 const NotificationCallback& notification_callback) {
496 DCHECK(!remote_window_); 499 DCHECK(!remote_window_);
497 DCHECK(notification_callback_.is_null()); 500 DCHECK(notification_callback_.is_null());
498 501
499 if (window_ != NULL) 502 if (window_ != NULL)
500 notification_callback_ = notification_callback; 503 notification_callback_ = notification_callback;
501 504
502 return window_ != NULL; 505 return window_ != NULL;
503 } 506 }
504 507
505 void ProcessSingleton::Cleanup() {
506 }
507
508 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { 508 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
509 // If locked, it means we are not ready to process this message because 509 // If locked, it means we are not ready to process this message because
510 // we are probably in a first run critical phase. 510 // we are probably in a first run critical phase.
511 if (locked_) { 511 if (locked_) {
512 #if defined(USE_AURA) 512 #if defined(USE_AURA)
513 NOTIMPLEMENTED(); 513 NOTIMPLEMENTED();
514 #else 514 #else
515 // Attempt to place ourselves in the foreground / flash the task bar. 515 // Attempt to place ourselves in the foreground / flash the task bar.
516 if (foreground_window_ != NULL && IsWindow(foreground_window_)) { 516 if (foreground_window_ != NULL && IsWindow(foreground_window_)) {
517 SetForegroundWindow(foreground_window_); 517 SetForegroundWindow(foreground_window_);
(...skipping 23 matching lines...) Expand all
541 switch (message) { 541 switch (message) {
542 case WM_COPYDATA: 542 case WM_COPYDATA:
543 return OnCopyData(reinterpret_cast<HWND>(wparam), 543 return OnCopyData(reinterpret_cast<HWND>(wparam),
544 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 544 reinterpret_cast<COPYDATASTRUCT*>(lparam));
545 default: 545 default:
546 break; 546 break;
547 } 547 }
548 548
549 return ::DefWindowProc(hwnd, message, wparam, lparam); 549 return ::DefWindowProc(hwnd, message, wparam, lparam);
550 } 550 }
OLDNEW
« chrome/browser/process_singleton_linux_unittest.cc ('K') | « chrome/browser/process_singleton_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698