Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: headless/lib/headless_content_main_delegate.cc

Issue 2820453003: Reland Enable crashpad for Mac. (Closed)
Patch Set: Updated upstream Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « headless/lib/headless_browser_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 #include "ui/ozone/public/ozone_switches.h" 29 #include "ui/ozone/public/ozone_switches.h"
30 30
31 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES 31 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES
32 #include "headless/embedded_resource_pak.h" 32 #include "headless/embedded_resource_pak.h"
33 #endif 33 #endif
34 34
35 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 35 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
36 #include "headless/lib/renderer/headless_content_renderer_client.h" 36 #include "headless/lib/renderer/headless_content_renderer_client.h"
37 #endif 37 #endif
38 38
39 #if defined(OS_MACOSX)
40 #include "components/crash/content/app/crashpad.h"
41 #endif
42
39 namespace headless { 43 namespace headless {
40 namespace { 44 namespace {
41 // Keep in sync with content/common/content_constants_internal.h. 45 // Keep in sync with content/common/content_constants_internal.h.
42 // TODO(skyostil): Add a tracing test for this. 46 // TODO(skyostil): Add a tracing test for this.
43 const int kTraceEventBrowserProcessSortIndex = -6; 47 const int kTraceEventBrowserProcessSortIndex = -6;
44 48
45 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; 49 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr;
46 50
47 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client = 51 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client =
48 LAZY_INSTANCE_INITIALIZER; 52 LAZY_INSTANCE_INITIALIZER;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 159 }
156 160
157 void HeadlessContentMainDelegate::InitCrashReporter( 161 void HeadlessContentMainDelegate::InitCrashReporter(
158 const base::CommandLine& command_line) { 162 const base::CommandLine& command_line) {
159 const std::string process_type = 163 const std::string process_type =
160 command_line.GetSwitchValueASCII(switches::kProcessType); 164 command_line.GetSwitchValueASCII(switches::kProcessType);
161 crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer()); 165 crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer());
162 g_headless_crash_client.Pointer()->set_crash_dumps_dir( 166 g_headless_crash_client.Pointer()->set_crash_dumps_dir(
163 browser_->options()->crash_dumps_dir); 167 browser_->options()->crash_dumps_dir);
164 168
165 #if defined(OS_LINUX) 169 #if defined(HEADLESS_USE_BREAKPAD)
166 if (!browser_->options()->enable_crash_reporter) { 170 if (!browser_->options()->enable_crash_reporter) {
167 DCHECK(!breakpad::IsCrashReporterEnabled()); 171 DCHECK(!breakpad::IsCrashReporterEnabled());
168 return; 172 return;
169 } 173 }
170 #if defined(HEADLESS_USE_BREAKPAD)
171 if (process_type != switches::kZygoteProcess) 174 if (process_type != switches::kZygoteProcess)
172 breakpad::InitCrashReporter(process_type); 175 breakpad::InitCrashReporter(process_type);
176 #elif defined(OS_MACOSX)
177 const bool browser_process = process_type.empty();
178 crash_reporter::InitializeCrashpad(browser_process, process_type);
173 #endif // defined(HEADLESS_USE_BREAKPAD) 179 #endif // defined(HEADLESS_USE_BREAKPAD)
174 #endif // !defined(OS_LINUX)
175 } 180 }
176 181
177 void HeadlessContentMainDelegate::PreSandboxStartup() { 182 void HeadlessContentMainDelegate::PreSandboxStartup() {
178 const base::CommandLine& command_line( 183 const base::CommandLine& command_line(
179 *base::CommandLine::ForCurrentProcess()); 184 *base::CommandLine::ForCurrentProcess());
180 #if defined(OS_WIN) 185 #if defined(OS_WIN)
181 // Windows always needs to initialize logging, otherwise you get a renderer 186 // Windows always needs to initialize logging, otherwise you get a renderer
182 // crash. 187 // crash.
183 InitLogging(command_line); 188 InitLogging(command_line);
184 #else 189 #else
185 if (command_line.HasSwitch(switches::kEnableLogging)) 190 if (command_line.HasSwitch(switches::kEnableLogging))
186 InitLogging(command_line); 191 InitLogging(command_line);
187 #endif 192 #endif // defined(OS_WIN)
188 #if !defined(OS_MACOSX)
189 InitCrashReporter(command_line); 193 InitCrashReporter(command_line);
190 #endif
191 InitializeResourceBundle(); 194 InitializeResourceBundle();
192 } 195 }
193 196
194 int HeadlessContentMainDelegate::RunProcess( 197 int HeadlessContentMainDelegate::RunProcess(
195 const std::string& process_type, 198 const std::string& process_type,
196 const content::MainFunctionParams& main_function_params) { 199 const content::MainFunctionParams& main_function_params) {
197 if (!process_type.empty()) 200 if (!process_type.empty())
198 return -1; 201 return -1;
199 202
200 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser"); 203 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser");
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 HeadlessContentMainDelegate::CreateContentRendererClient() { 291 HeadlessContentMainDelegate::CreateContentRendererClient() {
289 #if defined(CHROME_MULTIPLE_DLL_BROWSER) 292 #if defined(CHROME_MULTIPLE_DLL_BROWSER)
290 return nullptr; 293 return nullptr;
291 #else 294 #else
292 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); 295 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>();
293 return renderer_client_.get(); 296 return renderer_client_.get();
294 #endif 297 #endif
295 } 298 }
296 299
297 } // namespace headless 300 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/headless_browser_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698