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

Side by Side Diff: sky/shell/linux/main.cc

Issue 1229743002: Teach sky_shell.exe to run from a snapshot (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/mojo/net/fetch.dart ('k') | sky/shell/testing/test_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <iostream> 5 #include <iostream>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/icu_util.h" 11 #include "base/i18n/icu_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "sky/engine/public/web/WebRuntimeFeatures.h" 14 #include "sky/engine/public/web/WebRuntimeFeatures.h"
15 #include "sky/shell/platform_view.h" 15 #include "sky/shell/platform_view.h"
16 #include "sky/shell/service_provider.h" 16 #include "sky/shell/service_provider.h"
17 #include "sky/shell/shell.h" 17 #include "sky/shell/shell.h"
18 #include "sky/shell/shell_view.h" 18 #include "sky/shell/shell_view.h"
19 #include "sky/shell/switches.h" 19 #include "sky/shell/switches.h"
20 #include "sky/shell/testing/test_runner.h" 20 #include "sky/shell/testing/test_runner.h"
21 21
22 namespace sky { 22 namespace sky {
23 namespace shell { 23 namespace shell {
24 namespace { 24 namespace {
25 25
26 void Usage() { 26 void Usage() {
27 std::cerr << "Usage: sky_shell" 27 std::cerr << "Usage: sky_shell"
28 << " --" << switches::kNonInteractive 28 << " --" << switches::kNonInteractive
29 << " --" << switches::kPackageRoot << "=PACKAGE_ROOT" 29 << " --" << switches::kPackageRoot << "=PACKAGE_ROOT"
30 << " --" << switches::kSnapshot << "=SNAPSHOT"
30 << " [ MAIN_DART ]" << std::endl; 31 << " [ MAIN_DART ]" << std::endl;
31 } 32 }
32 33
33 void Init() { 34 void Init() {
34 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); 35 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
35 blink::WebRuntimeFeatures::enableObservatory( 36 blink::WebRuntimeFeatures::enableObservatory(
36 !command_line.HasSwitch(switches::kNonInteractive)); 37 !command_line.HasSwitch(switches::kNonInteractive));
37 38
38 Shell::Init(make_scoped_ptr(new ServiceProviderContext( 39 Shell::Init(make_scoped_ptr(new ServiceProviderContext(
39 base::MessageLoop::current()->task_runner()))); 40 base::MessageLoop::current()->task_runner())));
40 // Explicitly boot the shared test runner. 41 // Explicitly boot the shared test runner.
41 TestRunner& runner = TestRunner::Shared(); 42 TestRunner& runner = TestRunner::Shared();
42 43
43 std::string package_root = 44 std::string package_root =
44 command_line.GetSwitchValueASCII(switches::kPackageRoot); 45 command_line.GetSwitchValueASCII(switches::kPackageRoot);
46 runner.set_package_root(package_root);
45 47
46 std::string main; 48 scoped_ptr<TestRunner::SingleTest> single_test;
47 auto args = command_line.GetArgs(); 49 if (command_line.HasSwitch(switches::kSnapshot)) {
48 if (!args.empty()) 50 single_test.reset(new TestRunner::SingleTest);
49 main = args[0]; 51 single_test->path = command_line.GetSwitchValueASCII(switches::kSnapshot);
52 single_test->is_snapshot = true;
53 } else {
54 auto args = command_line.GetArgs();
55 if (!args.empty()) {
56 single_test.reset(new TestRunner::SingleTest);
57 single_test->path = args[0];
58 }
59 }
50 60
51 runner.set_package_root(package_root); 61 runner.Start(single_test.Pass());
52 runner.Start(main);
53 } 62 }
54 63
55 } // namespace 64 } // namespace
56 } // namespace shell 65 } // namespace shell
57 } // namespace sky 66 } // namespace sky
58 67
59 int main(int argc, const char* argv[]) { 68 int main(int argc, const char* argv[]) {
60 base::AtExitManager exit_manager; 69 base::AtExitManager exit_manager;
61 base::CommandLine::Init(argc, argv); 70 base::CommandLine::Init(argc, argv);
62 71
63 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); 72 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
64 73
65 if (command_line.HasSwitch(sky::shell::switches::kHelp) || 74 if (command_line.HasSwitch(sky::shell::switches::kHelp) ||
66 !command_line.HasSwitch(sky::shell::switches::kPackageRoot)) { 75 (!command_line.HasSwitch(sky::shell::switches::kPackageRoot) &&
76 !command_line.HasSwitch(sky::shell::switches::kSnapshot))) {
67 sky::shell::Usage(); 77 sky::shell::Usage();
68 return 0; 78 return 0;
69 } 79 }
70 80
71 base::MessageLoop message_loop; 81 base::MessageLoop message_loop;
72 82
73 base::i18n::InitializeICU(); 83 base::i18n::InitializeICU();
74 84
75 message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init)); 85 message_loop.PostTask(FROM_HERE, base::Bind(&sky::shell::Init));
76 message_loop.Run(); 86 message_loop.Run();
77 87
78 return 0; 88 return 0;
79 } 89 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/mojo/net/fetch.dart ('k') | sky/shell/testing/test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698