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 26 matching lines...) Expand all Loading... |
37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
38 #include "base/win/windows_version.h" | 38 #include "base/win/windows_version.h" |
39 #include "ui/base/win/scoped_ole_initializer.h" | 39 #include "ui/base/win/scoped_ole_initializer.h" |
40 #include "ui/gfx/win/direct_write.h" | 40 #include "ui/gfx/win/direct_write.h" |
41 #endif | 41 #endif |
42 | 42 |
43 namespace content { | 43 namespace content { |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 bool g_exited_main_message_loop = false; | 47 base::LazyInstance<base::AtomicFlag>::Leaky g_exited_main_message_loop; |
48 const char kMainThreadName[] = "CrBrowserMain"; | 48 const char kMainThreadName[] = "CrBrowserMain"; |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 class BrowserMainRunnerImpl : public BrowserMainRunner { | 52 class BrowserMainRunnerImpl : public BrowserMainRunner { |
53 public: | 53 public: |
54 BrowserMainRunnerImpl() | 54 BrowserMainRunnerImpl() |
55 : initialization_started_(false), is_shutdown_(false) {} | 55 : initialization_started_(false), is_shutdown_(false) {} |
56 | 56 |
57 ~BrowserMainRunnerImpl() override { | 57 ~BrowserMainRunnerImpl() override { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 *base::CommandLine::ForCurrentProcess(); | 188 *base::CommandLine::ForCurrentProcess(); |
189 std::unique_ptr<BrowserShutdownProfileDumper> shutdown_profiler; | 189 std::unique_ptr<BrowserShutdownProfileDumper> shutdown_profiler; |
190 if (command_line.HasSwitch(switches::kTraceShutdown)) { | 190 if (command_line.HasSwitch(switches::kTraceShutdown)) { |
191 shutdown_profiler.reset(new BrowserShutdownProfileDumper( | 191 shutdown_profiler.reset(new BrowserShutdownProfileDumper( |
192 BrowserShutdownProfileDumper::GetShutdownProfileFileName())); | 192 BrowserShutdownProfileDumper::GetShutdownProfileFileName())); |
193 } | 193 } |
194 | 194 |
195 { | 195 { |
196 // The trace event has to stay between profiler creation and destruction. | 196 // The trace event has to stay between profiler creation and destruction. |
197 TRACE_EVENT0("shutdown", "BrowserMainRunner"); | 197 TRACE_EVENT0("shutdown", "BrowserMainRunner"); |
198 g_exited_main_message_loop = true; | 198 g_exited_main_message_loop.Get().Set(); |
199 | 199 |
200 main_loop_->ShutdownThreadsAndCleanUp(); | 200 main_loop_->ShutdownThreadsAndCleanUp(); |
201 | 201 |
202 ui::ShutdownInputMethod(); | 202 ui::ShutdownInputMethod(); |
203 #if defined(OS_WIN) | 203 #if defined(OS_WIN) |
204 ole_initializer_.reset(NULL); | 204 ole_initializer_.reset(NULL); |
205 #endif | 205 #endif |
206 #if defined(OS_ANDROID) | 206 #if defined(OS_ANDROID) |
207 // Forcefully terminates the RunLoop inside MessagePumpForUI, ensuring | 207 // Forcefully terminates the RunLoop inside MessagePumpForUI, ensuring |
208 // proper shutdown for content_browsertests. Shutdown() is not used by | 208 // proper shutdown for content_browsertests. Shutdown() is not used by |
(...skipping 26 matching lines...) Expand all Loading... |
235 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); | 235 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); |
236 }; | 236 }; |
237 | 237 |
238 // static | 238 // static |
239 BrowserMainRunner* BrowserMainRunner::Create() { | 239 BrowserMainRunner* BrowserMainRunner::Create() { |
240 return new BrowserMainRunnerImpl(); | 240 return new BrowserMainRunnerImpl(); |
241 } | 241 } |
242 | 242 |
243 // static | 243 // static |
244 bool BrowserMainRunner::ExitedMainMessageLoop() { | 244 bool BrowserMainRunner::ExitedMainMessageLoop() { |
245 return g_exited_main_message_loop; | 245 return !(g_exited_main_message_loop == nullptr) && |
| 246 g_exited_main_message_loop.Get().IsSet(); |
246 } | 247 } |
247 | 248 |
248 } // namespace content | 249 } // namespace content |
OLD | NEW |