| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "headless/lib/headless_content_main_delegate.h" | 5 #include "headless/lib/headless_content_main_delegate.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
| 28 #include "ui/gfx/switches.h" | 28 #include "ui/gfx/switches.h" |
| 29 #include "ui/gl/gl_switches.h" | 29 #include "ui/gl/gl_switches.h" |
| 30 #include "ui/ozone/public/ozone_switches.h" | 30 #include "ui/ozone/public/ozone_switches.h" |
| 31 | 31 |
| 32 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES | 32 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES |
| 33 #include "headless/embedded_resource_pak.h" | 33 #include "headless/embedded_resource_pak.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if defined(OS_MACOSX) | |
| 37 #include "components/crash/content/app/crashpad.h" | |
| 38 #endif | |
| 39 | |
| 40 namespace headless { | 36 namespace headless { |
| 41 namespace { | 37 namespace { |
| 42 // Keep in sync with content/common/content_constants_internal.h. | 38 // Keep in sync with content/common/content_constants_internal.h. |
| 43 // TODO(skyostil): Add a tracing test for this. | 39 // TODO(skyostil): Add a tracing test for this. |
| 44 const int kTraceEventBrowserProcessSortIndex = -6; | 40 const int kTraceEventBrowserProcessSortIndex = -6; |
| 45 | 41 |
| 46 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; | 42 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; |
| 47 | 43 |
| 48 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client = | 44 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client = |
| 49 LAZY_INSTANCE_INITIALIZER; | 45 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 152 } |
| 157 | 153 |
| 158 void HeadlessContentMainDelegate::InitCrashReporter( | 154 void HeadlessContentMainDelegate::InitCrashReporter( |
| 159 const base::CommandLine& command_line) { | 155 const base::CommandLine& command_line) { |
| 160 const std::string process_type = | 156 const std::string process_type = |
| 161 command_line.GetSwitchValueASCII(switches::kProcessType); | 157 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 162 crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer()); | 158 crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer()); |
| 163 g_headless_crash_client.Pointer()->set_crash_dumps_dir( | 159 g_headless_crash_client.Pointer()->set_crash_dumps_dir( |
| 164 browser_->options()->crash_dumps_dir); | 160 browser_->options()->crash_dumps_dir); |
| 165 | 161 |
| 166 #if defined(HEADLESS_USE_BREAKPAD) | 162 #if !defined(OS_MACOSX) |
| 167 if (!browser_->options()->enable_crash_reporter) { | 163 if (!browser_->options()->enable_crash_reporter) { |
| 168 DCHECK(!breakpad::IsCrashReporterEnabled()); | 164 DCHECK(!breakpad::IsCrashReporterEnabled()); |
| 169 return; | 165 return; |
| 170 } | 166 } |
| 167 #if defined(HEADLESS_USE_BREAKPAD) |
| 171 if (process_type != switches::kZygoteProcess) | 168 if (process_type != switches::kZygoteProcess) |
| 172 breakpad::InitCrashReporter(process_type); | 169 breakpad::InitCrashReporter(process_type); |
| 173 #elif defined(OS_MACOSX) | |
| 174 const bool browser_process = process_type.empty(); | |
| 175 crash_reporter::InitializeCrashpad(browser_process, process_type); | |
| 176 #endif // defined(HEADLESS_USE_BREAKPAD) | 170 #endif // defined(HEADLESS_USE_BREAKPAD) |
| 171 #endif // !defined(OS_MACOSX) |
| 177 } | 172 } |
| 178 | 173 |
| 179 void HeadlessContentMainDelegate::PreSandboxStartup() { | 174 void HeadlessContentMainDelegate::PreSandboxStartup() { |
| 180 const base::CommandLine& command_line( | 175 const base::CommandLine& command_line( |
| 181 *base::CommandLine::ForCurrentProcess()); | 176 *base::CommandLine::ForCurrentProcess()); |
| 182 #if defined(OS_WIN) | 177 #if defined(OS_WIN) |
| 183 // Windows always needs to initialize logging, otherwise you get a renderer | 178 // Windows always needs to initialize logging, otherwise you get a renderer |
| 184 // crash. | 179 // crash. |
| 185 InitLogging(command_line); | 180 InitLogging(command_line); |
| 186 #else | 181 #else |
| 187 if (command_line.HasSwitch(switches::kEnableLogging)) | 182 if (command_line.HasSwitch(switches::kEnableLogging)) |
| 188 InitLogging(command_line); | 183 InitLogging(command_line); |
| 189 #endif // defined(OS_WIN) | 184 #endif |
| 185 #if !defined(OS_MACOSX) |
| 190 InitCrashReporter(command_line); | 186 InitCrashReporter(command_line); |
| 187 #endif |
| 191 InitializeResourceBundle(); | 188 InitializeResourceBundle(); |
| 192 } | 189 } |
| 193 | 190 |
| 194 int HeadlessContentMainDelegate::RunProcess( | 191 int HeadlessContentMainDelegate::RunProcess( |
| 195 const std::string& process_type, | 192 const std::string& process_type, |
| 196 const content::MainFunctionParams& main_function_params) { | 193 const content::MainFunctionParams& main_function_params) { |
| 197 if (!process_type.empty()) | 194 if (!process_type.empty()) |
| 198 return -1; | 195 return -1; |
| 199 | 196 |
| 200 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser"); | 197 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser"); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 return browser_client_.get(); | 277 return browser_client_.get(); |
| 281 } | 278 } |
| 282 | 279 |
| 283 content::ContentRendererClient* | 280 content::ContentRendererClient* |
| 284 HeadlessContentMainDelegate::CreateContentRendererClient() { | 281 HeadlessContentMainDelegate::CreateContentRendererClient() { |
| 285 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); | 282 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); |
| 286 return renderer_client_.get(); | 283 return renderer_client_.get(); |
| 287 } | 284 } |
| 288 | 285 |
| 289 } // namespace headless | 286 } // namespace headless |
| OLD | NEW |