Chromium Code Reviews| 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 "content/common/mojo/service_registry_impl.h" | 5 #include "content/common/mojo/service_registry_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "mojo/common/common_type_converters.h" | 9 #include "mojo/common/common_type_converters.h" |
| 10 | 10 |
| 11 #if defined(OS_ANDROID) | |
| 12 #include "content/common/mojo/service_registry_android.h" | |
| 13 #endif | |
| 14 | |
| 11 namespace content { | 15 namespace content { |
| 12 | 16 |
| 13 ServiceRegistryImpl::ServiceRegistryImpl() | 17 ServiceRegistryImpl::ServiceRegistryImpl() |
| 14 : binding_(this), weak_factory_(this) {} | 18 : binding_(this), |
| 19 #if defined(OS_ANDROID) | |
| 20 android_impl_(new ServiceRegistryAndroid(this)), | |
|
Sam McNally
2016/03/31 23:40:26
Can you delay creating this until the first call t
please use gerrit instead
2016/04/01 01:23:27
Done.
| |
| 21 #endif | |
| 22 weak_factory_(this) { | |
| 23 } | |
| 15 | 24 |
| 16 ServiceRegistryImpl::~ServiceRegistryImpl() { | 25 ServiceRegistryImpl::~ServiceRegistryImpl() { |
| 17 while (!pending_connects_.empty()) { | 26 while (!pending_connects_.empty()) { |
| 18 mojo::CloseRaw(pending_connects_.front().second); | 27 mojo::CloseRaw(pending_connects_.front().second); |
| 19 pending_connects_.pop(); | 28 pending_connects_.pop(); |
| 20 } | 29 } |
| 21 } | 30 } |
| 22 | 31 |
| 23 void ServiceRegistryImpl::Bind( | 32 void ServiceRegistryImpl::Bind( |
| 24 mojo::shell::mojom::InterfaceProviderRequest request) { | 33 mojo::shell::mojom::InterfaceProviderRequest request) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 void ServiceRegistryImpl::AddServiceOverrideForTesting( | 78 void ServiceRegistryImpl::AddServiceOverrideForTesting( |
| 70 const std::string& service_name, | 79 const std::string& service_name, |
| 71 const ServiceFactory& factory) { | 80 const ServiceFactory& factory) { |
| 72 service_overrides_[service_name] = factory; | 81 service_overrides_[service_name] = factory; |
| 73 } | 82 } |
| 74 | 83 |
| 75 void ServiceRegistryImpl::ClearServiceOverridesForTesting() { | 84 void ServiceRegistryImpl::ClearServiceOverridesForTesting() { |
| 76 service_overrides_.clear(); | 85 service_overrides_.clear(); |
| 77 } | 86 } |
| 78 | 87 |
| 88 #if defined(OS_ANDROID) | |
| 89 const base::android::ScopedJavaGlobalRef<jobject>& | |
| 90 ServiceRegistryImpl::GetJavaObj() { | |
| 91 return android_impl_->GetObj(); | |
| 92 } | |
| 93 #endif | |
| 94 | |
| 79 bool ServiceRegistryImpl::IsBound() const { | 95 bool ServiceRegistryImpl::IsBound() const { |
| 80 return binding_.is_bound(); | 96 return binding_.is_bound(); |
| 81 } | 97 } |
| 82 | 98 |
| 83 base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() { | 99 base::WeakPtr<ServiceRegistry> ServiceRegistryImpl::GetWeakPtr() { |
| 84 return weak_factory_.GetWeakPtr(); | 100 return weak_factory_.GetWeakPtr(); |
| 85 } | 101 } |
| 86 | 102 |
| 87 void ServiceRegistryImpl::GetInterface( | 103 void ServiceRegistryImpl::GetInterface( |
| 88 const mojo::String& name, | 104 const mojo::String& name, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 99 } | 115 } |
| 100 | 116 |
| 101 it->second.Run(std::move(client_handle)); | 117 it->second.Run(std::move(client_handle)); |
| 102 } | 118 } |
| 103 | 119 |
| 104 void ServiceRegistryImpl::OnConnectionError() { | 120 void ServiceRegistryImpl::OnConnectionError() { |
| 105 binding_.Close(); | 121 binding_.Close(); |
| 106 } | 122 } |
| 107 | 123 |
| 108 } // namespace content | 124 } // namespace content |
| OLD | NEW |