Skip to content

Commit afc6f8a

Browse files
skyostilCommit bot
authored and
Commit bot
committed
Revert of Implement a runtime headless mode for Linux (patchset #20 id:380001 of https://codereview.chromium.org/1991953002/ )
Reason for revert: Unexpectedly added a couple of new static initializers: https://uberchromegw.corp.google.com/i/chromium/builders/Linux%20x64/builds/29946 Original issue's description: > Implement a runtime headless mode for Linux > > This patch implements a runtime headless mode (i.e., a > --headless command line switch) that makes it possible to > use a regular Chrome binary as a headless. When the binary > is launched with this switch, the main entrypoint calls > into the Headless Shell entrypoint, effectively starting > that shell instead of Chrome. > > To make this possible we must remove the dependency from > Headless to Ozone, because Ozone is a build-time feature > which is generally not enabled for regular Chrome builds. > In practice this means implementing a new headless-specific > WindowTreeHost and modifying various graphics and input > entrypoints to do something appropriate in headless mode. > > Since many of the modifications are in platform-specific > code, this initial patch only adds headless support in Linux. > Other platforms will be added later. > > Design doc: https://docs.google.com/document/d/1aIJUzQr3eougZQp90bp4mqGr5gY6hdUice8UPa-Ys90/edit# > > BUG=612904 > CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel > > Committed: https://crrev.com/eb0f3b0218478f30858dfa2078cb350ea259701f > Cr-Commit-Position: refs/heads/master@{#438152} TBR=jochen@chromium.org,eseckler@chromium.org,sky@chromium.org,zmo@chromium.org,vmiura@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=612904 Review-Url: https://codereview.chromium.org/2570873002 Cr-Commit-Position: refs/heads/master@{#438177}
1 parent 047b36f commit afc6f8a

29 files changed

+132
-276
lines changed

chrome/BUILD.gn

-3
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ if (!is_android && !is_mac) {
239239
# Needed to use the master_preferences functions
240240
"//chrome/installer/util:with_no_strings",
241241
"//content/public/app:both",
242-
243-
# For headless mode.
244-
"//headless:headless_shell_lib",
245242
]
246243
if (enable_plugins && enable_pdf) {
247244
deps += [ "//pdf" ]

chrome/app/DEPS

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ include_rules = [
2929
"+content/public/app",
3030
"+content/public/browser/browser_main_runner.h",
3131
"+extensions/common/constants.h",
32-
"+headless/public", # For headless mode.
3332
"+native_client/src/trusted/service_runtime/osx",
3433
"+remoting/client/plugin",
3534
"+sandbox",

chrome/app/chrome_main.cc

+5-13
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@
55
#include <stdint.h>
66

77
#include "build/build_config.h"
8-
#include "base/command_line.h"
98
#include "base/time/time.h"
109
#include "chrome/app/chrome_main_delegate.h"
1110
#include "chrome/common/features.h"
1211
#include "content/public/app/content_main.h"
13-
#include "content/public/common/content_switches.h"
14-
#include "headless/public/headless_shell.h"
15-
#include "ui/gfx/switches.h"
1612

1713
#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
14+
#include "base/command_line.h"
1815
#include "chrome/app/mash/mash_runner.h"
1916
#include "chrome/common/channel_info.h"
2017
#include "components/version_info/version_info.h"
@@ -85,22 +82,17 @@ int ChromeMain(int argc, const char** argv) {
8582
params.argv = argv;
8683
#endif
8784

85+
#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
8886
#if !defined(OS_WIN)
8987
base::CommandLine::Init(params.argc, params.argv);
90-
const base::CommandLine* command_line(base::CommandLine::ForCurrentProcess());
91-
ALLOW_UNUSED_LOCAL(command_line);
9288
#endif
9389

94-
#if defined(OS_LINUX)
95-
if (command_line->HasSwitch(switches::kHeadless))
96-
return headless::HeadlessShellMain(argc, argv);
97-
#endif // defined(OS_LINUX)
98-
99-
#if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
10090
version_info::Channel channel = chrome::GetChannel();
10191
if (channel == version_info::Channel::CANARY ||
10292
channel == version_info::Channel::UNKNOWN) {
103-
if (command_line->HasSwitch("mash"))
93+
const base::CommandLine& command_line =
94+
*base::CommandLine::ForCurrentProcess();
95+
if (command_line.HasSwitch("mash"))
10496
return MashMain();
10597
WaitForMashDebuggerIfNecessary();
10698
}

content/browser/browser_main_loop.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
#include "skia/ext/skia_memory_dump_provider.h"
106106
#include "sql/sql_memory_dump_provider.h"
107107
#include "ui/base/clipboard/clipboard.h"
108-
#include "ui/gfx/switches.h"
109108

110109
#if defined(USE_AURA) || defined(OS_MACOSX)
111110
#include "content/browser/compositor/image_transport_factory.h"
@@ -464,8 +463,6 @@ class GpuDataManagerVisualProxy : public GpuDataManagerObserver {
464463
}
465464

466465
void OnGpuInfoUpdate() override {
467-
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
468-
return;
469466
gpu::GPUInfo gpu_info = gpu_data_manager_->GetGPUInfo();
470467
if (!ui::XVisualManager::GetInstance()->OnGPUInfoChanged(
471468
gpu_info.software_rendering ||
@@ -1572,8 +1569,7 @@ bool BrowserMainLoop::InitializeToolkit() {
15721569
#if defined(USE_AURA)
15731570

15741571
#if defined(USE_X11)
1575-
if (!parsed_command_line_.HasSwitch(switches::kHeadless) &&
1576-
!gfx::GetXDisplay()) {
1572+
if (!gfx::GetXDisplay()) {
15771573
LOG(ERROR) << "Unable to open X display.";
15781574
return false;
15791575
}

content/browser/compositor/gpu_process_transport_factory.cc

-9
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#include "ui/compositor/layer.h"
5656
#include "ui/display/types/display_snapshot.h"
5757
#include "ui/gfx/geometry/size.h"
58-
#include "ui/gfx/switches.h"
5958

6059
#if defined(USE_AURA)
6160
#include "content/browser/compositor/mus_browser_compositor_output_surface.h"
@@ -197,10 +196,6 @@ GpuProcessTransportFactory::~GpuProcessTransportFactory() {
197196
std::unique_ptr<cc::SoftwareOutputDevice>
198197
GpuProcessTransportFactory::CreateSoftwareOutputDevice(
199198
ui::Compositor* compositor) {
200-
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
201-
if (command_line->HasSwitch(switches::kHeadless))
202-
return base::WrapUnique(new cc::SoftwareOutputDevice);
203-
204199
#if defined(USE_AURA)
205200
if (service_manager::ServiceManagerIsRemote()) {
206201
NOTREACHED();
@@ -265,10 +260,6 @@ CreateOverlayCandidateValidator(gfx::AcceleratedWidget widget) {
265260
}
266261

267262
static bool ShouldCreateGpuCompositorFrameSink(ui::Compositor* compositor) {
268-
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
269-
if (command_line->HasSwitch(switches::kHeadless))
270-
return false;
271-
272263
#if defined(OS_CHROMEOS)
273264
// Software fallback does not happen on Chrome OS.
274265
return true;

content/browser/gpu/gpu_process_host.cc

-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#include "services/service_manager/runner/common/client_util.h"
7070
#include "ui/base/ui_base_switches.h"
7171
#include "ui/events/latency_info.h"
72-
#include "ui/gfx/switches.h"
7372
#include "ui/gl/gl_switches.h"
7473

7574
#if defined(OS_ANDROID)
@@ -136,7 +135,6 @@ static const char* const kSwitchNames[] = {
136135
switches::kGpuSandboxAllowSysVShm,
137136
switches::kGpuSandboxFailuresFatal,
138137
switches::kGpuSandboxStartEarly,
139-
switches::kHeadless,
140138
switches::kLoggingLevel,
141139
switches::kEnableLowEndDeviceMode,
142140
switches::kDisableLowEndDeviceMode,

content/browser/zygote_host/zygote_communication_linux.cc

-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "content/public/common/content_switches.h"
2424
#include "content/public/common/result_codes.h"
2525
#include "ui/display/display_switches.h"
26-
#include "ui/gfx/switches.h"
2726

2827
namespace content {
2928

@@ -253,9 +252,6 @@ void ZygoteCommunication::Init() {
253252
switches::kDisableSeccompFilterSandbox,
254253
switches::kEnableHeapProfiling,
255254
switches::kEnableLogging, // Support, e.g., --enable-logging=stderr.
256-
// Need to tell the zygote that it is headless so that we don't try to use
257-
// the wrong type of main delegate.
258-
switches::kHeadless,
259255
// Zygote process needs to know what resources to have loaded when it
260256
// becomes a renderer process.
261257
switches::kForceDeviceScaleFactor, switches::kLoggingLevel,

content/gpu/gpu_main.cc

+20-25
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
4141
#include "gpu/ipc/service/gpu_watchdog_thread.h"
4242
#include "ui/events/platform/platform_event_source.h"
43-
#include "ui/gfx/switches.h"
4443
#include "ui/gl/gl_context.h"
4544
#include "ui/gl/gl_implementation.h"
4645
#include "ui/gl/gl_surface.h"
@@ -201,39 +200,35 @@ int GpuMain(const MainFunctionParams& parameters) {
201200
// TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802
202201
// and crbug.com/609252.
203202
std::unique_ptr<base::MessageLoop> main_message_loop;
204-
if (command_line.HasSwitch(switches::kHeadless)) {
205-
main_message_loop.reset(
206-
new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT));
207-
} else {
203+
208204
#if defined(OS_WIN)
209-
// OK to use default non-UI message loop because all GPU windows run on
210-
// dedicated thread.
211-
main_message_loop.reset(
212-
new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT));
205+
// OK to use default non-UI message loop because all GPU windows run on
206+
// dedicated thread.
207+
main_message_loop.reset(
208+
new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT));
213209
#elif defined(USE_X11)
214-
// We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX
215-
// and https://crbug.com/326995.
216-
main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
217-
std::unique_ptr<ui::PlatformEventSource> event_source =
218-
ui::PlatformEventSource::CreateDefault();
210+
// We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX
211+
// and https://crbug.com/326995.
212+
main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
213+
std::unique_ptr<ui::PlatformEventSource> event_source =
214+
ui::PlatformEventSource::CreateDefault();
219215
#elif defined(USE_OZONE) && defined(OZONE_X11)
220-
// If we might be running Ozone X11 we need a UI loop to grab Expose events.
221-
// See GLSurfaceGLX and https://crbug.com/326995.
222-
main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
216+
// If we might be running Ozone X11 we need a UI loop to grab Expose events.
217+
// See GLSurfaceGLX and https://crbug.com/326995.
218+
main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
223219
#elif defined(USE_OZONE)
224-
main_message_loop.reset(
225-
new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT));
220+
main_message_loop.reset(
221+
new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT));
226222
#elif defined(OS_LINUX)
227223
#error "Unsupported Linux platform."
228224
#elif defined(OS_MACOSX)
229-
// This is necessary for CoreAnimation layers hosted in the GPU process to
230-
// be drawn. See http://crbug.com/312462.
231-
std::unique_ptr<base::MessagePump> pump(new base::MessagePumpCFRunLoop());
232-
main_message_loop.reset(new base::MessageLoop(std::move(pump)));
225+
// This is necessary for CoreAnimation layers hosted in the GPU process to be
226+
// drawn. See http://crbug.com/312462.
227+
std::unique_ptr<base::MessagePump> pump(new base::MessagePumpCFRunLoop());
228+
main_message_loop.reset(new base::MessageLoop(std::move(pump)));
233229
#else
234-
main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO));
230+
main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO));
235231
#endif
236-
}
237232

238233
base::PlatformThread::SetName("CrGpuMain");
239234

gpu/ipc/service/gpu_init.cc

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "gpu/config/gpu_util.h"
1818
#include "gpu/ipc/service/gpu_watchdog_thread.h"
1919
#include "gpu/ipc/service/switches.h"
20-
#include "ui/gfx/switches.h"
2120
#include "ui/gl/gl_implementation.h"
2221
#include "ui/gl/gl_switches.h"
2322
#include "ui/gl/init/gl_factory.h"
@@ -128,7 +127,6 @@ bool GpuInit::InitializeAndStartSandbox(const base::CommandLine& command_line) {
128127
// to run slowly in that case.
129128
bool enable_watchdog =
130129
!command_line.HasSwitch(switches::kDisableGpuWatchdog) &&
131-
!command_line.HasSwitch(switches::kHeadless) &&
132130
!RunningOnValgrind();
133131

134132
// Disable the watchdog in debug builds because they tend to only be run by

headless/BUILD.gn

+8-9
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ static_library("headless_lib") {
167167
"lib/browser/headless_devtools_client_impl.h",
168168
"lib/browser/headless_devtools_manager_delegate.cc",
169169
"lib/browser/headless_devtools_manager_delegate.h",
170-
"lib/browser/headless_platform_event_source.cc",
171-
"lib/browser/headless_platform_event_source.h",
172170
"lib/browser/headless_screen.cc",
173171
"lib/browser/headless_screen.h",
174172
"lib/browser/headless_url_request_context_getter.cc",
@@ -177,12 +175,14 @@ static_library("headless_lib") {
177175
"lib/browser/headless_web_contents_impl.h",
178176
"lib/browser/headless_window_parenting_client.cc",
179177
"lib/browser/headless_window_parenting_client.h",
180-
"lib/browser/headless_window_tree_host.cc",
181-
"lib/browser/headless_window_tree_host.h",
182178
"lib/headless_content_client.cc",
183179
"lib/headless_content_client.h",
184180
"lib/headless_content_main_delegate.cc",
185181
"lib/headless_content_main_delegate.h",
182+
"lib/renderer/headless_content_renderer_client.cc",
183+
"lib/renderer/headless_content_renderer_client.h",
184+
"lib/utility/headless_content_utility_client.cc",
185+
"lib/utility/headless_content_utility_client.h",
186186
"public/headless_browser.cc",
187187
"public/headless_browser.h",
188188
"public/headless_browser_context.h",
@@ -232,23 +232,22 @@ static_library("headless_lib") {
232232
"//components/security_state/core",
233233
"//content/public/app:both",
234234
"//content/public/browser",
235+
"//content/public/child",
235236
"//content/public/common",
236237
"//content/public/common:service_names",
238+
"//content/public/renderer",
239+
"//content/public/utility",
237240
"//net",
238241
"//services/service_manager/public/cpp",
239242
"//third_party/mesa:osmesa",
240243
"//ui/aura",
241244
"//ui/base",
242245
"//ui/compositor",
243246
"//ui/display",
244-
"//ui/events/devices",
247+
"//ui/ozone",
245248
"//url",
246249
]
247250

248-
if (use_ozone) {
249-
deps += [ "//ui/ozone" ]
250-
}
251-
252251
configs += [ ":headless_implementation" ]
253252
}
254253

headless/DEPS

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
include_rules = [
2-
"+content/public/app",
3-
"+content/public/browser",
4-
"+content/public/common",
5-
"+content/public/test",
2+
"+content/public",
63
"+mojo/public",
74
"+net",
85
"+ui/base",
96
"+ui/base/resource",
107
"+ui/display",
11-
"+ui/events/devices",
12-
"+ui/events/platform",
138
"+ui/gfx",
149
"+ui/gfx/geometry",
1510
"+ui/gl",

headless/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ web pages. Its main classes are:
6969

7070
## Documentation
7171

72-
* [Runtime headless mode for Chrome](https://docs.google.com/document/d/1aIJUzQr3eougZQp90bp4mqGr5gY6hdUice8UPa-Ys90/edit#)
7372
* [Virtual Time in Blink](https://docs.google.com/document/d/1y9kdt_zezt7pbey6uzvt1dgklwc1ob_vy4nzo1zbqmo/edit#heading=h.tn3gd1y9ifml)
7473
* [Headless Chrome architecture](https://docs.google.com/document/d/11zIkKkLBocofGgoTeeyibB2TZ_k7nR78v7kNelCatUE/edit)
7574
* [Headless Chrome C++ DevTools API](https://docs.google.com/document/d/1rlqcp8nk-ZQvldNJWdbaMbwfDbJoOXvahPCDoPGOwhQ/edit#heading=h.ng2bxb15li9a)

headless/lib/browser/headless_browser_impl.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
#include "headless/lib/browser/headless_browser_main_parts.h"
2020
#include "headless/lib/browser/headless_web_contents_impl.h"
2121
#include "headless/lib/browser/headless_window_parenting_client.h"
22-
#include "headless/lib/browser/headless_window_tree_host.h"
2322
#include "headless/lib/headless_content_main_delegate.h"
2423
#include "ui/aura/env.h"
25-
#include "ui/events/devices/device_data_manager.h"
24+
#include "ui/aura/window_tree_host.h"
2625
#include "ui/gfx/geometry/size.h"
2726

2827
namespace headless {
@@ -120,10 +119,8 @@ void HeadlessBrowserImpl::set_browser_main_parts(
120119

121120
void HeadlessBrowserImpl::RunOnStartCallback() {
122121
DCHECK(aura::Env::GetInstance());
123-
ui::DeviceDataManager::CreateInstance();
124-
125122
window_tree_host_.reset(
126-
new HeadlessWindowTreeHost(gfx::Rect(options()->window_size)));
123+
aura::WindowTreeHost::Create(gfx::Rect(options()->window_size)));
127124
window_tree_host_->InitHost();
128125

129126
window_parenting_client_.reset(

headless/lib/browser/headless_platform_event_source.cc

-13
This file was deleted.

headless/lib/browser/headless_platform_event_source.h

-26
This file was deleted.

headless/lib/browser/headless_web_contents_impl.cc

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "content/public/browser/web_contents_delegate.h"
2727
#include "content/public/common/bindings_policy.h"
2828
#include "content/public/common/origin_util.h"
29+
#include "content/public/renderer/render_frame.h"
2930
#include "headless/lib/browser/headless_browser_context_impl.h"
3031
#include "headless/lib/browser/headless_browser_impl.h"
3132
#include "headless/lib/browser/headless_browser_main_parts.h"

0 commit comments

Comments
 (0)