| 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/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
| 13 #include "base/profiler/scoped_tracker.h" | |
| 14 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 15 #include "base/tracked_objects.h" | |
| 16 #include "content/browser/browser_main_loop.h" | 14 #include "content/browser/browser_main_loop.h" |
| 17 #include "content/browser/browser_shutdown_profile_dumper.h" | 15 #include "content/browser/browser_shutdown_profile_dumper.h" |
| 18 #include "content/browser/notification_service_impl.h" | 16 #include "content/browser/notification_service_impl.h" |
| 19 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/common/main_function_params.h" | 18 #include "content/public/common/main_function_params.h" |
| 21 #include "ui/base/ime/input_method_initializer.h" | 19 #include "ui/base/ime/input_method_initializer.h" |
| 22 | 20 |
| 23 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 24 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
| 25 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 public: | 119 public: |
| 122 BrowserMainRunnerImpl() | 120 BrowserMainRunnerImpl() |
| 123 : initialization_started_(false), is_shutdown_(false) {} | 121 : initialization_started_(false), is_shutdown_(false) {} |
| 124 | 122 |
| 125 ~BrowserMainRunnerImpl() override { | 123 ~BrowserMainRunnerImpl() override { |
| 126 if (initialization_started_ && !is_shutdown_) | 124 if (initialization_started_ && !is_shutdown_) |
| 127 Shutdown(); | 125 Shutdown(); |
| 128 } | 126 } |
| 129 | 127 |
| 130 int Initialize(const MainFunctionParams& parameters) override { | 128 int Initialize(const MainFunctionParams& parameters) override { |
| 131 // TODO(vadimt): Remove all tracked_objects references below once | |
| 132 // crbug.com/453640 is fixed. | |
| 133 tracked_objects::ThreadData::InitializeThreadContext("CrBrowserMain"); | |
| 134 | |
| 135 tracked_objects::ScopedTracker tracking_profile( | |
| 136 FROM_HERE_WITH_EXPLICIT_FUNCTION("BrowserMainRunnerImpl::Initialize")); | |
| 137 | |
| 138 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); | 129 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); |
| 139 // On Android we normally initialize the browser in a series of UI thread | 130 // On Android we normally initialize the browser in a series of UI thread |
| 140 // tasks. While this is happening a second request can come from the OS or | 131 // tasks. While this is happening a second request can come from the OS or |
| 141 // another application to start the browser. If this happens then we must | 132 // another application to start the browser. If this happens then we must |
| 142 // not run these parts of initialization twice. | 133 // not run these parts of initialization twice. |
| 143 if (!initialization_started_) { | 134 if (!initialization_started_) { |
| 144 initialization_started_ = true; | 135 initialization_started_ = true; |
| 145 | 136 |
| 146 #if !defined(OS_IOS) | 137 #if !defined(OS_IOS) |
| 147 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) | 138 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 277 |
| 287 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); | 278 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); |
| 288 }; | 279 }; |
| 289 | 280 |
| 290 // static | 281 // static |
| 291 BrowserMainRunner* BrowserMainRunner::Create() { | 282 BrowserMainRunner* BrowserMainRunner::Create() { |
| 292 return new BrowserMainRunnerImpl(); | 283 return new BrowserMainRunnerImpl(); |
| 293 } | 284 } |
| 294 | 285 |
| 295 } // namespace content | 286 } // namespace content |
| OLD | NEW |