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

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

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, 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 unified diff | Download patch
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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <queue> 12 #include <queue>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "mojo/public/cpp/bindings/connector.h" 20 #include "mojo/public/cpp/bindings/connector.h"
21 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 21 #include "mojo/public/cpp/bindings/filter_chain.h"
22 #include "mojo/public/cpp/bindings/message.h"
22 23
23 namespace mojo { 24 namespace mojo {
24 namespace internal { 25 namespace internal {
25 26
26 // TODO(yzshen): Consider removing this class and use MultiplexRouter in all 27 // TODO(yzshen): Consider removing this class and use MultiplexRouter in all
27 // cases. crbug.com/594244 28 // cases. crbug.com/594244
28 class Router : public MessageReceiverWithResponder { 29 class Router : public MessageReceiverWithResponder {
29 public: 30 public:
30 Router(ScopedMessagePipeHandle message_pipe, 31 Router(ScopedMessagePipeHandle message_pipe,
31 FilterChain filters, 32 FilterChain filters,
(...skipping 19 matching lines...) Expand all
51 DCHECK(thread_checker_.CalledOnValidThread()); 52 DCHECK(thread_checker_.CalledOnValidThread());
52 return encountered_error_; 53 return encountered_error_;
53 } 54 }
54 55
55 // Is the router bound to a MessagePipe handle? 56 // Is the router bound to a MessagePipe handle?
56 bool is_valid() const { 57 bool is_valid() const {
57 DCHECK(thread_checker_.CalledOnValidThread()); 58 DCHECK(thread_checker_.CalledOnValidThread());
58 return connector_.is_valid(); 59 return connector_.is_valid();
59 } 60 }
60 61
62 void AddFilter(std::unique_ptr<MessageReceiver> filter);
63
61 // Please note that this method shouldn't be called unless it results from an 64 // Please note that this method shouldn't be called unless it results from an
62 // explicit request of the user of bindings (e.g., the user sets an 65 // explicit request of the user of bindings (e.g., the user sets an
63 // InterfacePtr to null or closes a Binding). 66 // InterfacePtr to null or closes a Binding).
64 void CloseMessagePipe() { 67 void CloseMessagePipe() {
65 DCHECK(thread_checker_.CalledOnValidThread()); 68 DCHECK(thread_checker_.CalledOnValidThread());
66 connector_.CloseMessagePipe(); 69 connector_.CloseMessagePipe();
67 } 70 }
68 71
69 ScopedMessagePipeHandle PassMessagePipe() { 72 ScopedMessagePipeHandle PassMessagePipe() {
70 DCHECK(thread_checker_.CalledOnValidThread()); 73 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 bool encountered_error_; 173 bool encountered_error_;
171 base::Closure error_handler_; 174 base::Closure error_handler_;
172 base::ThreadChecker thread_checker_; 175 base::ThreadChecker thread_checker_;
173 base::WeakPtrFactory<Router> weak_factory_; 176 base::WeakPtrFactory<Router> weak_factory_;
174 }; 177 };
175 178
176 } // namespace internal 179 } // namespace internal
177 } // namespace mojo 180 } // namespace mojo
178 181
179 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 182 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/multiplex_router.cc ('k') | mojo/public/cpp/bindings/lib/router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698