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 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 virtual void RemoveService(const std::string& service_name) = 0; | 53 virtual void RemoveService(const std::string& service_name) = 0; |
54 | 54 |
55 // Connect to an interface provided by the remote service provider. | 55 // Connect to an interface provided by the remote service provider. |
56 template <typename Interface> | 56 template <typename Interface> |
57 void ConnectToRemoteService(mojo::InterfaceRequest<Interface> ptr) { | 57 void ConnectToRemoteService(mojo::InterfaceRequest<Interface> ptr) { |
58 ConnectToRemoteService(Interface::Name_, ptr.PassMessagePipe()); | 58 ConnectToRemoteService(Interface::Name_, ptr.PassMessagePipe()); |
59 } | 59 } |
60 virtual void ConnectToRemoteService(const base::StringPiece& name, | 60 virtual void ConnectToRemoteService(const base::StringPiece& name, |
61 mojo::ScopedMessagePipeHandle handle) = 0; | 61 mojo::ScopedMessagePipeHandle handle) = 0; |
62 | 62 |
63 // Registers a local service factory to intercept ConnectToRemoteService | |
64 // requests instead of actually connecting to the remote registry. Used only | |
65 // for testing. | |
66 virtual void AddServiceOverrideForTesting( | |
67 const std::string& service_name, | |
68 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& | |
69 service_factory) = 0; | |
70 | |
71 virtual void ClearServiceOverridesForTesting() = 0; | |
jam
2016/03/18 17:01:13
nit: document
leonhsl(Using Gerrit)
2016/03/19 05:05:12
Done.
| |
72 | |
63 private: | 73 private: |
64 template <typename Interface> | 74 template <typename Interface> |
65 static void ForwardToServiceFactory( | 75 static void ForwardToServiceFactory( |
66 const base::Callback<void(mojo::InterfaceRequest<Interface>)> | 76 const base::Callback<void(mojo::InterfaceRequest<Interface>)> |
67 service_factory, | 77 service_factory, |
68 mojo::ScopedMessagePipeHandle handle) { | 78 mojo::ScopedMessagePipeHandle handle) { |
69 service_factory.Run(mojo::MakeRequest<Interface>(std::move(handle))); | 79 service_factory.Run(mojo::MakeRequest<Interface>(std::move(handle))); |
70 } | 80 } |
71 }; | 81 }; |
72 | 82 |
73 } // namespace content | 83 } // namespace content |
74 | 84 |
75 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ | 85 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ |
OLD | NEW |