Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: content/common/mojo/service_registry_impl.h

Issue 1470153002: [mojo] Enable ServiceRegistryImpl to override remote services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-testing-3
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/mojo/service_registry_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/service_registry_impl.h
diff --git a/content/common/mojo/service_registry_impl.h b/content/common/mojo/service_registry_impl.h
index 5e4fd73fd917b8c4874f5965df9ca52bb5f1e4a4..a51c67cfeed072ded9f685a3a1cca461666ecd67 100644
--- a/content/common/mojo/service_registry_impl.h
+++ b/content/common/mojo/service_registry_impl.h
@@ -24,6 +24,8 @@ class CONTENT_EXPORT ServiceRegistryImpl
: public ServiceRegistry,
public NON_EXPORTED_BASE(mojo::ServiceProvider) {
public:
+ using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
+
ServiceRegistryImpl();
~ServiceRegistryImpl() override;
@@ -36,10 +38,15 @@ class CONTENT_EXPORT ServiceRegistryImpl
// ServiceProvider.
void BindRemoteServiceProvider(mojo::ServiceProviderPtr service_provider);
+ // Registers a local service factory to intercept ConnectToRemoteService
+ // requests instead of actually connecting to the remote registry. Used only
+ // for testing.
+ void AddServiceOverrideForTesting(const std::string& service_name,
+ const ServiceFactory& service_factory);
+
// ServiceRegistry overrides.
void AddService(const std::string& service_name,
- const base::Callback<void(mojo::ScopedMessagePipeHandle)>
- service_factory) override;
+ const ServiceFactory service_factory) override;
void RemoveService(const std::string& service_name) override;
void ConnectToRemoteService(const base::StringPiece& service_name,
mojo::ScopedMessagePipeHandle handle) override;
@@ -58,11 +65,12 @@ class CONTENT_EXPORT ServiceRegistryImpl
mojo::Binding<mojo::ServiceProvider> binding_;
mojo::ServiceProviderPtr remote_provider_;
- std::map<std::string, base::Callback<void(mojo::ScopedMessagePipeHandle)> >
- service_factories_;
+ std::map<std::string, ServiceFactory> service_factories_;
std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
pending_connects_;
+ std::map<std::string, ServiceFactory> service_overrides_;
+
base::WeakPtrFactory<ServiceRegistry> weak_factory_;
};
« no previous file with comments | « no previous file | content/common/mojo/service_registry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698