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

Unified Diff: headless/app/headless_shell.cc

Issue 2832963002: Reland 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/app/headless_shell.h ('k') | headless/app/headless_shell_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/app/headless_shell.cc
diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc
index ff670db059b80d023d289528e3a23b4e870123f2..e12d12c2a3fa3106cf6cb34bec25128cb1de992c 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -18,6 +18,7 @@
#include "base/memory/weak_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
+#include "content/public/app/content_main.h"
#include "headless/app/headless_shell.h"
#include "headless/app/headless_shell_switches.h"
#include "headless/public/headless_devtools_target.h"
@@ -27,6 +28,10 @@
#include "net/base/net_errors.h"
#include "net/http/http_util.h"
#include "ui/gfx/geometry/size.h"
+
+#if defined(OS_WIN)
+#include "sandbox/win/src/sandbox_types.h"
+#endif
namespace headless {
namespace {
@@ -424,10 +429,10 @@
}
void HeadlessShell::OnFileWritten(const base::FilePath file_name,
- const int length,
+ const size_t length,
base::File::Error error_code,
int write_result) {
- if (write_result < length) {
+ if (write_result < static_cast<int>(length)) {
// TODO(eseckler): Support recovering from partial writes.
LOG(ERROR) << "Writing to file " << file_name.value()
<< " was unsuccessful: "
@@ -497,11 +502,20 @@
return true;
}
+#if defined(OS_WIN)
+int HeadlessShellMain(HINSTANCE instance,
+ sandbox::SandboxInterfaceInfo* sandbox_info) {
+ base::CommandLine::Init(0, nullptr);
+ HeadlessBrowser::Options::Builder builder(0, nullptr);
+ builder.SetInstance(instance);
+ builder.SetSandboxInfo(std::move(sandbox_info));
+#else
int HeadlessShellMain(int argc, const char** argv) {
base::CommandLine::Init(argc, argv);
RunChildProcessIfNeeded(argc, argv);
+ HeadlessBrowser::Options::Builder builder(argc, argv);
+#endif // defined(OS_WIN)
HeadlessShell shell;
- HeadlessBrowser::Options::Builder builder(argc, argv);
// Enable devtools if requested.
const base::CommandLine& command_line(
@@ -509,7 +523,7 @@
if (!ValidateCommandLine(command_line))
return EXIT_FAILURE;
- if (command_line.HasSwitch(::switches::kEnableCrashReporter))
+ if (command_line.HasSwitch(switches::kEnableCrashReporter))
builder.SetCrashReporterEnabled(true);
if (command_line.HasSwitch(switches::kCrashDumpsDir)) {
builder.SetCrashDumpsDir(
@@ -597,4 +611,12 @@
base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));
}
+int HeadlessShellMain(const content::ContentMainParams& params) {
+#if defined(OS_WIN)
+ return HeadlessShellMain(params.instance, params.sandbox_info);
+#else
+ return HeadlessShellMain(params.argc, params.argv);
+#endif
+}
+
} // namespace headless
« no previous file with comments | « headless/app/headless_shell.h ('k') | headless/app/headless_shell_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698