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

Unified Diff: services/shell/public/cpp/interface_provider.h

Issue 2079943002: Change RenderFrame to use InterfaceRegistry et al. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a2
Patch Set: . Created 4 years, 6 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 | « services/shell/public/cpp/connection.h ('k') | services/shell/public/cpp/interface_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/public/cpp/interface_provider.h
diff --git a/services/shell/public/cpp/remote_interface_registry.h b/services/shell/public/cpp/interface_provider.h
similarity index 62%
rename from services/shell/public/cpp/remote_interface_registry.h
rename to services/shell/public/cpp/interface_provider.h
index 7840cdf81b2d345c26575d77d65bd2fa547f9c0c..ccbfbb060fd3502ba5b626a3c19ba35f415b56d0 100644
--- a/services/shell/public/cpp/remote_interface_registry.h
+++ b/services/shell/public/cpp/interface_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef SERVICES_SHELL_PUBLIC_CPP_REMOTE_INTERFACE_REGISTRY_H_
-#define SERVICES_SHELL_PUBLIC_CPP_REMOTE_INTERFACE_REGISTRY_H_
+#ifndef SERVICES_SHELL_PUBLIC_CPP_INTERFACE_PROVIDER_H_
+#define SERVICES_SHELL_PUBLIC_CPP_INTERFACE_PROVIDER_H_
#include "services/shell/public/interfaces/interface_provider.mojom.h"
@@ -16,39 +16,39 @@ namespace shell {
// requests for remote interfaces.
// An instance of this class is used by the GetInterface() methods on
// Connection.
-class RemoteInterfaceRegistry {
+class InterfaceProvider {
public:
class TestApi {
public:
- explicit TestApi(RemoteInterfaceRegistry* registry) : registry_(registry) {}
+ explicit TestApi(InterfaceProvider* provider) : provider_(provider) {}
~TestApi() {}
- template <typename Interface>
void SetBinderForName(
const std::string& name,
- const base::Callback<void(mojo::InterfaceRequest<Interface>)>& binder) {
- registry_->SetBinderForName(name, binder);
+ const base::Callback<void(mojo::ScopedMessagePipeHandle)>& binder) {
+ provider_->SetBinderForName(name, binder);
}
void ClearBinders() {
- registry_->ClearBinders();
+ provider_->ClearBinders();
}
private:
- RemoteInterfaceRegistry* registry_;
+ InterfaceProvider* provider_;
DISALLOW_COPY_AND_ASSIGN(TestApi);
};
- explicit RemoteInterfaceRegistry(
- mojom::InterfaceProviderPtr remote_interfaces);
- ~RemoteInterfaceRegistry();
+ explicit InterfaceProvider(mojom::InterfaceProviderPtr interface_provider);
+ ~InterfaceProvider();
// Returns a raw pointer to the remote InterfaceProvider.
- mojom::InterfaceProvider* GetInterfaceProvider();
+ mojom::InterfaceProvider* get() { return interface_provider_.get(); }
// Sets a closure to be run when the remote InterfaceProvider pipe is closed.
void SetConnectionLostClosure(const base::Closure& connection_lost_closure);
+ base::WeakPtr<InterfaceProvider> GetWeakPtr();
+
// Binds |ptr| to an implementation of Interface in the remote application.
// |ptr| can immediately be used to start sending requests to the remote
// interface.
@@ -57,13 +57,7 @@ class RemoteInterfaceRegistry {
mojo::MessagePipe pipe;
ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u));
- // Local binders can be registered via TestApi.
- auto it = binders_.find(Interface::Name_);
- if (it != binders_.end()) {
- it->second.Run(std::move(pipe.handle1));
- return;
- }
- remote_interfaces_->GetInterface(Interface::Name_, std::move(pipe.handle1));
+ GetInterface(Interface::Name_, std::move(pipe.handle1));
}
template <typename Interface>
void GetInterface(mojo::InterfaceRequest<Interface> request) {
@@ -73,10 +67,9 @@ class RemoteInterfaceRegistry {
mojo::ScopedMessagePipeHandle request_handle);
private:
- template <typename Interface>
void SetBinderForName(
const std::string& name,
- const base::Callback<void(mojo::InterfaceRequest<Interface>)>& binder) {
+ const base::Callback<void(mojo::ScopedMessagePipeHandle)>& binder) {
binders_[name] = binder;
}
void ClearBinders();
@@ -85,11 +78,13 @@ class RemoteInterfaceRegistry {
std::string, base::Callback<void(mojo::ScopedMessagePipeHandle)>>;
BinderMap binders_;
- mojom::InterfaceProviderPtr remote_interfaces_;
+ mojom::InterfaceProviderPtr interface_provider_;
+
+ base::WeakPtrFactory<InterfaceProvider> weak_factory_;
- DISALLOW_COPY_AND_ASSIGN(RemoteInterfaceRegistry);
+ DISALLOW_COPY_AND_ASSIGN(InterfaceProvider);
};
} // namespace shell
-#endif // SERVICES_SHELL_PUBLIC_CPP_REMOTE_INTERFACE_REGISTRY_H_
+#endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_PROVIDER_H_
« no previous file with comments | « services/shell/public/cpp/connection.h ('k') | services/shell/public/cpp/interface_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698