Chromium Code Reviews| 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/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 Loading... | |
| 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 scoped_ptr<gin::Gin> instance(new gin::Gin()); | |
|
abarth-chromium
2013/11/19 15:49:21
Why not allocate on the stack?
jochen (gone - plz use gerrit)
2013/11/19 15:57:24
Done.
| |
| 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 } |
| OLD | NEW |