| 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/feature_list.h" |
| 8 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 9 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "gin/array_buffer.h" | 13 #include "gin/array_buffer.h" |
| 13 #include "gin/modules/console.h" | 14 #include "gin/modules/console.h" |
| 14 #include "gin/modules/module_runner_delegate.h" | 15 #include "gin/modules/module_runner_delegate.h" |
| 15 #include "gin/public/isolate_holder.h" | 16 #include "gin/public/isolate_holder.h" |
| 16 #include "gin/try_catch.h" | 17 #include "gin/try_catch.h" |
| 17 #include "gin/v8_initializer.h" | 18 #include "gin/v8_initializer.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 base::AtExitManager at_exit; | 62 base::AtExitManager at_exit; |
| 62 base::CommandLine::Init(argc, argv); | 63 base::CommandLine::Init(argc, argv); |
| 63 base::i18n::InitializeICU(); | 64 base::i18n::InitializeICU(); |
| 64 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 65 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 65 gin::V8Initializer::LoadV8Snapshot(); | 66 gin::V8Initializer::LoadV8Snapshot(); |
| 66 gin::V8Initializer::LoadV8Natives(); | 67 gin::V8Initializer::LoadV8Natives(); |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 69 base::MessageLoop message_loop; | 70 base::MessageLoop message_loop; |
| 70 | 71 |
| 72 // Initialize the base::FeatureList since IsolateHolder can depend on it. |
| 73 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList)); |
| 74 |
| 71 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 75 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
| 72 gin::IsolateHolder::kStableV8Extras, | 76 gin::IsolateHolder::kStableV8Extras, |
| 73 gin::ArrayBufferAllocator::SharedInstance()); | 77 gin::ArrayBufferAllocator::SharedInstance()); |
| 74 gin::IsolateHolder instance; | 78 gin::IsolateHolder instance; |
| 75 | 79 |
| 76 | 80 |
| 77 gin::GinShellRunnerDelegate delegate; | 81 gin::GinShellRunnerDelegate delegate; |
| 78 gin::ShellRunner runner(&delegate, instance.isolate()); | 82 gin::ShellRunner runner(&delegate, instance.isolate()); |
| 79 | 83 |
| 80 { | 84 { |
| 81 gin::Runner::Scope scope(&runner); | 85 gin::Runner::Scope scope(&runner); |
| 82 runner.GetContextHolder() | 86 runner.GetContextHolder() |
| 83 ->isolate() | 87 ->isolate() |
| 84 ->SetCaptureStackTraceForUncaughtExceptions(true); | 88 ->SetCaptureStackTraceForUncaughtExceptions(true); |
| 85 } | 89 } |
| 86 | 90 |
| 87 base::CommandLine::StringVector args = | 91 base::CommandLine::StringVector args = |
| 88 base::CommandLine::ForCurrentProcess()->GetArgs(); | 92 base::CommandLine::ForCurrentProcess()->GetArgs(); |
| 89 for (base::CommandLine::StringVector::const_iterator it = args.begin(); | 93 for (base::CommandLine::StringVector::const_iterator it = args.begin(); |
| 90 it != args.end(); ++it) { | 94 it != args.end(); ++it) { |
| 91 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 95 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
| 92 gin::Run, runner.GetWeakPtr(), base::FilePath(*it))); | 96 gin::Run, runner.GetWeakPtr(), base::FilePath(*it))); |
| 93 } | 97 } |
| 94 | 98 |
| 95 message_loop.RunUntilIdle(); | 99 message_loop.RunUntilIdle(); |
| 96 return 0; | 100 return 0; |
| 97 } | 101 } |
| OLD | NEW |