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 #ifndef CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 6 #define CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 // connections to the service are unaffected. | 47 // connections to the service are unaffected. |
| 48 template <typename Interface> | 48 template <typename Interface> |
| 49 void RemoveService() { | 49 void RemoveService() { |
| 50 RemoveService(Interface::Name_); | 50 RemoveService(Interface::Name_); |
| 51 } | 51 } |
| 52 virtual void RemoveService(const std::string& service_name) = 0; | 52 virtual void RemoveService(const std::string& service_name) = 0; |
| 53 | 53 |
| 54 // Connect to an interface provided by the remote service provider. | 54 // Connect to an interface provided by the remote service provider. |
| 55 template <typename Interface> | 55 template <typename Interface> |
| 56 void ConnectToRemoteService(mojo::InterfacePtr<Interface>* ptr) { | 56 void ConnectToRemoteService(mojo::InterfacePtr<Interface>* ptr) { |
| 57 ConnectToRemoteService(Interface::Name_, | 57 ConnectToRemoteService(Interface::Name_, |
|
Sam McNally
2015/05/20 02:53:13
This can just forward to the InterfaceRequest over
Anand Mistry (off Chromium)
2015/05/20 03:14:59
Done.
| |
| 58 mojo::GetProxy(ptr).PassMessagePipe()); | 58 mojo::GetProxy(ptr).PassMessagePipe()); |
| 59 } | 59 } |
| 60 template <typename Interface> | |
| 61 void ConnectToRemoteService(mojo::InterfaceRequest<Interface> ptr) { | |
| 62 ConnectToRemoteService(Interface::Name_, ptr.PassMessagePipe()); | |
| 63 } | |
| 60 virtual void ConnectToRemoteService(const base::StringPiece& name, | 64 virtual void ConnectToRemoteService(const base::StringPiece& name, |
| 61 mojo::ScopedMessagePipeHandle handle) = 0; | 65 mojo::ScopedMessagePipeHandle handle) = 0; |
| 62 | 66 |
| 63 private: | 67 private: |
| 64 template <typename Interface> | 68 template <typename Interface> |
| 65 static void ForwardToServiceFactory( | 69 static void ForwardToServiceFactory( |
| 66 const base::Callback<void(mojo::InterfaceRequest<Interface>)> | 70 const base::Callback<void(mojo::InterfaceRequest<Interface>)> |
| 67 service_factory, | 71 service_factory, |
| 68 mojo::ScopedMessagePipeHandle handle) { | 72 mojo::ScopedMessagePipeHandle handle) { |
| 69 service_factory.Run(mojo::MakeRequest<Interface>(handle.Pass())); | 73 service_factory.Run(mojo::MakeRequest<Interface>(handle.Pass())); |
| 70 } | 74 } |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 } // namespace content | 77 } // namespace content |
| 74 | 78 |
| 75 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 79 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
| OLD | NEW |