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

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: Also make a file-local function conditionally compiled with its sole user. Created 6 years, 5 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
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/profiles/profile_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 base::win::SetShouldCrashOnProcessDetach(false);
283
284 // On Windows 7 and later, the system will consider the process ripe for
285 // termination as soon as it hides or destroys its windows. Since any
286 // execution past that point will be non-deterministically cut short, we
287 // might as well put ourselves out of that misery deterministically.
288 base::KillProcess(base::Process::Current().handle(), 0, false);
289 #else
279 CloseAllBrowsers(); 290 CloseAllBrowsers();
280 291
281 // Send out notification. This is used during testing so that the test harness 292 // Send out notification. This is used during testing so that the test harness
282 // can properly shutdown before we exit. 293 // can properly shutdown before we exit.
283 content::NotificationService::current()->Notify( 294 content::NotificationService::current()->Notify(
284 chrome::NOTIFICATION_SESSION_END, 295 chrome::NOTIFICATION_SESSION_END,
285 content::NotificationService::AllSources(), 296 content::NotificationService::AllSources(),
286 content::NotificationService::NoDetails()); 297 content::NotificationService::NoDetails());
287 298
288 #if defined(OS_WIN)
289 base::win::SetShouldCrashOnProcessDetach(false);
290 #endif
291 // This will end by terminating the process. 299 // This will end by terminating the process.
292 content::ImmediateShutdownAndExitProcess(); 300 content::ImmediateShutdownAndExitProcess();
301 #endif // defined(OS_WIN)
293 } 302 }
294 303
295 void IncrementKeepAliveCount() { 304 void IncrementKeepAliveCount() {
296 // Increment the browser process refcount as long as we're keeping the 305 // Increment the browser process refcount as long as we're keeping the
297 // application alive. 306 // application alive.
298 if (!WillKeepAlive()) 307 if (!WillKeepAlive())
299 g_browser_process->AddRefModule(); 308 g_browser_process->AddRefModule();
300 ++g_keep_alive_count; 309 ++g_keep_alive_count;
301 } 310 }
302 311
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // environment is still active. 406 // environment is still active.
398 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) 407 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE)
399 return !ash::Shell::HasInstance(); 408 return !ash::Shell::HasInstance();
400 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) 409 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH)
401 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); 410 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty();
402 #endif 411 #endif
403 return true; 412 return true;
404 } 413 }
405 414
406 } // namespace chrome 415 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/profiles/profile_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698