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..d1a95bed67e970470ef3474d8f304ce773e2d255 100644 |
--- a/mojo/public/cpp/bindings/lib/multiplex_router.cc |
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.cc |
@@ -111,7 +111,8 @@ class MultiplexRouter::InterfaceEndpoint |
bool SendMessage(Message* message) override { |
DCHECK(task_runner_->BelongsToCurrentThread()); |
message->set_interface_id(id_); |
- return router_->connector_.Accept(message); |
+ |
+ return router_->connector_.Accept(message).Succeeded(); |
} |
void AllowWokenUpBySyncWatchOnSameThread() override { |
@@ -430,12 +431,13 @@ void MultiplexRouter::DetachEndpointClient( |
endpoint->DetachClient(); |
} |
-void MultiplexRouter::RaiseError() { |
+void MultiplexRouter::RaiseError(Result 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 +473,12 @@ bool MultiplexRouter::HasAssociatedEndpoints() const { |
return !ContainsKey(endpoints_, kMasterInterfaceId); |
} |
+void MultiplexRouter::SetMasterInterfaceName(const std::string& name) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ control_message_handler_.set_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 +487,7 @@ void MultiplexRouter::EnableTestingMode() { |
connector_.set_enforce_errors_from_incoming_receiver(false); |
} |
-bool MultiplexRouter::Accept(Message* message) { |
+MessageReceiver::Result MultiplexRouter::Accept(Message* message) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
scoped_refptr<MultiplexRouter> protector(this); |
@@ -514,9 +522,9 @@ bool MultiplexRouter::Accept(Message* message) { |
ProcessTasks(client_call_behavior, connector_.task_runner()); |
} |
- // Always return true. If we see errors during message processing, we will |
+ // Always succeed. If we see errors during message processing, we will |
// explicitly call Connector::RaiseError() to disconnect the message pipe. |
- return true; |
+ return Result::ForSuccess(); |
} |
bool MultiplexRouter::OnPeerAssociatedEndpointClosed(InterfaceId id) { |
@@ -706,8 +714,9 @@ bool MultiplexRouter::ProcessIncomingMessage( |
} |
if (PipeControlMessageHandler::IsPipeControlMessage(message)) { |
- if (!control_message_handler_.Accept(message)) |
- RaiseErrorInNonTestingMode(); |
+ Result result = control_message_handler_.Accept(message); |
+ if (!result.Succeeded()) |
+ RaiseErrorInNonTestingMode(std::move(result)); |
return true; |
} |
@@ -763,7 +772,7 @@ bool MultiplexRouter::ProcessIncomingMessage( |
DCHECK(endpoint->task_runner()->BelongsToCurrentThread()); |
InterfaceEndpointClient* client = endpoint->client(); |
- bool result = false; |
+ Result result(Result::Type::UNKNOWN_ERROR); |
{ |
// We must unlock before calling into |client| because it may call this |
// object within HandleIncomingMessage(). Holding the lock will lead to |
@@ -774,8 +783,8 @@ bool MultiplexRouter::ProcessIncomingMessage( |
base::AutoUnlock unlocker(lock_); |
result = client->HandleIncomingMessage(message); |
} |
- if (!result) |
- RaiseErrorInNonTestingMode(); |
+ if (!result.Succeeded()) |
+ RaiseErrorInNonTestingMode(std::move(result)); |
return true; |
} |
@@ -820,10 +829,10 @@ void MultiplexRouter::UpdateEndpointStateMayRemove( |
endpoints_.erase(endpoint->id()); |
} |
-void MultiplexRouter::RaiseErrorInNonTestingMode() { |
+void MultiplexRouter::RaiseErrorInNonTestingMode(Result error) { |
lock_.AssertAcquired(); |
if (!testing_mode_) |
- RaiseError(); |
+ RaiseError(std::move(error)); |
} |
MultiplexRouter::InterfaceEndpoint* MultiplexRouter::FindOrInsertEndpoint( |