Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 | 277 |
| 278 // Time to take action. Kill the browser process. | 278 // Time to take action. Kill the browser process. |
| 279 process.Terminate(content::RESULT_CODE_HUNG, true); | 279 process.Terminate(content::RESULT_CODE_HUNG, true); |
| 280 remote_window_ = NULL; | 280 remote_window_ = NULL; |
| 281 return PROCESS_NONE; | 281 return PROCESS_NONE; |
| 282 } | 282 } |
| 283 | 283 |
| 284 ProcessSingleton::NotifyResult | 284 ProcessSingleton::NotifyResult |
| 285 ProcessSingleton::NotifyOtherProcessOrCreate() { | 285 ProcessSingleton::NotifyOtherProcessOrCreate() { |
| 286 ProcessSingleton::NotifyResult result = PROCESS_NONE; | 286 ProcessSingleton::NotifyResult result = PROCESS_NONE; |
| 287 if (!Create()) { | 287 // While the remote window is not functional, attept to create |
| 288 // the Singleton. | |
| 289 while (result == PROCESS_NONE && !Create()) { | |
| 290 // Process attepts to notify the existing remote window. If the | |
| 291 // remote window is fund to be hung, the user is notified and | |
| 292 // asked to confirm the termination of the hung window. | |
| 288 result = NotifyOtherProcess(); | 293 result = NotifyOtherProcess(); |
|
grt (UTC plus 2)
2016/08/24 10:01:26
this will return PROCESS_NONE if AttemptToNotifyRu
gcomanici
2016/08/25 19:26:07
The new patch now runs this for the case when the
| |
| 289 if (result == PROCESS_NONE) | |
| 290 result = PROFILE_IN_USE; | |
| 291 } else { | |
| 292 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( | |
| 293 *base::CommandLine::ForCurrentProcess()); | |
| 294 } | 294 } |
| 295 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( | |
|
grt (UTC plus 2)
2016/08/24 10:01:26
this must only happen when Create() returns true
gcomanici
2016/08/25 19:26:07
Done.
| |
| 296 *base::CommandLine::ForCurrentProcess()); | |
| 295 return result; | 297 return result; |
| 296 } | 298 } |
| 297 | 299 |
| 298 // Look for a Chrome instance that uses the same profile directory. If there | 300 // Look for a Chrome instance that uses the same profile directory. If there |
| 299 // isn't one, create a message window with its title set to the profile | 301 // isn't one, create a message window with its title set to the profile |
| 300 // directory path. | 302 // directory path. |
| 301 bool ProcessSingleton::Create() { | 303 bool ProcessSingleton::Create() { |
| 302 static const wchar_t kMutexName[] = L"Local\\ChromeProcessSingletonStartup!"; | 304 static const wchar_t kMutexName[] = L"Local\\ChromeProcessSingletonStartup!"; |
| 303 | 305 |
| 304 remote_window_ = chrome::FindRunningChromeWindow(user_data_dir_); | 306 remote_window_ = chrome::FindRunningChromeWindow(user_data_dir_); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 return window_.hwnd() != NULL; | 356 return window_.hwnd() != NULL; |
| 355 } | 357 } |
| 356 | 358 |
| 357 void ProcessSingleton::Cleanup() { | 359 void ProcessSingleton::Cleanup() { |
| 358 } | 360 } |
| 359 | 361 |
| 360 void ProcessSingleton::OverrideShouldKillRemoteProcessCallbackForTesting( | 362 void ProcessSingleton::OverrideShouldKillRemoteProcessCallbackForTesting( |
| 361 const ShouldKillRemoteProcessCallback& display_dialog_callback) { | 363 const ShouldKillRemoteProcessCallback& display_dialog_callback) { |
| 362 should_kill_remote_process_callback_ = display_dialog_callback; | 364 should_kill_remote_process_callback_ = display_dialog_callback; |
| 363 } | 365 } |
| OLD | NEW |