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

Side by Side Diff: gin/shell/gin_main.cc

Issue 76353002: Introduce a Gin class instead of using global functions to control gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/icu_util.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "gin/initialize.h" 11 #include "gin/gin.h"
11 #include "gin/modules/console.h" 12 #include "gin/modules/console.h"
12 #include "gin/modules/module_runner_delegate.h" 13 #include "gin/modules/module_runner_delegate.h"
13 #include "gin/test/file_runner.h" 14 #include "gin/test/file_runner.h"
14 #include "gin/try_catch.h" 15 #include "gin/try_catch.h"
15 16
16 namespace gin { 17 namespace gin {
17 namespace { 18 namespace {
18 19
19 std::string Load(const base::FilePath& path) { 20 std::string Load(const base::FilePath& path) {
20 std::string source; 21 std::string source;
(...skipping 30 matching lines...) Expand all
51 private: 52 private:
52 DISALLOW_COPY_AND_ASSIGN(ShellRunnerDelegate); 53 DISALLOW_COPY_AND_ASSIGN(ShellRunnerDelegate);
53 }; 54 };
54 55
55 } // namespace 56 } // namespace
56 } // namespace gin 57 } // namespace gin
57 58
58 int main(int argc, char** argv) { 59 int main(int argc, char** argv) {
59 base::AtExitManager at_exit; 60 base::AtExitManager at_exit;
60 CommandLine::Init(argc, argv); 61 CommandLine::Init(argc, argv);
61 gin::Initialize(); 62 base::i18n::InitializeICU();
63
64 gin::Gin instance;
62 65
63 base::MessageLoop message_loop; 66 base::MessageLoop message_loop;
64 67
65 gin::ShellRunnerDelegate delegate; 68 gin::ShellRunnerDelegate delegate;
66 gin::Runner runner(&delegate, v8::Isolate::GetCurrent()); 69 gin::Runner runner(&delegate, instance.isolate());
67 70
68 CommandLine::StringVector args = CommandLine::ForCurrentProcess()->GetArgs(); 71 CommandLine::StringVector args = CommandLine::ForCurrentProcess()->GetArgs();
69 for (CommandLine::StringVector::const_iterator it = args.begin(); 72 for (CommandLine::StringVector::const_iterator it = args.begin();
70 it != args.end(); ++it) { 73 it != args.end(); ++it) {
71 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 74 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
72 gin::Run, runner.GetWeakPtr(), gin::Load(base::FilePath(*it)))); 75 gin::Run, runner.GetWeakPtr(), gin::Load(base::FilePath(*it))));
73 } 76 }
74 77
75 message_loop.RunUntilIdle(); 78 message_loop.RunUntilIdle();
76 return 0; 79 return 0;
77 } 80 }
OLDNEW
« no previous file with comments | « gin/runner_unittest.cc ('k') | gin/test/file_runner.cc » ('j') | gin/test/file_runner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698