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

Side by Side Diff: chrome/browser/lifetime/application_lifetime.cc

Issue 349263004: Fix Windows logoff race. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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/lifetime/application_lifetime.h" 5 #include "chrome/browser/lifetime/application_lifetime.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/process/kill.h"
16 #include "base/process/process.h"
15 #include "build/build_config.h" 17 #include "build/build_config.h"
16 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/browser_process_platform_part.h" 19 #include "chrome/browser/browser_process_platform_part.h"
18 #include "chrome/browser/browser_shutdown.h" 20 #include "chrome/browser/browser_shutdown.h"
19 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/download/download_service.h" 22 #include "chrome/browser/download/download_service.h"
21 #include "chrome/browser/lifetime/browser_close_manager.h" 23 #include "chrome/browser/lifetime/browser_close_manager.h"
22 #include "chrome/browser/metrics/thread_watcher.h" 24 #include "chrome/browser/metrics/thread_watcher.h"
23 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); 271 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION);
270 272
271 content::NotificationService::current()->Notify( 273 content::NotificationService::current()->Notify(
272 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, 274 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
273 content::NotificationService::AllSources(), 275 content::NotificationService::AllSources(),
274 content::NotificationService::NoDetails()); 276 content::NotificationService::NoDetails());
275 277
276 // Write important data first. 278 // Write important data first.
277 g_browser_process->EndSession(); 279 g_browser_process->EndSession();
278 280
281 #if defined(OS_WIN)
282 // On Windows 7 and later, the system will consider the process ripe for
283 // termination as soon as it hides or destroys its windows. Since any
284 // execution past that point will be non-deterministically cut short, we
285 // might as well put ourselves out of that misery deterministically.
286 base::KillProcess(base::Process::Current().handle(), 0, false);
erikwright (departed) 2014/06/23 19:59:00 Is it not potentially better to use the same logic
Sigurður Ásgeirsson 2014/06/23 20:20:12 I don't know that it is - this is fulfilling a dra
287 #else
279 CloseAllBrowsers(); 288 CloseAllBrowsers();
280 289
281 // Send out notification. This is used during testing so that the test harness 290 // Send out notification. This is used during testing so that the test harness
282 // can properly shutdown before we exit. 291 // can properly shutdown before we exit.
283 content::NotificationService::current()->Notify( 292 content::NotificationService::current()->Notify(
284 chrome::NOTIFICATION_SESSION_END, 293 chrome::NOTIFICATION_SESSION_END,
285 content::NotificationService::AllSources(), 294 content::NotificationService::AllSources(),
286 content::NotificationService::NoDetails()); 295 content::NotificationService::NoDetails());
287 296
288 #if defined(OS_WIN) 297 #if defined(OS_WIN)
289 base::win::SetShouldCrashOnProcessDetach(false); 298 base::win::SetShouldCrashOnProcessDetach(false);
gab 2014/06/23 19:53:48 This code is now unreachable.
Sigurður Ásgeirsson 2014/06/23 20:20:12 Done.
290 #endif 299 #endif
291 // This will end by terminating the process. 300 // This will end by terminating the process.
292 content::ImmediateShutdownAndExitProcess(); 301 content::ImmediateShutdownAndExitProcess();
302 #endif // defined(OS_WIN)
293 } 303 }
294 304
295 void IncrementKeepAliveCount() { 305 void IncrementKeepAliveCount() {
296 // Increment the browser process refcount as long as we're keeping the 306 // Increment the browser process refcount as long as we're keeping the
297 // application alive. 307 // application alive.
298 if (!WillKeepAlive()) 308 if (!WillKeepAlive())
299 g_browser_process->AddRefModule(); 309 g_browser_process->AddRefModule();
300 ++g_keep_alive_count; 310 ++g_keep_alive_count;
301 } 311 }
302 312
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // environment is still active. 407 // environment is still active.
398 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) 408 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE)
399 return !ash::Shell::HasInstance(); 409 return !ash::Shell::HasInstance();
400 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) 410 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH)
401 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); 411 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty();
402 #endif 412 #endif
403 return true; 413 return true;
404 } 414 }
405 415
406 } // namespace chrome 416 } // namespace chrome
OLDNEW
« chrome/browser/browser_process_impl.cc ('K') | « chrome/browser/browser_process_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698