Commit e9afd2b4 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Add top-level webrunner directory and webrunner skeleton.

WebRunner will be used on Fuchsia to run web applications.

Bug: 822474
Change-Id: I56b2fd4bf653bb2c77a013b3134f6dba8065289a
Reviewed-on: https://chromium-review.googlesource.com/965255Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarBen Goodger <ben@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547039}
parent 119d837b
...@@ -742,6 +742,7 @@ group("gn_all") { ...@@ -742,6 +742,7 @@ group("gn_all") {
"//headless", "//headless",
"//headless:headless_shell", "//headless:headless_shell",
"//headless:headless_tests", "//headless:headless_tests",
"//webrunner",
] ]
} }
} }
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_fuchsia)
import("//build/config/fuchsia/rules.gni")
executable("webrunner") {
public_deps = [
"//content/public/app:both",
"//content/public/browser",
"//content/public/child",
"//content/public/common",
"//content/public/renderer",
]
sources = [
"app/webrunner_main.cc",
"app/webrunner_main_delegate.cc",
"app/webrunner_main_delegate.h",
"browser/webrunner_browser_main.cc",
"browser/webrunner_browser_main.h",
]
}
fuchsia_executable_runner("webrunner_fuchsia") {
exe_target = ":webrunner"
}
include_rules = [
"+content/public/common",
]
\ No newline at end of file
file://build/fuchsia/OWNERS
This directory contains WebRunner implementation. WebRunner allows to run
web applications on Fuchsia.
\ No newline at end of file
include_rules = [
"+content/public/app",
"+ui/base",
]
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/app/content_main.h"
#include "webrunner/app/webrunner_main_delegate.h"
int main(int argc, const char** argv) {
webrunner::WebRunnerMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
return content::ContentMain(params);
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webrunner/app/webrunner_main_delegate.h"
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/path_service.h"
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
#include "webrunner/browser/webrunner_browser_main.h"
namespace webrunner {
namespace {
void InitLoggingFromCommandLine(const base::CommandLine& command_line) {
base::FilePath log_filename;
std::string filename = command_line.GetSwitchValueASCII(switches::kLogFile);
if (filename.empty()) {
PathService::Get(base::DIR_EXE, &log_filename);
log_filename = log_filename.AppendASCII("webrunner.log");
} else {
log_filename = base::FilePath::FromUTF8Unsafe(filename);
}
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_ALL;
settings.log_file = log_filename.value().c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::SetLogItems(true /* Process ID */, true /* Thread ID */,
true /* Timestamp */, false /* Tick count */);
}
void InitializeResourceBundle() {
base::FilePath pak_file;
bool result = base::PathService::Get(base::DIR_ASSETS, &pak_file);
DCHECK(result);
pak_file = pak_file.Append(FILE_PATH_LITERAL("webrunner.pak"));
ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
}
} // namespace
WebRunnerMainDelegate::WebRunnerMainDelegate() = default;
WebRunnerMainDelegate::~WebRunnerMainDelegate() = default;
bool WebRunnerMainDelegate::BasicStartupComplete(int* exit_code) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
InitLoggingFromCommandLine(*command_line);
return false;
}
void WebRunnerMainDelegate::PreSandboxStartup() {
InitializeResourceBundle();
}
int WebRunnerMainDelegate::RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) {
if (!process_type.empty())
return -1;
return WebRunnerBrowserMain(main_function_params);
}
} // namespace webrunner
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBRUNNER_APP_WEBRUNNER_MAIN_DELEGATE_H_
#define WEBRUNNER_APP_WEBRUNNER_MAIN_DELEGATE_H_
#include <memory>
#include "base/macros.h"
#include "content/public/app/content_main_delegate.h"
namespace webrunner {
class WebRunnerMainDelegate : public content::ContentMainDelegate {
public:
WebRunnerMainDelegate();
~WebRunnerMainDelegate() override;
// ContentMainDelegate implementation.
bool BasicStartupComplete(int* exit_code) override;
void PreSandboxStartup() override;
int RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) override;
private:
DISALLOW_COPY_AND_ASSIGN(WebRunnerMainDelegate);
};
} // namespace webrunner
#endif // WEBRUNNER_APP_WEBRUNNER_MAIN_DELEGATE_H_
include_rules = [
"+content/public/browser",
]
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webrunner/browser/webrunner_browser_main.h"
#include <memory>
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "build/build_config.h"
#include "content/public/browser/browser_main_runner.h"
namespace webrunner {
int WebRunnerBrowserMain(const content::MainFunctionParams& parameters) {
std::unique_ptr<content::BrowserMainRunner> main_runner(
content::BrowserMainRunner::Create());
int exit_code = main_runner->Initialize(parameters);
if (exit_code >= 0)
return exit_code;
exit_code = main_runner->Run();
main_runner->Shutdown();
return exit_code;
}
} // namespace webrunner
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBRUNNER_BROWSER_WEBRUNNER_BROWSER_MAIN_H_
#define WEBRUNNER_BROWSER_WEBRUNNER_BROWSER_MAIN_H_
#include <memory>
namespace content {
struct MainFunctionParams;
} // namespace content
namespace webrunner {
int WebRunnerBrowserMain(const content::MainFunctionParams& parameters);
} // namespace webrunner
#endif // WEBRUNNER_BROWSER_WEBRUNNER_BROWSER_MAIN_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment