| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/browser_main.h" | 5 #include "content/browser/browser_main.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/command_line.h" | 9 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 12 #include "content/browser/browser_main_loop.h" | 13 #include "content/browser/browser_main_loop.h" |
| 13 #include "content/browser/notification_service_impl.h" | 14 #include "content/browser/notification_service_impl.h" |
| 15 #include "content/common/child_process.h" |
| 14 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/common/main_function_params.h" | 17 #include "content/public/common/main_function_params.h" |
| 16 | 18 |
| 17 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 18 #include "base/win/scoped_com_initializer.h" | 20 #include "base/win/scoped_com_initializer.h" |
| 19 #endif | 21 #endif |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 bool g_exited_main_message_loop = false; | 25 bool g_exited_main_message_loop = false; |
| 24 | 26 |
| 25 } // namespace | 27 } // namespace |
| 26 | 28 |
| 27 namespace content { | 29 namespace content { |
| 28 | 30 |
| 29 bool ExitedMainMessageLoop() { | 31 bool ExitedMainMessageLoop() { |
| 30 return g_exited_main_message_loop; | 32 return g_exited_main_message_loop; |
| 31 } | 33 } |
| 32 | 34 |
| 33 } // namespace content | 35 } // namespace content |
| 34 | 36 |
| 35 // Main routine for running as the Browser process. | 37 // Main routine for running as the Browser process. |
| 36 int BrowserMain(const content::MainFunctionParams& parameters) { | 38 int BrowserMain(const content::MainFunctionParams& parameters) { |
| 37 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, ""); | 39 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, ""); |
| 38 | 40 |
| 41 // ChildProcess:: is a misnomer unless you consider context. Use |
| 42 // of --wait-for-debugger only makes sense when Chrome itself is a |
| 43 // child process (e.g. when launched by PyAuto). |
| 44 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) |
| 45 ChildProcess::WaitForDebugger("Browser"); |
| 46 |
| 39 NotificationServiceImpl main_notification_service; | 47 NotificationServiceImpl main_notification_service; |
| 40 | 48 |
| 41 scoped_ptr<content::BrowserMainLoop> main_loop( | 49 scoped_ptr<content::BrowserMainLoop> main_loop( |
| 42 new content::BrowserMainLoop(parameters)); | 50 new content::BrowserMainLoop(parameters)); |
| 43 | 51 |
| 44 main_loop->Init(); | 52 main_loop->Init(); |
| 45 | 53 |
| 46 main_loop->EarlyInitialization(); | 54 main_loop->EarlyInitialization(); |
| 47 | 55 |
| 48 // Must happen before we try to use a message loop or display any UI. | 56 // Must happen before we try to use a message loop or display any UI. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 #endif // OS_WIN | 96 #endif // OS_WIN |
| 89 | 97 |
| 90 base::StatisticsRecorder statistics; | 98 base::StatisticsRecorder statistics; |
| 91 | 99 |
| 92 main_loop->RunMainMessageLoopParts(&g_exited_main_message_loop); | 100 main_loop->RunMainMessageLoopParts(&g_exited_main_message_loop); |
| 93 | 101 |
| 94 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 102 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
| 95 | 103 |
| 96 return main_loop->GetResultCode(); | 104 return main_loop->GetResultCode(); |
| 97 } | 105 } |
| OLD | NEW |