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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 | 271 |
272 // If there is a visible browser window, ask the user before killing it. | 272 // If there is a visible browser window, ask the user before killing it. |
273 if (visible_window && !should_kill_remote_process_callback_.Run()) { | 273 if (visible_window && !should_kill_remote_process_callback_.Run()) { |
274 // The user denied. Quit silently. | 274 // The user denied. Quit silently. |
275 return PROCESS_NOTIFIED; | 275 return PROCESS_NOTIFIED; |
276 } | 276 } |
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 // GCOMANICI return PROCESS_HUNG; |
282 return PROCESS_HUNG; | |
282 } | 283 } |
283 | 284 |
284 ProcessSingleton::NotifyResult | 285 ProcessSingleton::NotifyResult |
285 ProcessSingleton::NotifyOtherProcessOrCreate() { | 286 ProcessSingleton::NotifyOtherProcessOrCreate() { |
286 ProcessSingleton::NotifyResult result = PROCESS_NONE; | 287 ProcessSingleton::NotifyResult result = PROCESS_NONE; |
287 if (!Create()) { | 288 if (!Create()) { |
288 result = NotifyOtherProcess(); | 289 result = NotifyOtherProcess(); |
290 if (result == PROCESS_HUNG) { | |
291 // The Chrome instance that usses the main profile directory was | |
292 // detected to be hung and the user confirmed its termination. | |
293 // Current process should have a secont attempt to create the profile | |
294 if (!Create()) { | |
grt (UTC plus 2)
2016/08/26 09:26:43
nit: omit braces for conditionals where the condit
gcomanici
2016/08/26 17:26:59
Acknowledged.
| |
295 result = NotifyOtherProcess(); | |
grt (UTC plus 2)
2016/08/26 09:26:43
instead of duplicating the calls to create and not
gcomanici
2016/08/26 17:26:59
Done.
| |
296 } | |
297 } | |
289 if (result == PROCESS_NONE) | 298 if (result == PROCESS_NONE) |
290 result = PROFILE_IN_USE; | 299 result = PROFILE_IN_USE; |
291 } else { | 300 if (result == PROCESS_HUNG) { |
301 // This only happens if the second attempt at Create() was succesful. | |
302 result = PROCESS_NONE; | |
303 } | |
304 } | |
305 if (result == PROCESS_NONE) { | |
292 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( | 306 g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing( |
grt (UTC plus 2)
2016/08/26 09:26:43
looking at the design in here a bit more, it seems
gcomanici
2016/08/26 17:26:59
The new patch has this call in chrome_browser_main
| |
293 *base::CommandLine::ForCurrentProcess()); | 307 *base::CommandLine::ForCurrentProcess()); |
294 } | 308 } |
295 return result; | 309 return result; |
296 } | 310 } |
297 | 311 |
298 // Look for a Chrome instance that uses the same profile directory. If there | 312 // 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 | 313 // isn't one, create a message window with its title set to the profile |
300 // directory path. | 314 // directory path. |
301 bool ProcessSingleton::Create() { | 315 bool ProcessSingleton::Create() { |
302 static const wchar_t kMutexName[] = L"Local\\ChromeProcessSingletonStartup!"; | 316 static const wchar_t kMutexName[] = L"Local\\ChromeProcessSingletonStartup!"; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 return window_.hwnd() != NULL; | 368 return window_.hwnd() != NULL; |
355 } | 369 } |
356 | 370 |
357 void ProcessSingleton::Cleanup() { | 371 void ProcessSingleton::Cleanup() { |
358 } | 372 } |
359 | 373 |
360 void ProcessSingleton::OverrideShouldKillRemoteProcessCallbackForTesting( | 374 void ProcessSingleton::OverrideShouldKillRemoteProcessCallbackForTesting( |
361 const ShouldKillRemoteProcessCallback& display_dialog_callback) { | 375 const ShouldKillRemoteProcessCallback& display_dialog_callback) { |
362 should_kill_remote_process_callback_ = display_dialog_callback; | 376 should_kill_remote_process_callback_ = display_dialog_callback; |
363 } | 377 } |
OLD | NEW |