Index: content/common/associated_interface_provider_impl.h |
diff --git a/content/common/associated_interface_provider_impl.h b/content/common/associated_interface_provider_impl.h |
index af01ce55427a5ee9fa6916635c7e066d05ca206a..380bff847b7289488f3badbbd4fd4f855f3e077e 100644 |
--- a/content/common/associated_interface_provider_impl.h |
+++ b/content/common/associated_interface_provider_impl.h |
@@ -5,10 +5,13 @@ |
#include "content/public/common/associated_interface_provider.h" |
#include <stdint.h> |
+#include <memory> |
#include "base/macros.h" |
#include "content/common/associated_interfaces.mojom.h" |
+#include "mojo/public/cpp/bindings/associated_binding.h" |
#include "mojo/public/cpp/bindings/associated_group.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
namespace content { |
@@ -17,16 +20,61 @@ class AssociatedInterfaceProviderImpl : public AssociatedInterfaceProvider { |
// Binds this to a remote mojom::AssociatedInterfaceProvider. |
explicit AssociatedInterfaceProviderImpl( |
mojom::AssociatedInterfaceProviderAssociatedPtr proxy); |
+ // This constructor is only used for some tests when there has no injected |
+ // mojom::AssociatedInterfaceProviderAssociatedPtr. Here will emulate it |
+ // by providing self-contained local implementations of both |
+ // mojom::RouteProvider and mojom::AssociatedInterfaceProvider. |
Ken Rockot(use gerrit already)
2016/09/28 14:42:48
nit: We can reduce this documentation a bit since
leonhsl(Using Gerrit)
2016/10/07 09:42:52
Done and Thanks!
|
+ AssociatedInterfaceProviderImpl(); |
~AssociatedInterfaceProviderImpl() override; |
// AssociatedInterfaceProvider: |
void GetInterface(const std::string& name, |
mojo::ScopedInterfaceEndpointHandle handle) override; |
mojo::AssociatedGroup* GetAssociatedGroup() override; |
+ void OverrideBinderForTesting( |
+ const std::string& name, |
+ const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) |
+ override; |
private: |
+ class LocalProvider : public mojom::RouteProvider, |
Ken Rockot(use gerrit already)
2016/09/28 14:42:48
Please move the class definition into the cc file.
leonhsl(Using Gerrit)
2016/10/07 09:42:52
Done.
|
+ mojom::AssociatedInterfaceProvider { |
+ public: |
+ explicit LocalProvider( |
+ mojom::AssociatedInterfaceProviderAssociatedPtr* proxy); |
+ ~LocalProvider() override; |
+ |
+ void SetBinderForName(const std::string& name, |
+ const base::Callback<void( |
+ mojo::ScopedInterfaceEndpointHandle)>& binder); |
+ |
+ private: |
+ // mojom::RouteProvider: |
+ void GetRoute( |
+ int32_t routing_id, |
+ mojom::AssociatedInterfaceProviderAssociatedRequest request) override; |
+ |
+ // mojom::AssociatedInterfaceProvider: |
+ void GetAssociatedInterface( |
+ const std::string& name, |
+ mojom::AssociatedInterfaceAssociatedRequest request) override; |
+ |
+ using BinderMap = |
+ std::map<std::string, |
+ base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>>; |
+ BinderMap binders_; |
+ |
+ mojom::RouteProviderPtr route_provider_ptr_; |
+ mojo::Binding<mojom::RouteProvider> route_provider_binding_; |
+ |
+ mojo::AssociatedBinding<mojom::AssociatedInterfaceProvider> |
+ associated_interface_provider_binding_; |
+ }; |
+ |
mojom::AssociatedInterfaceProviderAssociatedPtr proxy_; |
+ std::unique_ptr<LocalProvider> local_provider_; |
+ |
DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceProviderImpl); |
}; |