| 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 <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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 virtual ~MessageReceiver() {} | 84 virtual ~MessageReceiver() {} |
| 85 | 85 |
| 86 // The receiver may mutate the given message. Returns true if the message | 86 // The receiver may mutate the given message. Returns true if the message |
| 87 // was accepted and false otherwise, indicating that the message was invalid | 87 // was accepted and false otherwise, indicating that the message was invalid |
| 88 // or malformed. | 88 // or malformed. |
| 89 virtual bool Accept(Message* message) MOJO_WARN_UNUSED_RESULT = 0; | 89 virtual bool Accept(Message* message) MOJO_WARN_UNUSED_RESULT = 0; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 class MessageReceiverWithResponder : public MessageReceiver { | 92 class MessageReceiverWithResponder : public MessageReceiver { |
| 93 public: | 93 public: |
| 94 virtual ~MessageReceiverWithResponder() {} | 94 ~MessageReceiverWithResponder() override {} |
| 95 | 95 |
| 96 // A variant on Accept that registers a MessageReceiver (known as the | 96 // A variant on Accept that registers a MessageReceiver (known as the |
| 97 // responder) to handle the response message generated from the given | 97 // responder) to handle the response message generated from the given |
| 98 // message. The responder's Accept method may be called during | 98 // message. The responder's Accept method may be called during |
| 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 // Read a single message from the pipe and dispatch to the given receiver. The | 109 // 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. | 110 // 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 | 111 // 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 | 112 // become readable. Returns MOJO_RESULT_OK if a message was dispatched and |
| 113 // otherwise returns an error code if something went wrong. | 113 // otherwise returns an error code if something went wrong. |
| 114 // | 114 // |
| 115 // NOTE: The message hasn't been validated and may be malformed! | 115 // NOTE: The message hasn't been validated and may be malformed! |
| 116 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, | 116 MojoResult ReadAndDispatchMessage(MessagePipeHandle handle, |
| 117 MessageReceiver* receiver, | 117 MessageReceiver* receiver, |
| 118 bool* receiver_result); | 118 bool* receiver_result); |
| 119 | 119 |
| 120 } // namespace mojo | 120 } // namespace mojo |
| 121 | 121 |
| 122 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ | 122 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ |
| OLD | NEW |