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

Unified Diff: mojo/public/cpp/bindings/lib/router.cc

Issue 2280483002: Add FlushForTesting to InterfacePtr and Binding. (Closed)
Patch Set: Created 4 years, 4 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: mojo/public/cpp/bindings/lib/router.cc
diff --git a/mojo/public/cpp/bindings/lib/router.cc b/mojo/public/cpp/bindings/lib/router.cc
index 5d5db54caa13981a0f96b1f9d0b12826b5963513..2555688c68024701fab5bfe5e958301d37b44ff9 100644
--- a/mojo/public/cpp/bindings/lib/router.cc
+++ b/mojo/public/cpp/bindings/lib/router.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
+#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
namespace mojo {
@@ -118,7 +119,8 @@ bool Router::HandleIncomingMessageThunk::Accept(Message* message) {
Router::Router(ScopedMessagePipeHandle message_pipe,
FilterChain filters,
bool expects_sync_requests,
- scoped_refptr<base::SingleThreadTaskRunner> runner)
+ scoped_refptr<base::SingleThreadTaskRunner> runner,
+ int interface_version)
: thunk_(this),
filters_(std::move(filters)),
connector_(std::move(message_pipe),
@@ -129,6 +131,8 @@ Router::Router(ScopedMessagePipeHandle message_pipe,
testing_mode_(false),
pending_task_for_messages_(false),
encountered_error_(false),
+ control_message_proxy_(this),
+ control_message_handler_(interface_version),
weak_factory_(this) {
filters_.SetSink(&thunk_);
if (expects_sync_requests)
@@ -136,6 +140,7 @@ Router::Router(ScopedMessagePipeHandle message_pipe,
connector_.set_incoming_receiver(&filters_);
connector_.set_connection_error_handler(
base::Bind(&Router::OnConnectionError, base::Unretained(this)));
+ filters_.Append(base::MakeUnique<ControlMessageValidator>());
}
Router::~Router() {}
@@ -253,12 +258,18 @@ bool Router::HandleMessageInternal(Message* message) {
DCHECK(!encountered_error_);
if (message->has_flag(Message::kFlagExpectsResponse)) {
- if (!incoming_receiver_)
+ if (!incoming_receiver_ &&
yzshen1 2016/08/29 23:24:58 Maybe we don't need this check (and also line 303)
Sam McNally 2016/08/30 03:05:52 Done.
+ !mojo::internal::ControlMessageHandler::IsControlMessage(message)) {
return false;
-
+ }
MessageReceiverWithStatus* responder = new ResponderThunk(
weak_factory_.GetWeakPtr(), connector_.task_runner());
- bool ok = incoming_receiver_->AcceptWithResponder(message, responder);
+ bool ok = false;
+ if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) {
+ ok = control_message_handler_.AcceptWithResponder(message, responder);
+ } else {
+ ok = incoming_receiver_->AcceptWithResponder(message, responder);
+ }
if (!ok)
delete responder;
return ok;
@@ -286,6 +297,9 @@ bool Router::HandleMessageInternal(Message* message) {
async_responders_.erase(it);
return responder->Accept(message);
} else {
+ if (mojo::internal::ControlMessageHandler::IsControlMessage(message))
+ return control_message_handler_.Accept(message);
+
if (!incoming_receiver_)
return false;
@@ -313,6 +327,8 @@ void Router::OnConnectionError() {
return;
}
+ control_message_proxy_.OnConnectionError();
+
encountered_error_ = true;
// The callbacks may hold on to resources. There is no need to keep them any

Powered by Google App Engine
This is Rietveld 408576698