| 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/debugger.h" | 9 #include "base/debug/debugger.h" |
| 10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 int Run() override { | 138 int Run() override { |
| 139 DCHECK(initialization_started_); | 139 DCHECK(initialization_started_); |
| 140 DCHECK(!is_shutdown_); | 140 DCHECK(!is_shutdown_); |
| 141 main_loop_->RunMainMessageLoopParts(); | 141 main_loop_->RunMainMessageLoopParts(); |
| 142 return main_loop_->GetResultCode(); | 142 return main_loop_->GetResultCode(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void Shutdown() override { | 145 void Shutdown() override { |
| 146 DCHECK(initialization_started_); | 146 DCHECK(initialization_started_); |
| 147 DCHECK(!is_shutdown_); | 147 DCHECK(!is_shutdown_); |
| 148 |
| 148 #ifdef LEAK_SANITIZER | 149 #ifdef LEAK_SANITIZER |
| 149 // Invoke leak detection now, to avoid dealing with shutdown-only leaks. | 150 // Invoke leak detection now, to avoid dealing with shutdown-only leaks. |
| 150 // Normally this will have already happened in | 151 // Normally this will have already happened in |
| 151 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is | 152 // BroserProcessImpl::ReleaseModule(), so this call has no effect. This is |
| 152 // only for processes which do not instantiate a BrowserProcess. | 153 // only for processes which do not instantiate a BrowserProcess. |
| 153 // If leaks are found, the process will exit here. | 154 // If leaks are found, the process will exit here. |
| 154 __lsan_do_leak_check(); | 155 __lsan_do_leak_check(); |
| 155 #endif | 156 #endif |
| 157 |
| 158 main_loop_->PreShutdown(); |
| 159 |
| 156 // If startup tracing has not been finished yet, replace it's dumper | 160 // If startup tracing has not been finished yet, replace it's dumper |
| 157 // with special version, which would save trace file on exit (i.e. | 161 // with special version, which would save trace file on exit (i.e. |
| 158 // startup tracing becomes a version of shutdown tracing). | 162 // startup tracing becomes a version of shutdown tracing). |
| 159 // There are two cases: | 163 // There are two cases: |
| 160 // 1. Startup duration is not reached. | 164 // 1. Startup duration is not reached. |
| 161 // 2. Or startup duration is not specified for --trace-config-file flag. | 165 // 2. Or startup duration is not specified for --trace-config-file flag. |
| 162 std::unique_ptr<BrowserShutdownProfileDumper> startup_profiler; | 166 std::unique_ptr<BrowserShutdownProfileDumper> startup_profiler; |
| 163 if (main_loop_->is_tracing_startup_for_duration()) { | 167 if (main_loop_->is_tracing_startup_for_duration()) { |
| 164 main_loop_->StopStartupTracingTimer(); | 168 main_loop_->StopStartupTracingTimer(); |
| 165 if (main_loop_->startup_trace_file() != | 169 if (main_loop_->startup_trace_file() != |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
| 201 ole_initializer_.reset(NULL); | 205 ole_initializer_.reset(NULL); |
| 202 #endif | 206 #endif |
| 203 #if defined(OS_ANDROID) | 207 #if defined(OS_ANDROID) |
| 204 // Forcefully terminates the RunLoop inside MessagePumpForUI, ensuring | 208 // Forcefully terminates the RunLoop inside MessagePumpForUI, ensuring |
| 205 // proper shutdown for content_browsertests. Shutdown() is not used by | 209 // proper shutdown for content_browsertests. Shutdown() is not used by |
| 206 // the actual browser. | 210 // the actual browser. |
| 207 if (base::MessageLoop::current()->is_running()) | 211 if (base::MessageLoop::current()->is_running()) |
| 208 base::MessageLoop::current()->QuitNow(); | 212 base::MessageLoop::current()->QuitNow(); |
| 209 #endif | 213 #endif |
| 214 main_loop_->PostShutdown(); |
| 210 main_loop_.reset(NULL); | 215 main_loop_.reset(NULL); |
| 211 | 216 |
| 212 notification_service_.reset(NULL); | 217 notification_service_.reset(NULL); |
| 213 | 218 |
| 214 is_shutdown_ = true; | 219 is_shutdown_ = true; |
| 215 } | 220 } |
| 216 } | 221 } |
| 217 | 222 |
| 218 protected: | 223 protected: |
| 219 // True if we have started to initialize the runner. | 224 // True if we have started to initialize the runner. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 236 BrowserMainRunner* BrowserMainRunner::Create() { | 241 BrowserMainRunner* BrowserMainRunner::Create() { |
| 237 return new BrowserMainRunnerImpl(); | 242 return new BrowserMainRunnerImpl(); |
| 238 } | 243 } |
| 239 | 244 |
| 240 // static | 245 // static |
| 241 bool BrowserMainRunner::ExitedMainMessageLoop() { | 246 bool BrowserMainRunner::ExitedMainMessageLoop() { |
| 242 return g_exited_main_message_loop; | 247 return g_exited_main_message_loop; |
| 243 } | 248 } |
| 244 | 249 |
| 245 } // namespace content | 250 } // namespace content |
| OLD | NEW |