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

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

Issue 2527373003: Stability execution phase: register shutdown timebomb state in quick exit path (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | 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 <memory> 7 #include <memory>
8 #include <string>
8 9
9 #if defined(OS_WIN) 10 #if defined(OS_WIN)
10 #include <windows.h> 11 #include <windows.h>
11 #endif 12 #endif
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/process/process.h" 17 #include "base/process/process.h"
17 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
(...skipping 11 matching lines...) Expand all
29 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/browser_list.h" 32 #include "chrome/browser/ui/browser_list.h"
32 #include "chrome/browser/ui/browser_tabstrip.h" 33 #include "chrome/browser/ui/browser_tabstrip.h"
33 #include "chrome/browser/ui/browser_window.h" 34 #include "chrome/browser/ui/browser_window.h"
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" 35 #include "chrome/browser/ui/tabs/tab_strip_model.h"
35 #include "chrome/browser/ui/user_manager.h" 36 #include "chrome/browser/ui/user_manager.h"
36 #include "chrome/common/chrome_constants.h" 37 #include "chrome/common/chrome_constants.h"
37 #include "chrome/common/features.h" 38 #include "chrome/common/features.h"
38 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
40 #include "components/metrics/metrics_service.h"
39 #include "components/prefs/pref_service.h" 41 #include "components/prefs/pref_service.h"
40 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/navigation_details.h" 43 #include "content/public/browser/navigation_details.h"
42 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
43 45
44 #if defined(OS_CHROMEOS) 46 #if defined(OS_CHROMEOS)
45 #include "base/sys_info.h" 47 #include "base/sys_info.h"
46 #include "chrome/browser/chromeos/boot_times_recorder.h" 48 #include "chrome/browser/chromeos/boot_times_recorder.h"
47 #include "chromeos/dbus/dbus_thread_manager.h" 49 #include "chromeos/dbus/dbus_thread_manager.h"
48 #include "chromeos/dbus/power_policy_controller.h" 50 #include "chromeos/dbus/power_policy_controller.h"
49 #include "chromeos/dbus/session_manager_client.h" 51 #include "chromeos/dbus/session_manager_client.h"
50 #include "chromeos/dbus/update_engine_client.h" 52 #include "chromeos/dbus/update_engine_client.h"
51 #endif 53 #endif
52 54
53 #if defined(OS_WIN) 55 #if defined(OS_WIN)
54 #include "base/win/win_util.h" 56 #include "base/win/win_util.h"
55 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 57 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
56 #include "chrome/common/chrome_constants.h"
57 #endif 58 #endif
58 59
59 namespace chrome { 60 namespace chrome {
60 namespace { 61 namespace {
61 62
62 #if !defined(OS_ANDROID) 63 #if !defined(OS_ANDROID)
63 // Returns true if all browsers can be closed without user interaction. 64 // Returns true if all browsers can be closed without user interaction.
64 // This currently checks if there is pending download, or if it needs to 65 // This currently checks if there is pending download, or if it needs to
65 // handle unload handler. 66 // handle unload handler.
66 bool AreAllBrowsersCloseable() { 67 bool AreAllBrowsersCloseable() {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // ~ShutdownWatcherHelper uses IO (it joins a thread). We'll only trigger that 299 // ~ShutdownWatcherHelper uses IO (it joins a thread). We'll only trigger that
299 // if Terminate() fails, which leaves us in a weird state, or the OS is going 300 // if Terminate() fails, which leaves us in a weird state, or the OS is going
300 // to kill us soon. Either way we don't care about that here. 301 // to kill us soon. Either way we don't care about that here.
301 base::ThreadRestrictions::ScopedAllowIO allow_io; 302 base::ThreadRestrictions::ScopedAllowIO allow_io;
302 303
303 // Start watching for hang during shutdown, and crash it if takes too long. 304 // Start watching for hang during shutdown, and crash it if takes too long.
304 // We disarm when |shutdown_watcher| object is destroyed, which is when we 305 // We disarm when |shutdown_watcher| object is destroyed, which is when we
305 // exit this function. 306 // exit this function.
306 ShutdownWatcherHelper shutdown_watcher; 307 ShutdownWatcherHelper shutdown_watcher;
307 shutdown_watcher.Arm(base::TimeDelta::FromSeconds(90)); 308 shutdown_watcher.Arm(base::TimeDelta::FromSeconds(90));
309 PrefService* local_state = g_browser_process->local_state();
310 if (local_state) {
Alexei Svitkine (slow) 2016/11/25 19:51:31 Are you sure we need this if? If try bots pass wi
manzagop (departed) 2016/11/25 20:16:41 Done.
311 metrics::MetricsService::SetExecutionPhase(
312 metrics::MetricsService::SHUTDOWN_TIMEBOMB_ARM, local_state);
313 }
308 314
309 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION); 315 browser_shutdown::OnShutdownStarting(browser_shutdown::END_SESSION);
310 316
311 // In a clean shutdown, browser_shutdown::OnShutdownStarting sets 317 // In a clean shutdown, browser_shutdown::OnShutdownStarting sets
312 // g_shutdown_type, and browser_shutdown::ShutdownPreThreadsStop calls 318 // g_shutdown_type, and browser_shutdown::ShutdownPreThreadsStop calls
313 // RecordShutdownInfoPrefs to update the pref with the value. However, here 319 // RecordShutdownInfoPrefs to update the pref with the value. However, here
314 // the process is going to exit without calling ShutdownPreThreadsStop. 320 // the process is going to exit without calling ShutdownPreThreadsStop.
315 // Instead, here we call RecordShutdownInfoPrefs to record the shutdown info. 321 // Instead, here we call RecordShutdownInfoPrefs to record the shutdown info.
316 browser_shutdown::RecordShutdownInfoPrefs(); 322 browser_shutdown::RecordShutdownInfoPrefs();
317 323
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 void OnAppExiting() { 404 void OnAppExiting() {
399 static bool notified = false; 405 static bool notified = false;
400 if (notified) 406 if (notified)
401 return; 407 return;
402 notified = true; 408 notified = true;
403 HandleAppExitingForPlatform(); 409 HandleAppExitingForPlatform();
404 } 410 }
405 #endif // !defined(OS_ANDROID) 411 #endif // !defined(OS_ANDROID)
406 412
407 } // namespace chrome 413 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698