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

Side by Side Diff: mojo/public/cpp/bindings/message.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/router.cc ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('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_MESSAGE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "mojo/public/cpp/bindings/lib/message_internal.h" 10 #include "mojo/public/cpp/bindings/lib/message_internal.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // AcceptWithResponder or some time after its return. 99 // AcceptWithResponder or some time after its return.
100 // 100 //
101 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of 101 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of
102 // |responder| and will delete it after calling |responder->Accept| or upon 102 // |responder| and will delete it after calling |responder->Accept| or upon
103 // its own destruction. 103 // its own destruction.
104 // 104 //
105 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) 105 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder)
106 MOJO_WARN_UNUSED_RESULT = 0; 106 MOJO_WARN_UNUSED_RESULT = 0;
107 }; 107 };
108 108
109 // A MessageReceiver that is also able to provide status about the state
110 // of the underlying MessagePipe to which it will be forwarding messages
111 // received via the |Accept()| call.
112 class MessageReceiverWithStatus : public MessageReceiver {
113 public:
114 ~MessageReceiverWithStatus() override {}
115
116 // Returns |true| if this MessageReceiver is currently bound to a MessagePipe,
117 // the pipe has not been closed, and the pipe has not encountered an error.
118 virtual bool IsValid() = 0;
119 };
120
121 // An alternative to MessageReceiverWithResponder for cases in which it
122 // is necessary for the implementor of this interface to know about the status
123 // of the MessagePipe which will carry the responses.
124 class MessageReceiverWithResponderStatus : public MessageReceiver {
125 public:
126 ~MessageReceiverWithResponderStatus() override {}
127
128 // A variant on Accept that registers a MessageReceiverWithStatus (known as
129 // the responder) to handle the response message generated from the given
130 // message. Any of the responder's methods (Accept or IsValid) may be called
131 // during AcceptWithResponder or some time after its return.
132 //
133 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of
134 // |responder| and will delete it after calling |responder->Accept| or upon
135 // its own destruction.
136 //
137 virtual bool AcceptWithResponder(Message* message,
138 MessageReceiverWithStatus* responder)
139 MOJO_WARN_UNUSED_RESULT = 0;
140 };
141
109 // Read a single message from the pipe and dispatch to the given receiver. The 142 // Read a single message from the pipe and dispatch to the given receiver. The
110 // receiver may be null, in which case the message is simply discarded. 143 // receiver may be null, in which case the message is simply discarded.
111 // Returns MOJO_RESULT_SHOULD_WAIT if the caller should wait on the handle to 144 // Returns MOJO_RESULT_SHOULD_WAIT if the caller should wait on the handle to
112 // become readable. Returns MOJO_RESULT_OK if a message was dispatched and 145 // become readable. Returns MOJO_RESULT_OK if a message was dispatched and
113 // otherwise returns an error code if something went wrong. 146 // otherwise returns an error code if something went wrong.
114 // 147 //
115 // NOTE: The message hasn't been validated and may be malformed! 148 // NOTE: The message hasn't been validated and may be malformed!
116 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, 149 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle,
117 MessageReceiver* receiver, 150 MessageReceiver* receiver,
118 bool* receiver_result); 151 bool* receiver_result);
119 152
120 } // namespace mojo 153 } // namespace mojo
121 154
122 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 155 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.cc ('k') | mojo/public/cpp/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698