| 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 #ifndef CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ | 5 #ifndef CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ |
| 6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ | 6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 14 #include "content/public/common/service_registry.h" | 15 #include "content/public/common/service_registry.h" |
| 15 #include "mojo/public/cpp/bindings/interface_impl.h" | 16 #include "mojo/public/cpp/bindings/interface_impl.h" |
| 16 #include "mojo/public/cpp/system/core.h" | 17 #include "mojo/public/cpp/system/core.h" |
| 17 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 18 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 class ServiceRegistryImpl : public ServiceRegistry, | 22 class ServiceRegistryImpl : public ServiceRegistry, |
| 22 public mojo::InterfaceImpl<mojo::ServiceProvider> { | 23 public mojo::InterfaceImpl<mojo::ServiceProvider> { |
| 23 public: | 24 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 // ServiceRegistry overrides. | 35 // ServiceRegistry overrides. |
| 35 virtual void AddService( | 36 virtual void AddService( |
| 36 const std::string& service_name, | 37 const std::string& service_name, |
| 37 const base::Callback<void(mojo::ScopedMessagePipeHandle)> service_factory) | 38 const base::Callback<void(mojo::ScopedMessagePipeHandle)> service_factory) |
| 38 OVERRIDE; | 39 OVERRIDE; |
| 39 virtual void RemoveService(const std::string& service_name) OVERRIDE; | 40 virtual void RemoveService(const std::string& service_name) OVERRIDE; |
| 40 virtual void ConnectToRemoteService( | 41 virtual void ConnectToRemoteService( |
| 41 const base::StringPiece& service_name, | 42 const base::StringPiece& service_name, |
| 42 mojo::ScopedMessagePipeHandle handle) OVERRIDE; | 43 mojo::ScopedMessagePipeHandle handle) OVERRIDE; |
| 43 | 44 |
| 45 base::WeakPtr<ServiceRegistry> GetWeakPtr(); |
| 46 |
| 44 private: | 47 private: |
| 45 // mojo::InterfaceImpl<mojo::ServiceProvider> overrides. | 48 // mojo::InterfaceImpl<mojo::ServiceProvider> overrides. |
| 46 virtual void ConnectToService( | 49 virtual void ConnectToService( |
| 47 const mojo::String& name, | 50 const mojo::String& name, |
| 48 mojo::ScopedMessagePipeHandle client_handle) OVERRIDE; | 51 mojo::ScopedMessagePipeHandle client_handle) OVERRIDE; |
| 49 virtual void OnConnectionError() OVERRIDE; | 52 virtual void OnConnectionError() OVERRIDE; |
| 50 | 53 |
| 51 std::map<std::string, base::Callback<void(mojo::ScopedMessagePipeHandle)> > | 54 std::map<std::string, base::Callback<void(mojo::ScopedMessagePipeHandle)> > |
| 52 service_factories_; | 55 service_factories_; |
| 53 std::queue<std::pair<std::string, mojo::MessagePipeHandle> > | 56 std::queue<std::pair<std::string, mojo::MessagePipeHandle> > |
| 54 pending_connects_; | 57 pending_connects_; |
| 55 bool bound_; | 58 bool bound_; |
| 59 |
| 60 base::WeakPtrFactory<ServiceRegistry> weak_factory_; |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 } // namespace content | 63 } // namespace content |
| 59 | 64 |
| 60 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ | 65 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ |
| OLD | NEW |