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

Unified Diff: services/shell/public/cpp/lib/interface_provider.cc

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
Index: services/shell/public/cpp/lib/interface_provider.cc
diff --git a/services/shell/public/cpp/lib/interface_provider.cc b/services/shell/public/cpp/lib/interface_provider.cc
index 209d356ac476bb6a79d8cfc51f389500c8b297b7..77fb6f168eb12deda03d46d3aca3aafc8c5e5b4f 100644
--- a/services/shell/public/cpp/lib/interface_provider.cc
+++ b/services/shell/public/cpp/lib/interface_provider.cc
@@ -4,11 +4,40 @@
#include "services/shell/public/cpp/interface_provider.h"
+#include "base/macros.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
namespace shell {
+namespace {
+
+class ForwardingInterfaceProvider : public mojom::InterfaceProvider {
+ public:
+ ForwardingInterfaceProvider(
+ const shell::InterfaceProvider::ForwardCallback& callback,
+ mojom::InterfaceProviderRequest request)
+ : callback_(callback), binding_(this, std::move(request)) {}
+ ~ForwardingInterfaceProvider() override {}
+
+ private:
+ // mojom::InterfaceProvider:
+ void GetInterface(const mojo::String& interface_name,
+ mojo::ScopedMessagePipeHandle request_handle) override {
+ callback_.Run(interface_name, std::move(request_handle));
+ }
+
+ shell::InterfaceProvider::ForwardCallback callback_;
+ mojo::StrongBinding<mojom::InterfaceProvider> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForwardingInterfaceProvider);
+};
+
+} // namespace
+
InterfaceProvider::InterfaceProvider() : weak_factory_(this) {
pending_request_ = GetProxy(&interface_provider_);
}
+
InterfaceProvider::~InterfaceProvider() {}
void InterfaceProvider::Bind(mojom::InterfaceProviderPtr interface_provider) {
@@ -17,6 +46,13 @@ void InterfaceProvider::Bind(mojom::InterfaceProviderPtr interface_provider) {
interface_provider.PassInterface());
}
+void InterfaceProvider::Forward(const ForwardCallback& callback) {
+ DCHECK(pending_request_.is_pending());
+
+ // Owns itself.
+ new ForwardingInterfaceProvider(callback, std::move(pending_request_));
+}
+
void InterfaceProvider::SetConnectionLostClosure(
const base::Closure& connection_lost_closure) {
interface_provider_.set_connection_error_handler(connection_lost_closure);

Powered by Google App Engine
This is Rietveld 408576698