Index: mojo/public/cpp/bindings/lib/connector.cc |
diff --git a/mojo/public/cpp/bindings/lib/connector.cc b/mojo/public/cpp/bindings/lib/connector.cc |
index 9f1037ceae81b09ef3948d6532b7f1cec9a524ff..d1cb1dc25e7229ced69e31fd1ad80127da014fd7 100644 |
--- a/mojo/public/cpp/bindings/lib/connector.cc |
+++ b/mojo/public/cpp/bindings/lib/connector.cc |
@@ -87,8 +87,13 @@ ScopedMessagePipeHandle Connector::PassMessagePipe() { |
return std::move(message_pipe_); |
} |
-void Connector::RaiseError() { |
+void Connector::RaiseError(Result error) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK(!error.Succeeded()); |
+ |
+ // If this was a message validation error, notify the system of a bad message. |
+ if (error.type() == Result::Type::BAD_MESSAGE) |
+ error.message().NotifyBadMessage(error.details()); |
HandleError(true, true); |
} |
@@ -135,19 +140,19 @@ void Connector::ResumeIncomingMethodCallProcessing() { |
WaitToReadMore(); |
} |
-bool Connector::Accept(Message* message) { |
+MessageReceiver::Result Connector::Accept(Message* message) { |
DCHECK(lock_ || thread_checker_.CalledOnValidThread()); |
// It shouldn't hurt even if |error_| may be changed by a different thread at |
// the same time. The outcome is that we may write into |message_pipe_| after |
// encountering an error, which should be fine. |
if (error_) |
- return false; |
+ return Result(Result::Type::SEND_FAILED); |
MayAutoLock locker(lock_.get()); |
if (!message_pipe_.is_valid() || drop_writes_) |
- return true; |
+ return Result::ForSuccess(); |
MojoResult rv = |
WriteMessageNew(message_pipe_.get(), message->TakeMojoMessage(), |
@@ -175,13 +180,13 @@ bool Connector::Accept(Message* message) { |
// crbug.com/389666, etc. are resolved, this will make tests fail quickly |
// rather than hanging.) |
CHECK(false) << "Race condition or other bug detected"; |
- return false; |
+ return Result(Result::Type::SEND_FAILED); |
default: |
// This particular write was rejected, presumably because of bad input. |
// The pipe is not necessarily in a bad state. |
- return false; |
+ return Result(Result::Type::SEND_FAILED); |
} |
- return true; |
+ return Result::ForSuccess(); |
} |
void Connector::AllowWokenUpBySyncWatchOnSameThread() { |
@@ -256,7 +261,7 @@ void Connector::WaitToReadMore() { |
bool Connector::ReadSingleMessage(MojoResult* read_result) { |
CHECK(!paused_); |
- bool receiver_result = false; |
+ bool received_message = false; |
// Detect if |this| was destroyed during message dispatch. Allow for the |
// possibility of re-entering ReadMore() through message dispatch. |
@@ -266,9 +271,11 @@ bool Connector::ReadSingleMessage(MojoResult* read_result) { |
const MojoResult rv = ReadMessage(message_pipe_.get(), &message); |
*read_result = rv; |
- if (rv == MOJO_RESULT_OK) { |
- receiver_result = |
- incoming_receiver_ && incoming_receiver_->Accept(&message); |
+ if (rv == MOJO_RESULT_OK && incoming_receiver_) { |
+ Result result = incoming_receiver_->Accept(&message); |
+ if (result.type() == Result::Type::BAD_MESSAGE) |
+ result.message().NotifyBadMessage(result.details()); |
+ received_message = result.Succeeded(); |
} |
if (!weak_self) |
@@ -282,7 +289,7 @@ bool Connector::ReadSingleMessage(MojoResult* read_result) { |
return false; |
} |
- if (enforce_errors_from_incoming_receiver_ && !receiver_result) { |
+ if (enforce_errors_from_incoming_receiver_ && !received_message) { |
HandleError(true, false); |
return false; |
} |