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" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "components/crash/content/app/breakpad_linux.h" | 18 #include "components/crash/content/app/breakpad_linux.h" |
19 #include "content/public/browser/browser_main_runner.h" | 19 #include "content/public/browser/browser_main_runner.h" |
20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
21 #include "headless/lib/browser/headless_browser_impl.h" | 21 #include "headless/lib/browser/headless_browser_impl.h" |
22 #include "headless/lib/browser/headless_content_browser_client.h" | 22 #include "headless/lib/browser/headless_content_browser_client.h" |
23 #include "headless/lib/headless_crash_reporter_client.h" | 23 #include "headless/lib/headless_crash_reporter_client.h" |
24 #include "headless/lib/headless_macros.h" | 24 #include "headless/lib/headless_macros.h" |
25 #include "headless/lib/renderer/headless_content_renderer_client.h" | |
26 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/base/ui_base_switches.h" | 26 #include "ui/base/ui_base_switches.h" |
28 #include "ui/gfx/switches.h" | 27 #include "ui/gfx/switches.h" |
29 #include "ui/gl/gl_switches.h" | 28 #include "ui/gl/gl_switches.h" |
30 #include "ui/ozone/public/ozone_switches.h" | 29 #include "ui/ozone/public/ozone_switches.h" |
31 | 30 |
32 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES | 31 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES |
33 #include "headless/embedded_resource_pak.h" | 32 #include "headless/embedded_resource_pak.h" |
34 #endif | 33 #endif |
35 | 34 |
| 35 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 36 #include "headless/lib/renderer/headless_content_renderer_client.h" |
| 37 #endif |
| 38 |
36 namespace headless { | 39 namespace headless { |
37 namespace { | 40 namespace { |
38 // Keep in sync with content/common/content_constants_internal.h. | 41 // Keep in sync with content/common/content_constants_internal.h. |
39 // TODO(skyostil): Add a tracing test for this. | 42 // TODO(skyostil): Add a tracing test for this. |
40 const int kTraceEventBrowserProcessSortIndex = -6; | 43 const int kTraceEventBrowserProcessSortIndex = -6; |
41 | 44 |
42 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; | 45 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; |
43 | 46 |
44 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client = | 47 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client = |
45 LAZY_INSTANCE_INITIALIZER; | 48 LAZY_INSTANCE_INITIALIZER; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 155 } |
153 | 156 |
154 void HeadlessContentMainDelegate::InitCrashReporter( | 157 void HeadlessContentMainDelegate::InitCrashReporter( |
155 const base::CommandLine& command_line) { | 158 const base::CommandLine& command_line) { |
156 const std::string process_type = | 159 const std::string process_type = |
157 command_line.GetSwitchValueASCII(switches::kProcessType); | 160 command_line.GetSwitchValueASCII(switches::kProcessType); |
158 crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer()); | 161 crash_reporter::SetCrashReporterClient(g_headless_crash_client.Pointer()); |
159 g_headless_crash_client.Pointer()->set_crash_dumps_dir( | 162 g_headless_crash_client.Pointer()->set_crash_dumps_dir( |
160 browser_->options()->crash_dumps_dir); | 163 browser_->options()->crash_dumps_dir); |
161 | 164 |
162 #if !defined(OS_MACOSX) | 165 #if defined(OS_LINUX) |
163 if (!browser_->options()->enable_crash_reporter) { | 166 if (!browser_->options()->enable_crash_reporter) { |
164 DCHECK(!breakpad::IsCrashReporterEnabled()); | 167 DCHECK(!breakpad::IsCrashReporterEnabled()); |
165 return; | 168 return; |
166 } | 169 } |
167 #if defined(HEADLESS_USE_BREAKPAD) | 170 #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); |
170 #endif // defined(HEADLESS_USE_BREAKPAD) | 173 #endif // defined(HEADLESS_USE_BREAKPAD) |
171 #endif // !defined(OS_MACOSX) | 174 #endif // !defined(OS_LINUX) |
172 } | 175 } |
173 | 176 |
174 void HeadlessContentMainDelegate::PreSandboxStartup() { | 177 void HeadlessContentMainDelegate::PreSandboxStartup() { |
175 const base::CommandLine& command_line( | 178 const base::CommandLine& command_line( |
176 *base::CommandLine::ForCurrentProcess()); | 179 *base::CommandLine::ForCurrentProcess()); |
177 #if defined(OS_WIN) | 180 #if defined(OS_WIN) |
178 // Windows always needs to initialize logging, otherwise you get a renderer | 181 // Windows always needs to initialize logging, otherwise you get a renderer |
179 // crash. | 182 // crash. |
180 InitLogging(command_line); | 183 InitLogging(command_line); |
181 #else | 184 #else |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (!base::PathExists(pak_file)) | 268 if (!base::PathExists(pak_file)) |
266 pak_file = dir_module.Append(FILE_PATH_LITERAL("Resources/resources.pak")); | 269 pak_file = dir_module.Append(FILE_PATH_LITERAL("Resources/resources.pak")); |
267 #endif | 270 #endif |
268 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 271 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
269 pak_file, ui::SCALE_FACTOR_NONE); | 272 pak_file, ui::SCALE_FACTOR_NONE); |
270 #endif | 273 #endif |
271 } | 274 } |
272 | 275 |
273 content::ContentBrowserClient* | 276 content::ContentBrowserClient* |
274 HeadlessContentMainDelegate::CreateContentBrowserClient() { | 277 HeadlessContentMainDelegate::CreateContentBrowserClient() { |
| 278 #if defined(CHROME_MULTIPLE_DLL_CHILD) |
| 279 return nullptr; |
| 280 #else |
275 browser_client_ = | 281 browser_client_ = |
276 base::MakeUnique<HeadlessContentBrowserClient>(browser_.get()); | 282 base::MakeUnique<HeadlessContentBrowserClient>(browser_.get()); |
277 return browser_client_.get(); | 283 return browser_client_.get(); |
| 284 #endif |
278 } | 285 } |
279 | 286 |
280 content::ContentRendererClient* | 287 content::ContentRendererClient* |
281 HeadlessContentMainDelegate::CreateContentRendererClient() { | 288 HeadlessContentMainDelegate::CreateContentRendererClient() { |
| 289 #if defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 290 return nullptr; |
| 291 #else |
282 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); | 292 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); |
283 return renderer_client_.get(); | 293 return renderer_client_.get(); |
| 294 #endif |
284 } | 295 } |
285 | 296 |
286 } // namespace headless | 297 } // namespace headless |
OLD | NEW |