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

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

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

Powered by Google App Engine
This is Rietveld 408576698