| Index: sky/shell/linux/main.cc
|
| diff --git a/sky/shell/linux/main.cc b/sky/shell/linux/main.cc
|
| index 56fd84f5ae306e3510adf74ae1182c65802ac9e0..b40223d582d6901c199001e091642ae33c6bc8f6 100644
|
| --- a/sky/shell/linux/main.cc
|
| +++ b/sky/shell/linux/main.cc
|
| @@ -2,23 +2,37 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <iostream>
|
| +
|
| #include "base/at_exit.h"
|
| #include "base/basictypes.h"
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| +#include "base/files/file_path.h"
|
| #include "base/i18n/icu_util.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "base/threading/worker_pool.h"
|
| +#include "mojo/common/data_pipe_utils.h"
|
| #include "sky/shell/platform_view.h"
|
| #include "sky/shell/service_provider.h"
|
| #include "sky/shell/shell.h"
|
| #include "sky/shell/shell_view.h"
|
| +#include "sky/shell/switches.h"
|
|
|
| namespace sky {
|
| namespace shell {
|
| +namespace {
|
| +
|
| +void Ignored(bool) {
|
| +}
|
|
|
| -const char kMain[] = "main";
|
| -const char kPackageRoot[] = "package-root";
|
| +void Usage() {
|
| + std::cerr << "Usage: sky_shell"
|
| + << " [--" << switches::kPackageRoot << "]"
|
| + << " [--" << switches::kSnapshot << "]"
|
| + << " <sky-app>" << std::endl;
|
| +}
|
|
|
| void Init() {
|
| Shell::Init(make_scoped_ptr(new ServiceProviderContext(
|
| @@ -32,12 +46,31 @@ void Init() {
|
|
|
| base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
|
|
|
| - std::string main = command_line.GetSwitchValueASCII(kMain);
|
| - std::string package_root = command_line.GetSwitchValueASCII(kPackageRoot);
|
| + std::string main = command_line.GetArgs()[0];
|
| + if (command_line.HasSwitch(switches::kSnapshot)) {
|
| + base::FilePath snapshot =
|
| + command_line.GetSwitchValuePath(switches::kSnapshot);
|
| + mojo::DataPipe pipe;
|
| + viewport_observer->RunFromSnapshot(main, pipe.consumer_handle.Pass());
|
| + scoped_refptr<base::TaskRunner> runner =
|
| + base::WorkerPool::GetTaskRunner(true);
|
| + mojo::common::CopyFromFile(snapshot, pipe.producer_handle.Pass(), 0,
|
| + runner.get(), base::Bind(&Ignored));
|
| + return;
|
| + }
|
|
|
| - viewport_observer->RunFromFile(main, package_root);
|
| + if (command_line.HasSwitch(switches::kPackageRoot)) {
|
| + std::string package_root =
|
| + command_line.GetSwitchValueASCII(switches::kPackageRoot);
|
| + viewport_observer->RunFromFile(main, package_root);
|
| + return;
|
| + }
|
| +
|
| + std::cerr << "One of --" << switches::kPackageRoot << " or --"
|
| + << switches::kSnapshot << " is required." << std::endl;
|
| }
|
|
|
| +} // namespace
|
| } // namespace shell
|
| } // namespace sky
|
|
|
| @@ -45,6 +78,14 @@ int main(int argc, const char* argv[]) {
|
| base::AtExitManager exit_manager;
|
| base::CommandLine::Init(argc, argv);
|
|
|
| + base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
|
| +
|
| + if (command_line.HasSwitch(sky::shell::switches::kHelp) ||
|
| + command_line.GetArgs().empty()) {
|
| + sky::shell::Usage();
|
| + return 0;
|
| + }
|
| +
|
| base::MessageLoop message_loop;
|
|
|
| base::i18n::InitializeICU();
|
|
|