| 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/browser/browser_main.h" | 5 #include "content/browser/browser_main.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "content/common/content_constants_internal.h" | 8 #include "content/common/content_constants_internal.h" |
| 9 #include "content/public/browser/browser_main_runner.h" | 9 #include "content/public/browser/browser_main_runner.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 namespace { |
| 14 |
| 15 // Generates a pair of BrowserMain async events. We don't use the TRACE_EVENT0 |
| 16 // macro because the tracing infrastructure doesn't expect synchronous events |
| 17 // around the main loop of a thread. |
| 18 class ScopedBrowserMainEvent { |
| 19 public: |
| 20 ScopedBrowserMainEvent() { |
| 21 TRACE_EVENT_ASYNC_BEGIN0("startup", "BrowserMain", 0); |
| 22 } |
| 23 ~ScopedBrowserMainEvent() { |
| 24 TRACE_EVENT_ASYNC_END0("startup", "BrowserMain", 0); |
| 25 } |
| 26 }; |
| 27 |
| 28 } // namespace |
| 29 |
| 13 // Main routine for running as the Browser process. | 30 // Main routine for running as the Browser process. |
| 14 int BrowserMain(const MainFunctionParams& parameters) { | 31 int BrowserMain(const MainFunctionParams& parameters) { |
| 15 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, ""); | 32 ScopedBrowserMainEvent scoped_browser_main_event; |
| 33 |
| 16 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); | 34 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser"); |
| 17 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 35 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
| 18 kTraceEventBrowserProcessSortIndex); | 36 kTraceEventBrowserProcessSortIndex); |
| 19 | 37 |
| 20 scoped_ptr<BrowserMainRunner> main_runner(BrowserMainRunner::Create()); | 38 scoped_ptr<BrowserMainRunner> main_runner(BrowserMainRunner::Create()); |
| 21 | 39 |
| 22 int exit_code = main_runner->Initialize(parameters); | 40 int exit_code = main_runner->Initialize(parameters); |
| 23 if (exit_code >= 0) | 41 if (exit_code >= 0) |
| 24 return exit_code; | 42 return exit_code; |
| 25 | 43 |
| 26 exit_code = main_runner->Run(); | 44 exit_code = main_runner->Run(); |
| 27 | 45 |
| 28 main_runner->Shutdown(); | 46 main_runner->Shutdown(); |
| 29 | 47 |
| 30 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | |
| 31 | |
| 32 return exit_code; | 48 return exit_code; |
| 33 } | 49 } |
| 34 | 50 |
| 35 } // namespace content | 51 } // namespace content |
| OLD | NEW |