Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/apps/js/js_app.h" | 5 #include "mojo/apps/js/js_app.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "gin/array_buffer.h" | 8 #include "gin/array_buffer.h" |
| 9 #include "gin/converter.h" | 9 #include "gin/converter.h" |
| 10 #include "mojo/apps/js/application_delegate_impl.h" | 10 #include "mojo/apps/js/application_delegate_impl.h" |
| 11 #include "mojo/apps/js/mojo_module.h" | 11 #include "mojo/apps/js/mojo_module.h" |
| 12 | 12 |
| 13 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 14 #include "gin/public/isolate_holder.h" | |
| 15 #endif | |
| 16 | |
| 13 namespace mojo { | 17 namespace mojo { |
| 14 namespace apps { | 18 namespace apps { |
| 15 | 19 |
| 16 JSApp::JSApp(ApplicationDelegateImpl* app_delegate_impl) | 20 JSApp::JSApp(ApplicationDelegateImpl* app_delegate_impl) |
| 17 : app_delegate_impl_(app_delegate_impl), | 21 : app_delegate_impl_(app_delegate_impl), |
| 18 thread_("Mojo JS"), | 22 thread_("Mojo JS"), |
| 19 app_delegate_impl_task_runner_( | 23 app_delegate_impl_task_runner_( |
| 20 base::MessageLoop::current()->task_runner()) { | 24 base::MessageLoop::current()->task_runner()) { |
| 21 CHECK(on_app_delegate_impl_thread()); | 25 CHECK(on_app_delegate_impl_thread()); |
| 22 runner_delegate_.AddBuiltinModule(Mojo::kModuleName, | 26 runner_delegate_.AddBuiltinModule(Mojo::kModuleName, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 } | 69 } |
| 66 | 70 |
| 67 void JSApp::Run() { | 71 void JSApp::Run() { |
| 68 CHECK(!js_app_task_runner_.get() && !on_app_delegate_impl_thread()); | 72 CHECK(!js_app_task_runner_.get() && !on_app_delegate_impl_thread()); |
| 69 js_app_task_runner_ = base::MessageLoop::current()->task_runner(); | 73 js_app_task_runner_ = base::MessageLoop::current()->task_runner(); |
| 70 | 74 |
| 71 std::string source; | 75 std::string source; |
| 72 std::string file_name; | 76 std::string file_name; |
| 73 Load(&source, &file_name); // TODO(hansmuller): handle Load() failure. | 77 Load(&source, &file_name); // TODO(hansmuller): handle Load() failure. |
| 74 | 78 |
| 79 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 80 gin::IsolateHolder::LoadV8Snapshot(); | |
|
rmcilroy
2014/10/06 15:41:03
Is this required given the change in content_handl
baixo
2014/10/07 14:53:28
Done.
| |
| 81 #endif | |
| 82 | |
| 75 isolate_holder_.reset(new gin::IsolateHolder()); | 83 isolate_holder_.reset(new gin::IsolateHolder()); |
| 76 isolate_holder_->AddRunMicrotasksObserver(); | 84 isolate_holder_->AddRunMicrotasksObserver(); |
| 77 | 85 |
| 78 shell_runner_.reset( | 86 shell_runner_.reset( |
| 79 new gin::ShellRunner(&runner_delegate_, isolate_holder_->isolate())); | 87 new gin::ShellRunner(&runner_delegate_, isolate_holder_->isolate())); |
| 80 | 88 |
| 81 gin::Runner::Scope scope(shell_runner_.get()); | 89 gin::Runner::Scope scope(shell_runner_.get()); |
| 82 shell_runner_->Run(source.c_str(), file_name.c_str()); | 90 shell_runner_->Run(source.c_str(), file_name.c_str()); |
| 83 } | 91 } |
| 84 | 92 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 103 } | 111 } |
| 104 | 112 |
| 105 bool JSApp::on_js_app_thread() const { | 113 bool JSApp::on_js_app_thread() const { |
| 106 return js_app_task_runner_.get() && | 114 return js_app_task_runner_.get() && |
| 107 js_app_task_runner_.get() == | 115 js_app_task_runner_.get() == |
| 108 base::MessageLoop::current()->task_runner().get(); | 116 base::MessageLoop::current()->task_runner().get(); |
| 109 } | 117 } |
| 110 | 118 |
| 111 } // namespace apps | 119 } // namespace apps |
| 112 } // namespace mojo | 120 } // namespace mojo |
| OLD | NEW |