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/allocator/allocator_shim.h" | 7 #include "base/allocator/allocator_shim.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 class BrowserMainRunnerImpl : public BrowserMainRunner { | 117 class BrowserMainRunnerImpl : public BrowserMainRunner { |
118 public: | 118 public: |
119 BrowserMainRunnerImpl() | 119 BrowserMainRunnerImpl() |
120 : initialization_started_(false), is_shutdown_(false) {} | 120 : initialization_started_(false), is_shutdown_(false) {} |
121 | 121 |
122 virtual ~BrowserMainRunnerImpl() { | 122 virtual ~BrowserMainRunnerImpl() { |
123 if (initialization_started_ && !is_shutdown_) | 123 if (initialization_started_ && !is_shutdown_) |
124 Shutdown(); | 124 Shutdown(); |
125 } | 125 } |
126 | 126 |
127 virtual int Initialize(const MainFunctionParams& parameters) OVERRIDE { | 127 virtual int Initialize(const MainFunctionParams& parameters) override { |
128 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); | 128 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); |
129 // On Android we normally initialize the browser in a series of UI thread | 129 // On Android we normally initialize the browser in a series of UI thread |
130 // tasks. While this is happening a second request can come from the OS or | 130 // tasks. While this is happening a second request can come from the OS or |
131 // another application to start the browser. If this happens then we must | 131 // another application to start the browser. If this happens then we must |
132 // not run these parts of initialization twice. | 132 // not run these parts of initialization twice. |
133 if (!initialization_started_) { | 133 if (!initialization_started_) { |
134 initialization_started_ = true; | 134 initialization_started_ = true; |
135 | 135 |
136 #if !defined(OS_IOS) | 136 #if !defined(OS_IOS) |
137 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) | 137 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 main_loop_->CreateStartupTasks(); | 193 main_loop_->CreateStartupTasks(); |
194 int result_code = main_loop_->GetResultCode(); | 194 int result_code = main_loop_->GetResultCode(); |
195 if (result_code > 0) | 195 if (result_code > 0) |
196 return result_code; | 196 return result_code; |
197 | 197 |
198 // Return -1 to indicate no early termination. | 198 // Return -1 to indicate no early termination. |
199 return -1; | 199 return -1; |
200 } | 200 } |
201 | 201 |
202 virtual int Run() OVERRIDE { | 202 virtual int Run() override { |
203 DCHECK(initialization_started_); | 203 DCHECK(initialization_started_); |
204 DCHECK(!is_shutdown_); | 204 DCHECK(!is_shutdown_); |
205 main_loop_->RunMainMessageLoopParts(); | 205 main_loop_->RunMainMessageLoopParts(); |
206 return main_loop_->GetResultCode(); | 206 return main_loop_->GetResultCode(); |
207 } | 207 } |
208 | 208 |
209 virtual void Shutdown() OVERRIDE { | 209 virtual void Shutdown() override { |
210 DCHECK(initialization_started_); | 210 DCHECK(initialization_started_); |
211 DCHECK(!is_shutdown_); | 211 DCHECK(!is_shutdown_); |
212 #ifdef LEAK_SANITIZER | 212 #ifdef LEAK_SANITIZER |
213 // Invoke leak detection now, to avoid dealing with shutdown-only leaks. | 213 // Invoke leak detection now, to avoid dealing with shutdown-only leaks. |
214 // Normally this will have already happened in | 214 // Normally this will have already happened in |
215 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is | 215 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is |
216 // only for processes which do not instantiate a BrowserProcess. | 216 // only for processes which do not instantiate a BrowserProcess. |
217 // If leaks are found, the process will exit here. | 217 // If leaks are found, the process will exit here. |
218 __lsan_do_leak_check(); | 218 __lsan_do_leak_check(); |
219 #endif | 219 #endif |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); | 282 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); |
283 }; | 283 }; |
284 | 284 |
285 // static | 285 // static |
286 BrowserMainRunner* BrowserMainRunner::Create() { | 286 BrowserMainRunner* BrowserMainRunner::Create() { |
287 return new BrowserMainRunnerImpl(); | 287 return new BrowserMainRunnerImpl(); |
288 } | 288 } |
289 | 289 |
290 } // namespace content | 290 } // namespace content |
OLD | NEW |