| OLD | NEW |
| 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/at_exit.h" | 15 #include "base/at_exit.h" |
| 16 #include "base/base_switches.h" | 16 #include "base/base_switches.h" |
| 17 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/debug/crash_logging.h" | 19 #include "base/debug/crash_logging.h" |
| 20 #include "base/debug/debugger.h" | 20 #include "base/debug/debugger.h" |
| 21 #include "base/feature_list.h" | 21 #include "base/feature_list.h" |
| 22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
| 23 #include "base/files/file_util.h" | 23 #include "base/files/file_util.h" |
| 24 #include "base/logging.h" | 24 #include "base/logging.h" |
| 25 #include "base/memory/ptr_util.h" | 25 #include "base/memory/ptr_util.h" |
| 26 #include "base/metrics/field_trial.h" | 26 #include "base/metrics/field_trial.h" |
| 27 #include "base/metrics/histogram_macros.h" | 27 #include "base/metrics/histogram_macros.h" |
| 28 #include "base/path_service.h" | 28 #include "base/path_service.h" |
| 29 #include "base/profiler/scoped_tracker.h" | 29 #include "base/profiler/scoped_tracker.h" |
| 30 #include "base/profiler/stack_sampling_profiler.h" |
| 30 #include "base/run_loop.h" | 31 #include "base/run_loop.h" |
| 31 #include "base/strings/string16.h" | 32 #include "base/strings/string16.h" |
| 32 #include "base/strings/string_number_conversions.h" | 33 #include "base/strings/string_number_conversions.h" |
| 33 #include "base/strings/sys_string_conversions.h" | 34 #include "base/strings/sys_string_conversions.h" |
| 34 #include "base/strings/utf_string_conversions.h" | 35 #include "base/strings/utf_string_conversions.h" |
| 35 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
| 36 #include "base/task_scheduler/task_scheduler.h" | 37 #include "base/task_scheduler/task_scheduler.h" |
| 37 #include "base/threading/platform_thread.h" | 38 #include "base/threading/platform_thread.h" |
| 38 #include "base/time/default_tick_clock.h" | 39 #include "base/time/default_tick_clock.h" |
| 39 #include "base/time/time.h" | 40 #include "base/time/time.h" |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart"); | 920 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart"); |
| 920 | 921 |
| 921 // device_event_log must be initialized after the message loop. Calls to | 922 // device_event_log must be initialized after the message loop. Calls to |
| 922 // {DEVICE}_LOG prior to here will only be logged with VLOG. Some | 923 // {DEVICE}_LOG prior to here will only be logged with VLOG. Some |
| 923 // platforms (e.g. chromeos) may have already initialized this. | 924 // platforms (e.g. chromeos) may have already initialized this. |
| 924 if (!device_event_log::IsInitialized()) | 925 if (!device_event_log::IsInitialized()) |
| 925 device_event_log::Initialize(0 /* default max entries */); | 926 device_event_log::Initialize(0 /* default max entries */); |
| 926 | 927 |
| 927 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 928 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 928 chrome_extra_parts_[i]->PostMainMessageLoopStart(); | 929 chrome_extra_parts_[i]->PostMainMessageLoopStart(); |
| 930 |
| 931 base::StackSamplingProfiler::SetProcessPhase( |
| 932 metrics::CallStackProfileMetricsProvider::MAIN_LOOP_START); |
| 929 } | 933 } |
| 930 | 934 |
| 931 int ChromeBrowserMainParts::PreCreateThreads() { | 935 int ChromeBrowserMainParts::PreCreateThreads() { |
| 932 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); | 936 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); |
| 933 result_code_ = PreCreateThreadsImpl(); | 937 result_code_ = PreCreateThreadsImpl(); |
| 934 | 938 |
| 935 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { | 939 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { |
| 936 #if !defined(OS_ANDROID) | 940 #if !defined(OS_ANDROID) |
| 937 // These members must be initialized before exiting this function normally. | 941 // These members must be initialized before exiting this function normally. |
| 938 DCHECK(master_prefs_.get()); | 942 DCHECK(master_prefs_.get()); |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 // to bypass this code. Perhaps we need a *final* hook that is called on all | 2092 // to bypass this code. Perhaps we need a *final* hook that is called on all |
| 2089 // paths from content/browser/browser_main. | 2093 // paths from content/browser/browser_main. |
| 2090 CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown()); | 2094 CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown()); |
| 2091 | 2095 |
| 2092 #if defined(OS_CHROMEOS) | 2096 #if defined(OS_CHROMEOS) |
| 2093 chromeos::CrosSettings::Shutdown(); | 2097 chromeos::CrosSettings::Shutdown(); |
| 2094 #endif // defined(OS_CHROMEOS) | 2098 #endif // defined(OS_CHROMEOS) |
| 2095 #endif // defined(OS_ANDROID) | 2099 #endif // defined(OS_ANDROID) |
| 2096 } | 2100 } |
| 2097 | 2101 |
| 2102 void ChromeBrowserMainParts::PreShutdown() { |
| 2103 base::StackSamplingProfiler::SetProcessPhase( |
| 2104 metrics::CallStackProfileMetricsProvider::SHUTDOWN_START); |
| 2105 } |
| 2106 |
| 2098 // Public members: | 2107 // Public members: |
| 2099 | 2108 |
| 2100 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2109 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2101 chrome_extra_parts_.push_back(parts); | 2110 chrome_extra_parts_.push_back(parts); |
| 2102 } | 2111 } |
| OLD | NEW |