Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: mojo/apps/js/js_app.cc

Issue 665743003: Mojo JS Bindings: Simplify sharing services for content-provided JS applications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
41 41
42 void JSApp::Quit() { 42 void JSApp::Quit() {
43 CHECK(on_js_app_thread()); 43 CHECK(on_js_app_thread());
44 44
45 // The terminate operation is posted to the message_loop so that 45 // The terminate operation is posted to the message_loop so that
46 // the shell_runner isn't destroyed before this JS function returns. 46 // the shell_runner isn't destroyed before this JS function returns.
47 thread_.message_loop()->PostTask( 47 thread_.message_loop()->PostTask(
48 FROM_HERE, base::Bind(&JSApp::Terminate, base::Unretained(this))); 48 FROM_HERE, base::Bind(&JSApp::Terminate, base::Unretained(this)));
49 } 49 }
50 50
51 Handle JSApp::ConnectToService(const std::string& application_url, 51 Handle JSApp::ConnectToApplication(const std::string& application_url) {
52 const std::string& interface_name) {
53 CHECK(on_js_app_thread()); 52 CHECK(on_js_app_thread());
54 MessagePipe pipe; 53 MessagePipe pipe;
55 54
56 app_delegate_impl_task_runner_->PostTask( 55 app_delegate_impl_task_runner_->PostTask(
57 FROM_HERE, 56 FROM_HERE,
58 base::Bind(&ApplicationDelegateImpl::ConnectToService, 57 base::Bind(&ApplicationDelegateImpl::ConnectToApplication,
59 base::Unretained(app_delegate_impl_), 58 base::Unretained(app_delegate_impl_),
60 base::Passed(pipe.handle1.Pass()),
61 application_url, 59 application_url,
62 interface_name)); 60 base::Passed(pipe.handle1.Pass())));
63 61
64 return pipe.handle0.release(); 62 return pipe.handle0.release();
65 } 63 }
66 64
65
67 void JSApp::Run() { 66 void JSApp::Run() {
68 CHECK(!js_app_task_runner_.get() && !on_app_delegate_impl_thread()); 67 CHECK(!js_app_task_runner_.get() && !on_app_delegate_impl_thread());
69 js_app_task_runner_ = base::MessageLoop::current()->task_runner(); 68 js_app_task_runner_ = base::MessageLoop::current()->task_runner();
70 69
71 std::string source; 70 std::string source;
72 std::string file_name; 71 std::string file_name;
73 Load(&source, &file_name); // TODO(hansmuller): handle Load() failure. 72 Load(&source, &file_name); // TODO(hansmuller): handle Load() failure.
74 73
75 isolate_holder_.reset(new gin::IsolateHolder()); 74 isolate_holder_.reset(new gin::IsolateHolder());
76 isolate_holder_->AddRunMicrotasksObserver(); 75 isolate_holder_->AddRunMicrotasksObserver();
(...skipping 26 matching lines...) Expand all
103 } 102 }
104 103
105 bool JSApp::on_js_app_thread() const { 104 bool JSApp::on_js_app_thread() const {
106 return js_app_task_runner_.get() && 105 return js_app_task_runner_.get() &&
107 js_app_task_runner_.get() == 106 js_app_task_runner_.get() ==
108 base::MessageLoop::current()->task_runner().get(); 107 base::MessageLoop::current()->task_runner().get();
109 } 108 }
110 109
111 } // namespace apps 110 } // namespace apps
112 } // namespace mojo 111 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698