Index: services/shell/public/cpp/interface_provider.h |
diff --git a/services/shell/public/cpp/interface_provider.h b/services/shell/public/cpp/interface_provider.h |
index fe6930e3f825d8a262ca4b4ed20cb13795958c95..865ab8bd5cdcdbcf3e4b3a85def271adc1d96ae6 100644 |
--- a/services/shell/public/cpp/interface_provider.h |
+++ b/services/shell/public/cpp/interface_provider.h |
@@ -18,6 +18,8 @@ namespace shell { |
// Connection. |
class InterfaceProvider { |
public: |
+ using ForwardCallback = base::Callback<void(const mojo::String&, |
+ mojo::ScopedMessagePipeHandle)>; |
class TestApi { |
public: |
explicit TestApi(InterfaceProvider* provider) : provider_(provider) {} |
@@ -41,8 +43,17 @@ class InterfaceProvider { |
InterfaceProvider(); |
~InterfaceProvider(); |
+ // Binds this InterfaceProvider to an actual mojom::InterfaceProvider pipe. |
+ // It is an error to call this on a forwarding InterfaceProvider, i.e. this |
+ // call is exclusive to Forward(). |
void Bind(mojom::InterfaceProviderPtr interface_provider); |
+ // Sets this InterfaceProvider to forward all GetInterface() requests to |
+ // |callback|. It is an error to call this on a bound InterfaceProvider, i.e. |
+ // this call is exclusive to Bind(). In addition, and unlike Bind(), this MUST |
+ // be called before any calls to GetInterface() are made. |
+ void Forward(const ForwardCallback& callback); |
+ |
// Returns a raw pointer to the remote InterfaceProvider. |
mojom::InterfaceProvider* get() { return interface_provider_.get(); } |
@@ -83,6 +94,10 @@ class InterfaceProvider { |
mojom::InterfaceProviderPtr interface_provider_; |
mojom::InterfaceProviderRequest pending_request_; |
+ // A callback to receive all GetInterface() requests in lieu of the |
+ // InterfaceProvider pipe. |
+ ForwardCallback forward_callback_; |
+ |
base::WeakPtrFactory<InterfaceProvider> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(InterfaceProvider); |