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

Side by Side Diff: mojo/public/cpp/bindings/lib/router.cc

Issue 2276043002: Support custom message filtering on Mojo binding objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.h ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/lib/router.h" 5 #include "mojo/public/cpp/bindings/lib/router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 std::move(runner)), 126 std::move(runner)),
127 incoming_receiver_(nullptr), 127 incoming_receiver_(nullptr),
128 next_request_id_(0), 128 next_request_id_(0),
129 testing_mode_(false), 129 testing_mode_(false),
130 pending_task_for_messages_(false), 130 pending_task_for_messages_(false),
131 encountered_error_(false), 131 encountered_error_(false),
132 weak_factory_(this) { 132 weak_factory_(this) {
133 filters_.SetSink(&thunk_); 133 filters_.SetSink(&thunk_);
134 if (expects_sync_requests) 134 if (expects_sync_requests)
135 connector_.AllowWokenUpBySyncWatchOnSameThread(); 135 connector_.AllowWokenUpBySyncWatchOnSameThread();
136 connector_.set_incoming_receiver(filters_.GetHead()); 136 connector_.set_incoming_receiver(&filters_);
137 connector_.set_connection_error_handler( 137 connector_.set_connection_error_handler(
138 base::Bind(&Router::OnConnectionError, base::Unretained(this))); 138 base::Bind(&Router::OnConnectionError, base::Unretained(this)));
139 } 139 }
140 140
141 Router::~Router() {} 141 Router::~Router() {}
142 142
143 void Router::AddFilter(std::unique_ptr<MessageReceiver> filter) {
144 filters_.Append(std::move(filter));
145 }
146
143 bool Router::Accept(Message* message) { 147 bool Router::Accept(Message* message) {
144 DCHECK(thread_checker_.CalledOnValidThread()); 148 DCHECK(thread_checker_.CalledOnValidThread());
145 DCHECK(!message->has_flag(Message::kFlagExpectsResponse)); 149 DCHECK(!message->has_flag(Message::kFlagExpectsResponse));
146 return connector_.Accept(message); 150 return connector_.Accept(message);
147 } 151 }
148 152
149 bool Router::AcceptWithResponder(Message* message, MessageReceiver* responder) { 153 bool Router::AcceptWithResponder(Message* message, MessageReceiver* responder) {
150 DCHECK(thread_checker_.CalledOnValidThread()); 154 DCHECK(thread_checker_.CalledOnValidThread());
151 DCHECK(message->has_flag(Message::kFlagExpectsResponse)); 155 DCHECK(message->has_flag(Message::kFlagExpectsResponse));
152 156
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 async_responders_.clear(); 320 async_responders_.clear();
317 321
318 if (!error_handler_.is_null()) 322 if (!error_handler_.is_null())
319 error_handler_.Run(); 323 error_handler_.Run();
320 } 324 }
321 325
322 // ---------------------------------------------------------------------------- 326 // ----------------------------------------------------------------------------
323 327
324 } // namespace internal 328 } // namespace internal
325 } // namespace mojo 329 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.h ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698