| 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 "content/public/browser/browser_main_runner.h" | 5 #include "content/public/browser/browser_main_runner.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
| 15 #include "base/profiler/scoped_profile.h" | 15 #include "base/profiler/scoped_profile.h" |
| 16 #include "base/profiler/scoped_tracker.h" | 16 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 18 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
| 19 #include "base/tracked_objects.h" | 20 #include "base/tracked_objects.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 21 #include "components/tracing/trace_config_file.h" | 22 #include "components/tracing/trace_config_file.h" |
| 22 #include "components/tracing/tracing_switches.h" | 23 #include "components/tracing/tracing_switches.h" |
| 23 #include "content/browser/browser_main_loop.h" | 24 #include "content/browser/browser_main_loop.h" |
| 24 #include "content/browser/browser_shutdown_profile_dumper.h" | 25 #include "content/browser/browser_shutdown_profile_dumper.h" |
| 25 #include "content/browser/notification_service_impl.h" | 26 #include "content/browser/notification_service_impl.h" |
| 26 #include "content/public/browser/tracing_controller.h" | 27 #include "content/public/browser/tracing_controller.h" |
| 27 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/common/main_function_params.h" | 29 #include "content/public/common/main_function_params.h" |
| 29 #include "third_party/skia/include/core/SkGraphics.h" | 30 #include "third_party/skia/include/core/SkGraphics.h" |
| 30 #include "ui/base/ime/input_method_initializer.h" | 31 #include "ui/base/ime/input_method_initializer.h" |
| 31 | 32 |
| 32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 33 #include "content/browser/android/tracing_controller_android.h" | 34 #include "content/browser/android/tracing_controller_android.h" |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 37 #include "base/win/windows_version.h" | 38 #include "base/win/windows_version.h" |
| 38 #include "ui/base/win/scoped_ole_initializer.h" | 39 #include "ui/base/win/scoped_ole_initializer.h" |
| 39 #include "ui/gfx/win/direct_write.h" | 40 #include "ui/gfx/win/direct_write.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 namespace content { | 43 namespace content { |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 bool g_exited_main_message_loop = false; | 47 bool g_exited_main_message_loop = false; |
| 48 const char kMainThreadName[] = "CrBrowserMain"; |
| 47 | 49 |
| 48 } // namespace | 50 } // namespace |
| 49 | 51 |
| 50 class BrowserMainRunnerImpl : public BrowserMainRunner { | 52 class BrowserMainRunnerImpl : public BrowserMainRunner { |
| 51 public: | 53 public: |
| 52 BrowserMainRunnerImpl() | 54 BrowserMainRunnerImpl() |
| 53 : initialization_started_(false), is_shutdown_(false) {} | 55 : initialization_started_(false), is_shutdown_(false) {} |
| 54 | 56 |
| 55 ~BrowserMainRunnerImpl() override { | 57 ~BrowserMainRunnerImpl() override { |
| 56 if (initialization_started_ && !is_shutdown_) | 58 if (initialization_started_ && !is_shutdown_) |
| 57 Shutdown(); | 59 Shutdown(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 int Initialize(const MainFunctionParams& parameters) override { | 62 int Initialize(const MainFunctionParams& parameters) override { |
| 61 SCOPED_UMA_HISTOGRAM_LONG_TIMER( | 63 SCOPED_UMA_HISTOGRAM_LONG_TIMER( |
| 62 "Startup.BrowserMainRunnerImplInitializeLongTime"); | 64 "Startup.BrowserMainRunnerImplInitializeLongTime"); |
| 63 | 65 |
| 64 // TODO(vadimt, yiyaoliu): Remove all tracked_objects references below once | 66 // TODO(vadimt, yiyaoliu): Remove all tracked_objects references below once |
| 65 // crbug.com/453640 is fixed. | 67 // crbug.com/453640 is fixed. |
| 66 tracked_objects::ThreadData::InitializeThreadContext("CrBrowserMain"); | 68 tracked_objects::ThreadData::InitializeThreadContext(kMainThreadName); |
| 69 base::trace_event::AllocationContextTracker::SetCurrentThreadName( |
| 70 kMainThreadName); |
| 67 TRACK_SCOPED_REGION( | 71 TRACK_SCOPED_REGION( |
| 68 "Startup", "BrowserMainRunnerImpl::Initialize"); | 72 "Startup", "BrowserMainRunnerImpl::Initialize"); |
| 69 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); | 73 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); |
| 70 | 74 |
| 71 // On Android we normally initialize the browser in a series of UI thread | 75 // On Android we normally initialize the browser in a series of UI thread |
| 72 // tasks. While this is happening a second request can come from the OS or | 76 // tasks. While this is happening a second request can come from the OS or |
| 73 // another application to start the browser. If this happens then we must | 77 // another application to start the browser. If this happens then we must |
| 74 // not run these parts of initialization twice. | 78 // not run these parts of initialization twice. |
| 75 if (!initialization_started_) { | 79 if (!initialization_started_) { |
| 76 initialization_started_ = true; | 80 initialization_started_ = true; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 BrowserMainRunner* BrowserMainRunner::Create() { | 251 BrowserMainRunner* BrowserMainRunner::Create() { |
| 248 return new BrowserMainRunnerImpl(); | 252 return new BrowserMainRunnerImpl(); |
| 249 } | 253 } |
| 250 | 254 |
| 251 // static | 255 // static |
| 252 bool BrowserMainRunner::ExitedMainMessageLoop() { | 256 bool BrowserMainRunner::ExitedMainMessageLoop() { |
| 253 return g_exited_main_message_loop; | 257 return g_exited_main_message_loop; |
| 254 } | 258 } |
| 255 | 259 |
| 256 } // namespace content | 260 } // namespace content |
| OLD | NEW |