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..0934ee15ce2803570448310547e73216da6a4a18 100644 |
--- a/services/shell/public/cpp/lib/interface_provider.cc |
+++ b/services/shell/public/cpp/lib/interface_provider.cc |
@@ -4,19 +4,32 @@ |
#include "services/shell/public/cpp/interface_provider.h" |
+#include "base/macros.h" |
+#include "mojo/public/cpp/bindings/strong_binding.h" |
+ |
namespace shell { |
InterfaceProvider::InterfaceProvider() : weak_factory_(this) { |
pending_request_ = GetProxy(&interface_provider_); |
} |
+ |
InterfaceProvider::~InterfaceProvider() {} |
void InterfaceProvider::Bind(mojom::InterfaceProviderPtr interface_provider) { |
DCHECK(pending_request_.is_pending()); |
+ DCHECK(forward_callback_.is_null()); |
mojo::FuseInterface(std::move(pending_request_), |
interface_provider.PassInterface()); |
} |
+void InterfaceProvider::Forward(const ForwardCallback& callback) { |
+ DCHECK(pending_request_.is_pending()); |
+ DCHECK(forward_callback_.is_null()); |
+ interface_provider_.reset(); |
+ pending_request_.PassMessagePipe().reset(); |
+ forward_callback_ = callback; |
+} |
+ |
void InterfaceProvider::SetConnectionLostClosure( |
const base::Closure& connection_lost_closure) { |
interface_provider_.set_connection_error_handler(connection_lost_closure); |
@@ -35,7 +48,14 @@ void InterfaceProvider::GetInterface( |
it->second.Run(std::move(request_handle)); |
return; |
} |
- interface_provider_->GetInterface(name, std::move(request_handle)); |
+ |
+ if (!forward_callback_.is_null()) { |
+ DCHECK(!interface_provider_.is_bound()); |
+ forward_callback_.Run(name, std::move(request_handle)); |
+ } else { |
+ DCHECK(interface_provider_.is_bound()); |
+ interface_provider_->GetInterface(name, std::move(request_handle)); |
+ } |
} |
void InterfaceProvider::ClearBinders() { |