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