OLD | NEW |
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/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/i18n/icu_util.h" | 9 #include "base/i18n/icu_util.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "gin/array_buffer.h" | 11 #include "gin/array_buffer.h" |
12 #include "gin/modules/console.h" | 12 #include "gin/modules/console.h" |
13 #include "gin/modules/module_runner_delegate.h" | 13 #include "gin/modules/module_runner_delegate.h" |
14 #include "gin/public/isolate_holder.h" | 14 #include "gin/public/isolate_holder.h" |
15 #include "gin/try_catch.h" | 15 #include "gin/try_catch.h" |
| 16 #include "gin/v8_initializer.h" |
16 | 17 |
17 namespace gin { | 18 namespace gin { |
18 namespace { | 19 namespace { |
19 | 20 |
20 std::string Load(const base::FilePath& path) { | 21 std::string Load(const base::FilePath& path) { |
21 std::string source; | 22 std::string source; |
22 if (!ReadFileToString(path, &source)) | 23 if (!ReadFileToString(path, &source)) |
23 LOG(FATAL) << "Unable to read " << path.LossyDisplayName(); | 24 LOG(FATAL) << "Unable to read " << path.LossyDisplayName(); |
24 return source; | 25 return source; |
25 } | 26 } |
(...skipping 27 matching lines...) Expand all Loading... |
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 base::CommandLine::Init(argc, argv); | 61 base::CommandLine::Init(argc, argv); |
61 base::i18n::InitializeICU(); | 62 base::i18n::InitializeICU(); |
62 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 63 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
63 gin::IsolateHolder::LoadV8Snapshot(); | 64 gin::V8Initializer::LoadV8Snapshot(); |
64 #endif | 65 #endif |
65 | 66 |
66 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 67 gin::V8Initializer::Initialize(gin::IsolateHolder::kStrictMode, |
67 gin::ArrayBufferAllocator::SharedInstance()); | 68 gin::ArrayBufferAllocator::SharedInstance()); |
68 gin::IsolateHolder instance; | 69 gin::IsolateHolder instance; |
69 | 70 |
70 base::MessageLoop message_loop; | 71 base::MessageLoop message_loop; |
71 | 72 |
72 gin::GinShellRunnerDelegate delegate; | 73 gin::GinShellRunnerDelegate delegate; |
73 gin::ShellRunner runner(&delegate, instance.isolate()); | 74 gin::ShellRunner runner(&delegate, instance.isolate()); |
74 | 75 |
75 { | 76 { |
76 gin::Runner::Scope scope(&runner); | 77 gin::Runner::Scope scope(&runner); |
77 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 78 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
78 } | 79 } |
79 | 80 |
80 base::CommandLine::StringVector args = | 81 base::CommandLine::StringVector args = |
81 base::CommandLine::ForCurrentProcess()->GetArgs(); | 82 base::CommandLine::ForCurrentProcess()->GetArgs(); |
82 for (base::CommandLine::StringVector::const_iterator it = args.begin(); | 83 for (base::CommandLine::StringVector::const_iterator it = args.begin(); |
83 it != args.end(); ++it) { | 84 it != args.end(); ++it) { |
84 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 85 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
85 gin::Run, runner.GetWeakPtr(), base::FilePath(*it))); | 86 gin::Run, runner.GetWeakPtr(), base::FilePath(*it))); |
86 } | 87 } |
87 | 88 |
88 message_loop.RunUntilIdle(); | 89 message_loop.RunUntilIdle(); |
89 return 0; | 90 return 0; |
90 } | 91 } |
OLD | NEW |