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

Side by Side Diff: chrome/browser/browser_shutdown.cc

Issue 1388303002: Move assorted function in application_lifetime to where they are used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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/browser_shutdown.h" 5 #include "chrome/browser/browser_shutdown.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/prefs/pref_registry_simple.h" 16 #include "base/prefs/pref_registry_simple.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "base/trace_event/trace_event.h"
22 #include "chrome/browser/about_flags.h" 23 #include "chrome/browser/about_flags.h"
23 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/lifetime/application_lifetime.h" 25 #include "chrome/browser/lifetime/application_lifetime.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/profiles/profile_metrics.h" 27 #include "chrome/browser/profiles/profile_metrics.h"
27 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/crash_keys.h" 30 #include "chrome/common/crash_keys.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "chrome/common/switch_utils.h" 32 #include "chrome/common/switch_utils.h"
32 #include "components/metrics/metrics_service.h" 33 #include "components/metrics/metrics_service.h"
34 #include "components/tracing/tracing_switches.h"
33 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/render_process_host.h" 36 #include "content/public/browser/render_process_host.h"
35 37
36 #if defined(OS_WIN) 38 #if defined(OS_WIN)
37 #include "chrome/browser/browser_util_win.h" 39 #include "chrome/browser/browser_util_win.h"
38 #include "chrome/browser/first_run/upgrade_util_win.h" 40 #include "chrome/browser/first_run/upgrade_util_win.h"
39 #endif 41 #endif
40 42
41 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 43 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
42 #include "chrome/browser/first_run/upgrade_util.h" 44 #include "chrome/browser/first_run/upgrade_util.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 107 }
106 108
107 void OnShutdownStarting(ShutdownType type) { 109 void OnShutdownStarting(ShutdownType type) {
108 if (g_shutdown_type != NOT_VALID) 110 if (g_shutdown_type != NOT_VALID)
109 return; 111 return;
110 base::debug::SetCrashKeyValue(crash_keys::kShutdownType, 112 base::debug::SetCrashKeyValue(crash_keys::kShutdownType,
111 ToShutdownTypeString(type)); 113 ToShutdownTypeString(type));
112 #if !defined(OS_CHROMEOS) 114 #if !defined(OS_CHROMEOS)
113 // Start the shutdown tracing. Note that On ChromeOS this has already been 115 // Start the shutdown tracing. Note that On ChromeOS this has already been
114 // called in AttemptUserExit(). 116 // called in AttemptUserExit().
115 chrome::StartShutdownTracing(); 117 browser_shutdown::StartShutdownTracing();
sky 2015/10/07 17:12:32 Isn't this code in the browser_shutdown namespace?
Lei Zhang 2015/10/08 07:01:58 Done.
116 #endif 118 #endif
117 119
118 g_shutdown_type = type; 120 g_shutdown_type = type;
119 // For now, we're only counting the number of renderer processes 121 // For now, we're only counting the number of renderer processes
120 // since we can't safely count the number of plugin processes from this 122 // since we can't safely count the number of plugin processes from this
121 // thread, and we'd really like to avoid anything which might add further 123 // thread, and we'd really like to avoid anything which might add further
122 // delays to shutdown time. 124 // delays to shutdown time.
123 DCHECK(!g_shutdown_started); 125 DCHECK(!g_shutdown_started);
124 g_shutdown_started = new Time(Time::Now()); 126 g_shutdown_started = new Time(Time::Now());
125 127
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 341 }
340 342
341 void SetTryingToQuit(bool quitting) { 343 void SetTryingToQuit(bool quitting) {
342 g_trying_to_quit = quitting; 344 g_trying_to_quit = quitting;
343 } 345 }
344 346
345 bool IsTryingToQuit() { 347 bool IsTryingToQuit() {
346 return g_trying_to_quit; 348 return g_trying_to_quit;
347 } 349 }
348 350
351 void StartShutdownTracing() {
352 const base::CommandLine& command_line =
353 *base::CommandLine::ForCurrentProcess();
354 if (command_line.HasSwitch(switches::kTraceShutdown)) {
355 base::trace_event::TraceConfig trace_config(
356 command_line.GetSwitchValueASCII(switches::kTraceShutdown), "");
357 base::trace_event::TraceLog::GetInstance()->SetEnabled(
358 trace_config,
359 base::trace_event::TraceLog::RECORDING_MODE);
360 }
361 TRACE_EVENT0("shutdown", "StartShutdownTracing");
362 }
363
349 } // namespace browser_shutdown 364 } // namespace browser_shutdown
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698