| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 HeadlessContentMainDelegate::~HeadlessContentMainDelegate() { | 37 HeadlessContentMainDelegate::~HeadlessContentMainDelegate() { |
| 38 DCHECK(g_current_headless_content_main_delegate == this); | 38 DCHECK(g_current_headless_content_main_delegate == this); |
| 39 g_current_headless_content_main_delegate = nullptr; | 39 g_current_headless_content_main_delegate = nullptr; |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool HeadlessContentMainDelegate::BasicStartupComplete(int* exit_code) { | 42 bool HeadlessContentMainDelegate::BasicStartupComplete(int* exit_code) { |
| 43 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 43 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 44 | 44 |
| 45 // Make sure all processes know that we're in headless mode. |
| 46 if (!command_line->HasSwitch(switches::kHeadless)) |
| 47 command_line->AppendSwitch(switches::kHeadless); |
| 48 |
| 45 if (browser_->options()->single_process_mode) | 49 if (browser_->options()->single_process_mode) |
| 46 command_line->AppendSwitch(switches::kSingleProcess); | 50 command_line->AppendSwitch(switches::kSingleProcess); |
| 47 | 51 |
| 48 if (browser_->options()->disable_sandbox) | 52 if (browser_->options()->disable_sandbox) |
| 49 command_line->AppendSwitch(switches::kNoSandbox); | 53 command_line->AppendSwitch(switches::kNoSandbox); |
| 50 | 54 |
| 51 // The headless backend is automatically chosen for a headless build, but also | |
| 52 // adding it here allows us to run in a non-headless build too. | |
| 53 command_line->AppendSwitchASCII(switches::kOzonePlatform, "headless"); | |
| 54 | |
| 55 if (!browser_->options()->gl_implementation.empty()) { | 55 if (!browser_->options()->gl_implementation.empty()) { |
| 56 command_line->AppendSwitchASCII(switches::kUseGL, | 56 command_line->AppendSwitchASCII(switches::kUseGL, |
| 57 browser_->options()->gl_implementation); | 57 browser_->options()->gl_implementation); |
| 58 } else { | 58 } else { |
| 59 command_line->AppendSwitch(switches::kDisableGpu); | 59 command_line->AppendSwitch(switches::kDisableGpu); |
| 60 } | 60 } |
| 61 | 61 |
| 62 SetContentClient(&content_client_); | 62 SetContentClient(&content_client_); |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return renderer_client_.get(); | 123 return renderer_client_.get(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 content::ContentUtilityClient* | 126 content::ContentUtilityClient* |
| 127 HeadlessContentMainDelegate::CreateContentUtilityClient() { | 127 HeadlessContentMainDelegate::CreateContentUtilityClient() { |
| 128 utility_client_.reset(new HeadlessContentUtilityClient); | 128 utility_client_.reset(new HeadlessContentUtilityClient); |
| 129 return utility_client_.get(); | 129 return utility_client_.get(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace headless | 132 } // namespace headless |
| OLD | NEW |