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

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

Issue 1003773002: CPP bindings: DCHECK when a Callback is destructed without being invoked (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased again Created 5 years, 8 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/connector.h ('k') | mojo/public/cpp/bindings/lib/router.cc » ('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 #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 <map> 8 #include <map>
9 9
10 #include "mojo/public/cpp/bindings/lib/connector.h" 10 #include "mojo/public/cpp/bindings/lib/connector.h"
11 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 11 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
12 #include "mojo/public/cpp/bindings/lib/shared_data.h" 12 #include "mojo/public/cpp/bindings/lib/shared_data.h"
13 #include "mojo/public/cpp/environment/environment.h" 13 #include "mojo/public/cpp/environment/environment.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 namespace internal { 16 namespace internal {
17 17
18 class Router : public MessageReceiverWithResponder { 18 class Router : public MessageReceiverWithResponder {
19 public: 19 public:
20 Router(ScopedMessagePipeHandle message_pipe, 20 Router(ScopedMessagePipeHandle message_pipe,
21 FilterChain filters, 21 FilterChain filters,
22 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()); 22 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter());
23 ~Router() override; 23 ~Router() override;
24 24
25 // Sets the receiver to handle messages read from the message pipe that do 25 // Sets the receiver to handle messages read from the message pipe that do
26 // not have the kMessageIsResponse flag set. 26 // not have the kMessageIsResponse flag set.
27 void set_incoming_receiver(MessageReceiverWithResponder* receiver) { 27 void set_incoming_receiver(MessageReceiverWithResponderStatus* receiver) {
28 incoming_receiver_ = receiver; 28 incoming_receiver_ = receiver;
29 } 29 }
30 30
31 // Sets the error handler to receive notifications when an error is 31 // Sets the error handler to receive notifications when an error is
32 // encountered while reading from the pipe or waiting to read from the pipe. 32 // encountered while reading from the pipe or waiting to read from the pipe.
33 void set_error_handler(ErrorHandler* error_handler) { 33 void set_error_handler(ErrorHandler* error_handler) {
34 connector_.set_error_handler(error_handler); 34 connector_.set_error_handler(error_handler);
35 } 35 }
36 36
37 // Returns true if an error was encountered while reading from the pipe or 37 // Returns true if an error was encountered while reading from the pipe or
38 // waiting to read from the pipe. 38 // waiting to read from the pipe.
39 bool encountered_error() const { return connector_.encountered_error(); } 39 bool encountered_error() const { return connector_.encountered_error(); }
40 40
41 // Is the router bound to a MessagePipe handle?
42 bool is_valid() const { return connector_.is_valid(); }
43
41 void CloseMessagePipe() { connector_.CloseMessagePipe(); } 44 void CloseMessagePipe() { connector_.CloseMessagePipe(); }
42 45
43 ScopedMessagePipeHandle PassMessagePipe() { 46 ScopedMessagePipeHandle PassMessagePipe() {
44 return connector_.PassMessagePipe(); 47 return connector_.PassMessagePipe();
45 } 48 }
46 49
47 // MessageReceiver implementation: 50 // MessageReceiver implementation:
48 bool Accept(Message* message) override; 51 bool Accept(Message* message) override;
49 bool AcceptWithResponder(Message* message, 52 bool AcceptWithResponder(Message* message,
50 MessageReceiver* responder) override; 53 MessageReceiver* responder) override;
(...skipping 23 matching lines...) Expand all
74 private: 77 private:
75 Router* router_; 78 Router* router_;
76 }; 79 };
77 80
78 bool HandleIncomingMessage(Message* message); 81 bool HandleIncomingMessage(Message* message);
79 82
80 HandleIncomingMessageThunk thunk_; 83 HandleIncomingMessageThunk thunk_;
81 FilterChain filters_; 84 FilterChain filters_;
82 Connector connector_; 85 Connector connector_;
83 SharedData<Router*> weak_self_; 86 SharedData<Router*> weak_self_;
84 MessageReceiverWithResponder* incoming_receiver_; 87 MessageReceiverWithResponderStatus* incoming_receiver_;
85 ResponderMap responders_; 88 ResponderMap responders_;
86 uint64_t next_request_id_; 89 uint64_t next_request_id_;
87 bool testing_mode_; 90 bool testing_mode_;
88 }; 91 };
89 92
90 } // namespace internal 93 } // namespace internal
91 } // namespace mojo 94 } // namespace mojo
92 95
93 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 96 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.h ('k') | mojo/public/cpp/bindings/lib/router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698