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

Unified Diff: services/service_manager/public/cpp/connector.h

Issue 2755813002: Begin to wean child processes off reliance on a persistent service_manager::Connection to the brows… (Closed)
Patch Set: . Created 3 years, 9 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
Index: services/service_manager/public/cpp/connector.h
diff --git a/services/service_manager/public/cpp/connector.h b/services/service_manager/public/cpp/connector.h
index 793fe91d02e4d6696a44087af0e3cafc86638c22..00e8d0a4beccd290851dfec1dfdf1b21d65583f6 100644
--- a/services/service_manager/public/cpp/connector.h
+++ b/services/service_manager/public/cpp/connector.h
@@ -34,6 +34,22 @@ namespace service_manager {
// closed.
class Connector {
public:
+ class TestApi {
+ public:
+ using Binder = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
+ explicit TestApi(Connector* connector) : connector_(connector) {}
+ // Allows caller to specify a callback to bind requests for |interface_name|
+ // locally, rather than passing the request through the Service Manager.
+ void OverrideBinderForTesting(const std::string& interface_name,
+ const Binder& binder) {
+ connector_->OverrideBinderForTesting(interface_name, binder);
+ }
+ void ClearBinderOverrides() { connector_->ClearBinderOverrides(); }
+
+ private:
+ Connector* connector_;
+ };
+
virtual ~Connector() {}
// Creates a new Connector instance and fills in |*request| with a request
@@ -86,6 +102,13 @@ class Connector {
// Binds a Connector request to the other end of this Connector.
virtual void BindConnectorRequest(mojom::ConnectorRequest request) = 0;
+
+ virtual base::WeakPtr<Connector> GetWeakPtr() = 0;
+
+ protected:
+ virtual void OverrideBinderForTesting(const std::string& interface_name,
+ const TestApi::Binder& binder) = 0;
+ virtual void ClearBinderOverrides() = 0;
};
} // namespace service_manager

Powered by Google App Engine
This is Rietveld 408576698