diff options
author | sky <sky@chromium.org> | 2016-03-25 14:27:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 21:29:56 +0000 |
commit | 0e07a14f1d8515fb5802c03e7c30dfe0bae4a87d (patch) | |
tree | 3a37b27effc69b6f027deec8eac05bf2a772e2e1 | |
parent | 7e3a03855688b46f3abad63dc94093b09e5a6f4b (diff) | |
download | chromium_src-0e07a14f1d8515fb5802c03e7c30dfe0bae4a87d.zip chromium_src-0e07a14f1d8515fb5802c03e7c30dfe0bae4a87d.tar.gz chromium_src-0e07a14f1d8515fb5802c03e7c30dfe0bae4a87d.tar.bz2 |
Move use of ShutdownWatcherHelper after early return
The ShutdownWatcherHelper is only needed if we don't early return,
additionally the early return triggers a DCHECK because
ShutdownWatcherHelper gets destroyed on the UI thread, triggering a
threading assertion because it ends up calling Join().
Also add ScopedAllowIO, in case Terminate fails. If SessionEnding returns we're going to be destroyed by the OS anyway, so we don't really care about any additional IO.
BUG=none
TEST=none
R=jam@chromium.org
Review URL: https://codereview.chromium.org/1839453002
Cr-Commit-Position: refs/heads/master@{#383365}
-rw-r--r-- | PRESUBMIT.py | 1 | ||||
-rw-r--r-- | chrome/browser/lifetime/application_lifetime.cc | 17 |
2 files changed, 12 insertions, 6 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index aee7722..1f257b1 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -168,6 +168,7 @@ _BANNED_CPP_FUNCTIONS = ( r"^base[\\\/]process[\\\/]process_metrics_linux\.cc$", r"^blimp[\\\/]engine[\\\/]app[\\\/]blimp_browser_main_parts\.cc$", r"^chrome[\\\/]browser[\\\/]chromeos[\\\/]boot_times_recorder\.cc$", + r"^chrome[\\\/]browser[\\\/]lifetime[\\\/]application_lifetime\.cc$", r"^chrome[\\\/]browser[\\\/]chromeos[\\\/]" "customization_document_browsertest\.cc$", r"^components[\\\/]crash[\\\/]app[\\\/]breakpad_mac\.mm$", diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc index c734162..8bd06e9 100644 --- a/chrome/browser/lifetime/application_lifetime.cc +++ b/chrome/browser/lifetime/application_lifetime.cc @@ -247,12 +247,6 @@ void SessionEnding() { // disk as we can as soon as we can, and where we must kill the // process within a hang timeout to avoid user prompts. - // Start watching for hang during shutdown, and crash it if takes too long. - // We disarm when |shutdown_watcher| object is destroyed, which is when we - // exit this function. - ShutdownWatcherHelper shutdown_watcher; - shutdown_watcher.Arm(base::TimeDelta::FromSeconds(90)); - // EndSession is invoked once per frame. Only do something the first time. static bool already_ended = false; // We may get called in the middle of shutdown, e.g. http://crbug.com/70852 @@ -261,6 +255,17 @@ void SessionEnding() { return; already_ended = true; + // ~ShutdownWatcherHelper uses IO (it joins a thread). We'll only trigger that + // if Terminate() fails, which leaves us in a weird state, or the OS is going + // to kill us soon. Either way we don't care about that here. + base::ThreadRestrictions::ScopedAllowIO allow_io; + + // Start watching for hang during shutdown, and crash it if takes too long. + // We disarm when |shutdown_watcher| object is destroyed, which is when we + // exit this function. + ShutdownWatcherHelper shutdown_watcher; + shutdown_watcher.Arm(base::TimeDelta::FromSeconds(90)); + browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); content::NotificationService::current()->Notify( |