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

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

Issue 12096114: Extract locking behaviour from ProcessSingleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed merge. Created 7 years, 9 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
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 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 ::Sleep(10); 248 ::Sleep(10);
249 } 249 }
250 return true; 250 return true;
251 } 251 }
252 return false; 252 return false;
253 } 253 }
254 254
255 ProcessSingleton::ProcessSingleton( 255 ProcessSingleton::ProcessSingleton(
256 const base::FilePath& user_data_dir, 256 const base::FilePath& user_data_dir,
257 const NotificationCallback& notification_callback) 257 const NotificationCallback& notification_callback)
258 : window_(NULL), locked_(false), foreground_window_(NULL), 258 : window_(NULL), notification_callback_(notification_callback),
259 notification_callback_(notification_callback),
260 is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE), 259 is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE),
261 user_data_dir_(user_data_dir) { 260 user_data_dir_(user_data_dir) {
262 } 261 }
263 262
264 ProcessSingleton::~ProcessSingleton() { 263 ProcessSingleton::~ProcessSingleton() {
265 // We need to unregister the window as late as possible so that we can detect 264 // We need to unregister the window as late as possible so that we can detect
266 // another instance of chrome running. Otherwise we may end up writing out 265 // another instance of chrome running. Otherwise we may end up writing out
267 // data while a new chrome is starting up. 266 // data while a new chrome is starting up.
268 if (window_) { 267 if (window_) {
269 ::DestroyWindow(window_); 268 ::DestroyWindow(window_);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 529 }
531 } 530 }
532 531
533 return window_ != NULL; 532 return window_ != NULL;
534 } 533 }
535 534
536 void ProcessSingleton::Cleanup() { 535 void ProcessSingleton::Cleanup() {
537 } 536 }
538 537
539 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { 538 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
540 // If locked, it means we are not ready to process this message because
541 // we are probably in a first run critical phase.
542 if (locked_) {
543 #if defined(USE_AURA)
544 NOTIMPLEMENTED();
545 #else
546 // Attempt to place ourselves in the foreground / flash the task bar.
547 if (foreground_window_ != NULL && IsWindow(foreground_window_)) {
548 SetForegroundWindow(foreground_window_);
robertshield 2013/03/27 14:51:38 This is at least a small change in behaviour in th
erikwright (departed) 2013/03/28 03:16:34 Done.
549 } else {
550 // Read the command line and store it. It will be replayed when the
551 // ProcessSingleton becomes unlocked.
552 CommandLine parsed_command_line(CommandLine::NO_PROGRAM);
553 base::FilePath current_directory;
554 if (ParseCommandLine(cds, &parsed_command_line, &current_directory))
555 saved_startup_messages_.push_back(
556 std::make_pair(parsed_command_line.argv(), current_directory));
557 }
558 #endif
559 return TRUE;
560 }
561
562 CommandLine parsed_command_line(CommandLine::NO_PROGRAM); 539 CommandLine parsed_command_line(CommandLine::NO_PROGRAM);
563 base::FilePath current_directory; 540 base::FilePath current_directory;
564 if (!ParseCommandLine(cds, &parsed_command_line, &current_directory)) 541 if (!ParseCommandLine(cds, &parsed_command_line, &current_directory))
565 return TRUE; 542 return TRUE;
566 return notification_callback_.Run(parsed_command_line, current_directory) ? 543 return notification_callback_.Run(parsed_command_line, current_directory) ?
567 TRUE : FALSE; 544 TRUE : FALSE;
568 } 545 }
569 546
570 LRESULT ProcessSingleton::WndProc(HWND hwnd, UINT message, 547 LRESULT ProcessSingleton::WndProc(HWND hwnd, UINT message,
571 WPARAM wparam, LPARAM lparam) { 548 WPARAM wparam, LPARAM lparam) {
572 switch (message) { 549 switch (message) {
573 case WM_COPYDATA: 550 case WM_COPYDATA:
574 return OnCopyData(reinterpret_cast<HWND>(wparam), 551 return OnCopyData(reinterpret_cast<HWND>(wparam),
575 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 552 reinterpret_cast<COPYDATASTRUCT*>(lparam));
576 default: 553 default:
577 break; 554 break;
578 } 555 }
579 556
580 return ::DefWindowProc(hwnd, message, wparam, lparam); 557 return ::DefWindowProc(hwnd, message, wparam, lparam);
581 } 558 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698