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