| 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" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 void JSApp::Run() { | 67 void JSApp::Run() { |
| 68 CHECK(!js_app_task_runner_.get() && !on_app_delegate_impl_thread()); | 68 CHECK(!js_app_task_runner_.get() && !on_app_delegate_impl_thread()); |
| 69 js_app_task_runner_ = base::MessageLoop::current()->task_runner(); | 69 js_app_task_runner_ = base::MessageLoop::current()->task_runner(); |
| 70 | 70 |
| 71 std::string source; | 71 std::string source; |
| 72 std::string file_name; | 72 std::string file_name; |
| 73 Load(&source, &file_name); // TODO(hansmuller): handle Load() failure. | 73 Load(&source, &file_name); // TODO(hansmuller): handle Load() failure. |
| 74 | 74 |
| 75 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | |
| 76 gin::ArrayBufferAllocator::SharedInstance()); | |
| 77 isolate_holder_.reset(new gin::IsolateHolder()); | 75 isolate_holder_.reset(new gin::IsolateHolder()); |
| 78 isolate_holder_->AddRunMicrotasksObserver(); | 76 isolate_holder_->AddRunMicrotasksObserver(); |
| 79 | 77 |
| 80 shell_runner_.reset( | 78 shell_runner_.reset( |
| 81 new gin::ShellRunner(&runner_delegate_, isolate_holder_->isolate())); | 79 new gin::ShellRunner(&runner_delegate_, isolate_holder_->isolate())); |
| 82 | 80 |
| 83 gin::Runner::Scope scope(shell_runner_.get()); | 81 gin::Runner::Scope scope(shell_runner_.get()); |
| 84 shell_runner_->Run(source.c_str(), file_name.c_str()); | 82 shell_runner_->Run(source.c_str(), file_name.c_str()); |
| 85 } | 83 } |
| 86 | 84 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 105 } | 103 } |
| 106 | 104 |
| 107 bool JSApp::on_js_app_thread() const { | 105 bool JSApp::on_js_app_thread() const { |
| 108 return js_app_task_runner_.get() && | 106 return js_app_task_runner_.get() && |
| 109 js_app_task_runner_.get() == | 107 js_app_task_runner_.get() == |
| 110 base::MessageLoop::current()->task_runner().get(); | 108 base::MessageLoop::current()->task_runner().get(); |
| 111 } | 109 } |
| 112 | 110 |
| 113 } // namespace apps | 111 } // namespace apps |
| 114 } // namespace mojo | 112 } // namespace mojo |
| OLD | NEW |