| 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_manager/application_manager.h" | 5 #include "mojo/application_manager/application_manager.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 client()->AcceptConnection(String::From(requestor_url), | 93 client()->AcceptConnection(String::From(requestor_url), |
| 94 service_provider.Pass()); | 94 service_provider.Pass()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // ServiceProvider implementation: | 97 // ServiceProvider implementation: |
| 98 void ConnectToApplication( | 98 void ConnectToApplication( |
| 99 const String& app_url, | 99 const String& app_url, |
| 100 InterfaceRequest<ServiceProvider> in_service_provider) override { | 100 InterfaceRequest<ServiceProvider> in_service_provider) override { |
| 101 ServiceProviderPtr out_service_provider; | 101 ServiceProviderPtr out_service_provider; |
| 102 out_service_provider.Bind(in_service_provider.PassMessagePipe()); | 102 out_service_provider.Bind(in_service_provider.PassMessagePipe()); |
| 103 manager_->ConnectToApplication( | 103 GURL app_gurl(app_url); |
| 104 app_url.To<GURL>(), url_, out_service_provider.Pass()); | 104 if (!app_gurl.is_valid()) { |
| 105 LOG(ERROR) << "Error: invalid URL: " << app_url; |
| 106 return; |
| 107 } |
| 108 manager_->ConnectToApplication(app_gurl, url_, out_service_provider.Pass()); |
| 105 } | 109 } |
| 106 | 110 |
| 107 const GURL& url() const { return url_; } | 111 const GURL& url() const { return url_; } |
| 108 | 112 |
| 109 private: | 113 private: |
| 110 void OnConnectionError() override { manager_->OnShellImplError(this); } | 114 void OnConnectionError() override { manager_->OnShellImplError(this); } |
| 111 | 115 |
| 112 ApplicationManager* const manager_; | 116 ApplicationManager* const manager_; |
| 113 const GURL url_; | 117 const GURL url_; |
| 114 | 118 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 static base::LazyInstance<ApplicationManager> instance = | 172 static base::LazyInstance<ApplicationManager> instance = |
| 169 LAZY_INSTANCE_INITIALIZER; | 173 LAZY_INSTANCE_INITIALIZER; |
| 170 has_created_instance = true; | 174 has_created_instance = true; |
| 171 return &instance.Get(); | 175 return &instance.Get(); |
| 172 } | 176 } |
| 173 | 177 |
| 174 void ApplicationManager::ConnectToApplication( | 178 void ApplicationManager::ConnectToApplication( |
| 175 const GURL& url, | 179 const GURL& url, |
| 176 const GURL& requestor_url, | 180 const GURL& requestor_url, |
| 177 ServiceProviderPtr service_provider) { | 181 ServiceProviderPtr service_provider) { |
| 182 DCHECK(url.is_valid()); |
| 178 URLToShellImplMap::const_iterator shell_it = url_to_shell_impl_.find(url); | 183 URLToShellImplMap::const_iterator shell_it = url_to_shell_impl_.find(url); |
| 179 if (shell_it != url_to_shell_impl_.end()) { | 184 if (shell_it != url_to_shell_impl_.end()) { |
| 180 ConnectToClient( | 185 ConnectToClient( |
| 181 shell_it->second, url, requestor_url, service_provider.Pass()); | 186 shell_it->second, url, requestor_url, service_provider.Pass()); |
| 182 return; | 187 return; |
| 183 } | 188 } |
| 184 | 189 |
| 185 scoped_refptr<LoadCallbacksImpl> callbacks( | 190 scoped_refptr<LoadCallbacksImpl> callbacks( |
| 186 new LoadCallbacksImpl(weak_ptr_factory_.GetWeakPtr(), | 191 new LoadCallbacksImpl(weak_ptr_factory_.GetWeakPtr(), |
| 187 url, | 192 url, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 StubServiceProvider* stub_sp = new StubServiceProvider; | 321 StubServiceProvider* stub_sp = new StubServiceProvider; |
| 317 ServiceProviderPtr spp; | 322 ServiceProviderPtr spp; |
| 318 BindToProxy(stub_sp, &spp); | 323 BindToProxy(stub_sp, &spp); |
| 319 ConnectToApplication(application_url, GURL(), spp.Pass()); | 324 ConnectToApplication(application_url, GURL(), spp.Pass()); |
| 320 MessagePipe pipe; | 325 MessagePipe pipe; |
| 321 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, | 326 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, |
| 322 pipe.handle1.Pass()); | 327 pipe.handle1.Pass()); |
| 323 return pipe.handle0.Pass(); | 328 return pipe.handle0.Pass(); |
| 324 } | 329 } |
| 325 } // namespace mojo | 330 } // namespace mojo |
| OLD | NEW |