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/application_delegate_impl.h" | 5 #include "mojo/apps/js/application_delegate_impl.h" |
6 | 6 |
7 #include "gin/array_buffer.h" | 7 #include "gin/array_buffer.h" |
8 #include "gin/public/isolate_holder.h" | 8 #include "gin/public/isolate_holder.h" |
9 #include "mojo/apps/js/js_app.h" | 9 #include "mojo/apps/js/js_app.h" |
10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 app_vector_.push_back(app); | 30 app_vector_.push_back(app); |
31 // TODO(hansmuller): deal with the Start() return value. | 31 // TODO(hansmuller): deal with the Start() return value. |
32 app->Start(); | 32 app->Start(); |
33 } | 33 } |
34 | 34 |
35 void ApplicationDelegateImpl::QuitJSApp(JSApp* app) { | 35 void ApplicationDelegateImpl::QuitJSApp(JSApp* app) { |
36 AppVector::iterator itr = | 36 AppVector::iterator itr = |
37 std::find(app_vector_.begin(), app_vector_.end(), app); | 37 std::find(app_vector_.begin(), app_vector_.end(), app); |
38 if (itr != app_vector_.end()) | 38 if (itr != app_vector_.end()) |
39 app_vector_.erase(itr); | 39 app_vector_.erase(itr); |
| 40 if (app_vector_.empty()) |
| 41 base::MessageLoop::current()->QuitWhenIdle(); |
40 } | 42 } |
41 | 43 |
42 void ApplicationDelegateImpl::ConnectToService( | 44 void ApplicationDelegateImpl::ConnectToService( |
43 ScopedMessagePipeHandle pipe_handle, | 45 ScopedMessagePipeHandle pipe_handle, |
44 const std::string& application_url, | 46 const std::string& application_url, |
45 const std::string& interface_name) { | 47 const std::string& interface_name) { |
46 CHECK(application_impl_); | 48 CHECK(application_impl_); |
47 ServiceProvider* service_provider = | 49 ServiceProvider* service_provider = |
48 application_impl_->ConnectToApplication(application_url) | 50 application_impl_->ConnectToApplication(application_url) |
49 ->GetServiceProvider(); | 51 ->GetServiceProvider(); |
50 service_provider->ConnectToService(interface_name, pipe_handle.Pass()); | 52 service_provider->ConnectToService(interface_name, pipe_handle.Pass()); |
51 } | 53 } |
52 | 54 |
53 } // namespace apps | 55 } // namespace apps |
54 } // namespace mojo | 56 } // namespace mojo |
OLD | NEW |