| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool ApplicationManager::TestAPI::HasCreatedInstance() { | 141 bool ApplicationManager::TestAPI::HasCreatedInstance() { |
| 142 return has_created_instance; | 142 return has_created_instance; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool ApplicationManager::TestAPI::HasFactoryForURL(const GURL& url) const { | 145 bool ApplicationManager::TestAPI::HasFactoryForURL(const GURL& url) const { |
| 146 return manager_->url_to_shell_impl_.find(url) != | 146 return manager_->url_to_shell_impl_.find(url) != |
| 147 manager_->url_to_shell_impl_.end(); | 147 manager_->url_to_shell_impl_.end(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 ApplicationManager::ApplicationManager() | 150 ApplicationManager::ApplicationManager() |
| 151 : interceptor_(NULL), weak_ptr_factory_(this) { | 151 : delegate_(NULL), |
| 152 interceptor_(NULL), |
| 153 weak_ptr_factory_(this) { |
| 152 } | 154 } |
| 153 | 155 |
| 154 ApplicationManager::~ApplicationManager() { | 156 ApplicationManager::~ApplicationManager() { |
| 155 STLDeleteValues(&url_to_content_handler_); | 157 STLDeleteValues(&url_to_content_handler_); |
| 156 TerminateShellConnections(); | 158 TerminateShellConnections(); |
| 157 STLDeleteValues(&url_to_loader_); | 159 STLDeleteValues(&url_to_loader_); |
| 158 STLDeleteValues(&scheme_to_loader_); | 160 STLDeleteValues(&scheme_to_loader_); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void ApplicationManager::TerminateShellConnections() { | 163 void ApplicationManager::TerminateShellConnections() { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void ApplicationManager::OnShellImplError(ShellImpl* shell_impl) { | 280 void ApplicationManager::OnShellImplError(ShellImpl* shell_impl) { |
| 279 // Called from ~ShellImpl, so we do not need to call Destroy here. | 281 // Called from ~ShellImpl, so we do not need to call Destroy here. |
| 280 const GURL url = shell_impl->url(); | 282 const GURL url = shell_impl->url(); |
| 281 URLToShellImplMap::iterator it = url_to_shell_impl_.find(url); | 283 URLToShellImplMap::iterator it = url_to_shell_impl_.find(url); |
| 282 DCHECK(it != url_to_shell_impl_.end()); | 284 DCHECK(it != url_to_shell_impl_.end()); |
| 283 delete it->second; | 285 delete it->second; |
| 284 url_to_shell_impl_.erase(it); | 286 url_to_shell_impl_.erase(it); |
| 285 ApplicationLoader* loader = GetLoaderForURL(url); | 287 ApplicationLoader* loader = GetLoaderForURL(url); |
| 286 if (loader) | 288 if (loader) |
| 287 loader->OnServiceError(this, url); | 289 loader->OnServiceError(this, url); |
| 290 if (delegate_) |
| 291 delegate_->OnServiceError(url); |
| 288 } | 292 } |
| 289 | 293 |
| 290 ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName( | 294 ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName( |
| 291 const GURL& application_url, | 295 const GURL& application_url, |
| 292 const std::string& interface_name) { | 296 const std::string& interface_name) { |
| 293 StubServiceProvider* stub_sp = new StubServiceProvider; | 297 StubServiceProvider* stub_sp = new StubServiceProvider; |
| 294 ServiceProviderPtr spp; | 298 ServiceProviderPtr spp; |
| 295 BindToProxy(stub_sp, &spp); | 299 BindToProxy(stub_sp, &spp); |
| 296 ConnectToApplication(application_url, GURL(), spp.Pass()); | 300 ConnectToApplication(application_url, GURL(), spp.Pass()); |
| 297 MessagePipe pipe; | 301 MessagePipe pipe; |
| 298 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, | 302 stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name, |
| 299 pipe.handle1.Pass()); | 303 pipe.handle1.Pass()); |
| 300 return pipe.handle0.Pass(); | 304 return pipe.handle0.Pass(); |
| 301 } | 305 } |
| 302 } // namespace mojo | 306 } // namespace mojo |
| OLD | NEW |