OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "mojo/service_manager/service_manager.h" | 7 #include "mojo/service_manager/service_manager.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 bool ServiceManager::TestAPI::HasFactoryForURL(const GURL& url) const { | 88 bool ServiceManager::TestAPI::HasFactoryForURL(const GURL& url) const { |
89 return manager_->url_to_shell_impl_.find(url) != | 89 return manager_->url_to_shell_impl_.find(url) != |
90 manager_->url_to_shell_impl_.end(); | 90 manager_->url_to_shell_impl_.end(); |
91 } | 91 } |
92 | 92 |
93 ServiceManager::ServiceManager() : interceptor_(NULL) { | 93 ServiceManager::ServiceManager() : interceptor_(NULL) { |
94 } | 94 } |
95 | 95 |
96 ServiceManager::~ServiceManager() { | 96 ServiceManager::~ServiceManager() { |
97 TerminateShellConnections(); | 97 STLDeleteValues(&url_to_shell_impl_); |
98 STLDeleteValues(&url_to_loader_); | 98 STLDeleteValues(&url_to_loader_); |
99 STLDeleteValues(&scheme_to_loader_); | 99 STLDeleteValues(&scheme_to_loader_); |
100 } | 100 } |
101 | 101 |
102 void ServiceManager::TerminateShellConnections() { | 102 void ServiceManager::TerminateShellConnections() { |
103 STLDeleteValues(&url_to_shell_impl_); | 103 URLToShellImplMap::iterator it; |
| 104 for (it = url_to_shell_impl_.begin(); it != url_to_shell_impl_.end(); ++it) |
| 105 it->second->client()->Terminate(); |
104 } | 106 } |
105 | 107 |
106 // static | 108 // static |
107 ServiceManager* ServiceManager::GetInstance() { | 109 ServiceManager* ServiceManager::GetInstance() { |
108 static base::LazyInstance<ServiceManager> instance = | 110 static base::LazyInstance<ServiceManager> instance = |
109 LAZY_INSTANCE_INITIALIZER; | 111 LAZY_INSTANCE_INITIALIZER; |
110 has_created_instance = true; | 112 has_created_instance = true; |
111 return &instance.Get(); | 113 return &instance.Get(); |
112 } | 114 } |
113 | 115 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 StubServiceProvider* stub_sp = new StubServiceProvider; | 184 StubServiceProvider* stub_sp = new StubServiceProvider; |
183 ServiceProviderPtr spp; | 185 ServiceProviderPtr spp; |
184 BindToProxy(stub_sp, &spp); | 186 BindToProxy(stub_sp, &spp); |
185 ConnectToApplication(application_url, GURL(), spp.Pass()); | 187 ConnectToApplication(application_url, GURL(), spp.Pass()); |
186 MessagePipe pipe; | 188 MessagePipe pipe; |
187 stub_sp->GetRemoteServiceProvider()->ConnectToService( | 189 stub_sp->GetRemoteServiceProvider()->ConnectToService( |
188 interface_name, pipe.handle1.Pass()); | 190 interface_name, pipe.handle1.Pass()); |
189 return pipe.handle0.Pass(); | 191 return pipe.handle0.Pass(); |
190 } | 192 } |
191 } // namespace mojo | 193 } // namespace mojo |
OLD | NEW |