Index: mojo/public/cpp/bindings/lib/multiplex_router.cc |
diff --git a/mojo/public/cpp/bindings/lib/multiplex_router.cc b/mojo/public/cpp/bindings/lib/multiplex_router.cc |
index a8d06a45f93f942f968f2096f7f8c5083ef9601e..d5538bce1ba72eab0f651d96a802df0c62839110 100644 |
--- a/mojo/public/cpp/bindings/lib/multiplex_router.cc |
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.cc |
@@ -111,7 +111,9 @@ class MultiplexRouter::InterfaceEndpoint |
bool SendMessage(Message* message) override { |
DCHECK(task_runner_->BelongsToCurrentThread()); |
message->set_interface_id(id_); |
- return router_->connector_.Accept(message); |
+ |
+ Error send_error; |
+ return router_->connector_.Accept(message, &send_error); |
} |
void AllowWokenUpBySyncWatchOnSameThread() override { |
@@ -430,12 +432,13 @@ void MultiplexRouter::DetachEndpointClient( |
endpoint->DetachClient(); |
} |
-void MultiplexRouter::RaiseError() { |
+void MultiplexRouter::RaiseError(Error error) { |
if (task_runner_->BelongsToCurrentThread()) { |
- connector_.RaiseError(); |
+ connector_.RaiseError(std::move(error)); |
} else { |
task_runner_->PostTask(FROM_HERE, |
- base::Bind(&MultiplexRouter::RaiseError, this)); |
+ base::Bind(&MultiplexRouter::RaiseError, this, |
+ base::Passed(&error))); |
} |
} |
@@ -471,6 +474,12 @@ bool MultiplexRouter::HasAssociatedEndpoints() const { |
return !ContainsKey(endpoints_, kMasterInterfaceId); |
} |
+void MultiplexRouter::SetMasterInterfaceName(const std::string& name) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ master_interface_name_ = name; |
+ header_validator_.set_debug_info(name + " master interface header validator"); |
+} |
+ |
void MultiplexRouter::EnableTestingMode() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
base::AutoLock locker(lock_); |
@@ -479,7 +488,7 @@ void MultiplexRouter::EnableTestingMode() { |
connector_.set_enforce_errors_from_incoming_receiver(false); |
} |
-bool MultiplexRouter::Accept(Message* message) { |
+bool MultiplexRouter::Accept(Message* message, Error* error) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
scoped_refptr<MultiplexRouter> protector(this); |
@@ -706,8 +715,9 @@ bool MultiplexRouter::ProcessIncomingMessage( |
} |
if (PipeControlMessageHandler::IsPipeControlMessage(message)) { |
- if (!control_message_handler_.Accept(message)) |
- RaiseErrorInNonTestingMode(); |
+ Error error; |
+ if (!control_message_handler_.Accept(message, &error)) |
+ RaiseErrorInNonTestingMode(std::move(error)); |
return true; |
} |
@@ -763,6 +773,7 @@ bool MultiplexRouter::ProcessIncomingMessage( |
DCHECK(endpoint->task_runner()->BelongsToCurrentThread()); |
InterfaceEndpointClient* client = endpoint->client(); |
+ Error error(Error::Type::NONE); |
bool result = false; |
{ |
// We must unlock before calling into |client| because it may call this |
@@ -772,10 +783,10 @@ bool MultiplexRouter::ProcessIncomingMessage( |
// It is safe to call into |client| without the lock. Because |client| is |
// always accessed on the same thread, including DetachEndpointClient(). |
base::AutoUnlock unlocker(lock_); |
- result = client->HandleIncomingMessage(message); |
+ result = client->HandleIncomingMessage(message, &error); |
} |
if (!result) |
- RaiseErrorInNonTestingMode(); |
+ RaiseErrorInNonTestingMode(std::move(error)); |
return true; |
} |
@@ -820,10 +831,10 @@ void MultiplexRouter::UpdateEndpointStateMayRemove( |
endpoints_.erase(endpoint->id()); |
} |
-void MultiplexRouter::RaiseErrorInNonTestingMode() { |
+void MultiplexRouter::RaiseErrorInNonTestingMode(Error error) { |
lock_.AssertAcquired(); |
if (!testing_mode_) |
- RaiseError(); |
+ RaiseError(std::move(error)); |
} |
MultiplexRouter::InterfaceEndpoint* MultiplexRouter::FindOrInsertEndpoint( |