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/application/public/cpp/application_impl.h" | 5 #include "mojo/application/public/cpp/application_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 application_url, application_url, remote_services.Pass(), | 79 application_url, application_url, remote_services.Pass(), |
80 local_request.Pass(), allowed)); | 80 local_request.Pass(), allowed)); |
81 shell_->ConnectToApplication(request.Pass(), remote_services_proxy.Pass(), | 81 shell_->ConnectToApplication(request.Pass(), remote_services_proxy.Pass(), |
82 local_services.Pass(), filter.Pass(), | 82 local_services.Pass(), filter.Pass(), |
83 registry->GetConnectToApplicationCallback()); | 83 registry->GetConnectToApplicationCallback()); |
84 if (!delegate_->ConfigureOutgoingConnection(registry.get())) | 84 if (!delegate_->ConfigureOutgoingConnection(registry.get())) |
85 return nullptr; | 85 return nullptr; |
86 return registry.Pass(); | 86 return registry.Pass(); |
87 } | 87 } |
88 | 88 |
89 void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) { | 89 void ApplicationImpl::WaitForInitialize() { |
90 shell_ = shell.Pass(); | 90 DCHECK(!shell_.is_bound()); |
91 shell_.set_connection_error_handler([this]() { OnConnectionError(); }); | 91 binding_.WaitForIncomingMethodCall(); |
92 url_ = url; | |
93 delegate_->Initialize(this); | |
94 } | 92 } |
95 | 93 |
96 void ApplicationImpl::Quit() { | 94 void ApplicationImpl::Quit() { |
97 // We can't quit immediately, since there could be in-flight requests from the | 95 // We can't quit immediately, since there could be in-flight requests from the |
98 // shell. So check with it first. | 96 // shell. So check with it first. |
99 if (shell_) { | 97 if (shell_) { |
100 quit_requested_ = true; | 98 quit_requested_ = true; |
101 shell_->QuitApplication(); | 99 shell_->QuitApplication(); |
102 } else { | 100 } else { |
103 QuitNow(); | 101 QuitNow(); |
104 } | 102 } |
105 } | 103 } |
106 | 104 |
| 105 void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) { |
| 106 shell_ = shell.Pass(); |
| 107 shell_.set_connection_error_handler([this]() { OnConnectionError(); }); |
| 108 url_ = url; |
| 109 delegate_->Initialize(this); |
| 110 } |
| 111 |
107 void ApplicationImpl::AcceptConnection( | 112 void ApplicationImpl::AcceptConnection( |
108 const String& requestor_url, | 113 const String& requestor_url, |
109 InterfaceRequest<ServiceProvider> services, | 114 InterfaceRequest<ServiceProvider> services, |
110 ServiceProviderPtr exposed_services, | 115 ServiceProviderPtr exposed_services, |
111 Array<String> allowed_interfaces, | 116 Array<String> allowed_interfaces, |
112 const String& url) { | 117 const String& url) { |
113 scoped_ptr<ApplicationConnection> registry(new internal::ServiceRegistry( | 118 scoped_ptr<ApplicationConnection> registry(new internal::ServiceRegistry( |
114 url, requestor_url, exposed_services.Pass(), services.Pass(), | 119 url, requestor_url, exposed_services.Pass(), services.Pass(), |
115 allowed_interfaces.To<std::set<std::string>>())); | 120 allowed_interfaces.To<std::set<std::string>>())); |
116 if (!delegate_->ConfigureIncomingConnection(registry.get())) | 121 if (!delegate_->ConfigureIncomingConnection(registry.get())) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 159 } |
155 | 160 |
156 void ApplicationImpl::UnbindConnections( | 161 void ApplicationImpl::UnbindConnections( |
157 InterfaceRequest<Application>* application_request, | 162 InterfaceRequest<Application>* application_request, |
158 ShellPtr* shell) { | 163 ShellPtr* shell) { |
159 *application_request = binding_.Unbind(); | 164 *application_request = binding_.Unbind(); |
160 shell->Bind(shell_.PassInterface()); | 165 shell->Bind(shell_.PassInterface()); |
161 } | 166 } |
162 | 167 |
163 } // namespace mojo | 168 } // namespace mojo |
OLD | NEW |