| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 // A variant on Accept that registers a MessageReceiver (known as the | 116 // A variant on Accept that registers a MessageReceiver (known as the |
| 117 // responder) to handle the response message generated from the given | 117 // responder) to handle the response message generated from the given |
| 118 // message. The responder's Accept method may be called during | 118 // message. The responder's Accept method may be called during |
| 119 // AcceptWithResponder or some time after its return. | 119 // AcceptWithResponder or some time after its return. |
| 120 // | 120 // |
| 121 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of | 121 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of |
| 122 // |responder| and will delete it after calling |responder->Accept| or upon | 122 // |responder| and will delete it after calling |responder->Accept| or upon |
| 123 // its own destruction. | 123 // its own destruction. |
| 124 // | 124 // |
| 125 // TODO(yzshen): consider changing |responder| to scoped_ptr<MessageReceiver>. | |
| 126 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) | 125 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) |
| 127 MOJO_WARN_UNUSED_RESULT = 0; | 126 MOJO_WARN_UNUSED_RESULT = 0; |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 // A MessageReceiver that is also able to provide status about the state | 129 // A MessageReceiver that is also able to provide status about the state |
| 131 // of the underlying MessagePipe to which it will be forwarding messages | 130 // of the underlying MessagePipe to which it will be forwarding messages |
| 132 // received via the |Accept()| call. | 131 // received via the |Accept()| call. |
| 133 class MessageReceiverWithStatus : public MessageReceiver { | 132 class MessageReceiverWithStatus : public MessageReceiver { |
| 134 public: | 133 public: |
| 135 ~MessageReceiverWithStatus() override {} | 134 ~MessageReceiverWithStatus() override {} |
| (...skipping 12 matching lines...) Expand all Loading... |
| 148 | 147 |
| 149 // A variant on Accept that registers a MessageReceiverWithStatus (known as | 148 // A variant on Accept that registers a MessageReceiverWithStatus (known as |
| 150 // the responder) to handle the response message generated from the given | 149 // the responder) to handle the response message generated from the given |
| 151 // message. Any of the responder's methods (Accept or IsValid) may be called | 150 // message. Any of the responder's methods (Accept or IsValid) may be called |
| 152 // during AcceptWithResponder or some time after its return. | 151 // during AcceptWithResponder or some time after its return. |
| 153 // | 152 // |
| 154 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of | 153 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of |
| 155 // |responder| and will delete it after calling |responder->Accept| or upon | 154 // |responder| and will delete it after calling |responder->Accept| or upon |
| 156 // its own destruction. | 155 // its own destruction. |
| 157 // | 156 // |
| 158 // TODO(yzshen): consider changing |responder| to scoped_ptr<MessageReceiver>. | |
| 159 virtual bool AcceptWithResponder(Message* message, | 157 virtual bool AcceptWithResponder(Message* message, |
| 160 MessageReceiverWithStatus* responder) | 158 MessageReceiverWithStatus* responder) |
| 161 MOJO_WARN_UNUSED_RESULT = 0; | 159 MOJO_WARN_UNUSED_RESULT = 0; |
| 162 }; | 160 }; |
| 163 | 161 |
| 164 // Read a single message from the pipe. The caller should have created the | 162 // Read a single message from the pipe. The caller should have created the |
| 165 // Message, but not called Initialize(). Returns MOJO_RESULT_SHOULD_WAIT if | 163 // Message, but not called Initialize(). Returns MOJO_RESULT_SHOULD_WAIT if |
| 166 // the caller should wait on the handle to become readable. Returns | 164 // the caller should wait on the handle to become readable. Returns |
| 167 // MOJO_RESULT_OK if the message was read successfully and should be | 165 // MOJO_RESULT_OK if the message was read successfully and should be |
| 168 // dispatched, otherwise returns an error code if something went wrong. | 166 // dispatched, otherwise returns an error code if something went wrong. |
| 169 // | 167 // |
| 170 // NOTE: The message hasn't been validated and may be malformed! | 168 // NOTE: The message hasn't been validated and may be malformed! |
| 171 MojoResult ReadMessage(MessagePipeHandle handle, Message* message); | 169 MojoResult ReadMessage(MessagePipeHandle handle, Message* message); |
| 172 | 170 |
| 173 } // namespace mojo | 171 } // namespace mojo |
| 174 | 172 |
| 175 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ | 173 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ |
| OLD | NEW |