| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
| 6 #define MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 6 #define MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // dispatcher, e.g., to read messages and to wait. Implementations of this class | 31 // dispatcher, e.g., to read messages and to wait. Implementations of this class |
| 32 // are not thread-safe; instances are protected by |MesssagePipe|'s lock. | 32 // are not thread-safe; instances are protected by |MesssagePipe|'s lock. |
| 33 class MOJO_SYSTEM_EXPORT MessagePipeEndpoint { | 33 class MOJO_SYSTEM_EXPORT MessagePipeEndpoint { |
| 34 public: | 34 public: |
| 35 virtual ~MessagePipeEndpoint() {} | 35 virtual ~MessagePipeEndpoint() {} |
| 36 | 36 |
| 37 // All implementations must implement these. | 37 // All implementations must implement these. |
| 38 virtual void Close() = 0; | 38 virtual void Close() = 0; |
| 39 // Returns false if the endpoint should be closed and destroyed, else true. | 39 // Returns false if the endpoint should be closed and destroyed, else true. |
| 40 virtual bool OnPeerClose() = 0; | 40 virtual bool OnPeerClose() = 0; |
| 41 // Takes ownership of |message|. | 41 // Checks if |EnqueueMessage()| will be able to enqueue the given message |
| 42 virtual MojoResult EnqueueMessage( | 42 // (with the given set of dispatchers). |dispatchers| should be non-null only |
| 43 // if it's nonempty. Returns |MOJO_RESULT_OK| if it will and an appropriate |
| 44 // error code if it won't. |
| 45 virtual MojoResult CanEnqueueMessage( |
| 46 const MessageInTransit* message, |
| 47 const std::vector<Dispatcher*>* dispatchers) = 0; |
| 48 // Takes ownership of |message| and the contents of |dispatchers| (leaving |
| 49 // it empty). This should only be called after |CanEnqueueMessage()| has |
| 50 // indicated success. (Unlike |CanEnqueueMessage()|, |dispatchers| may be |
| 51 // non-null but empty.) |
| 52 virtual void EnqueueMessage( |
| 43 MessageInTransit* message, | 53 MessageInTransit* message, |
| 44 const std::vector<Dispatcher*>* dispatchers) = 0; | 54 std::vector<scoped_refptr<Dispatcher> >* dispatchers) = 0; |
| 45 | 55 |
| 46 // Implementations must override these if they represent a local endpoint, | 56 // Implementations must override these if they represent a local endpoint, |
| 47 // i.e., one for which there's a |MessagePipeDispatcher| (and thus a handle). | 57 // i.e., one for which there's a |MessagePipeDispatcher| (and thus a handle). |
| 48 // An implementation for a proxy endpoint (for which there's no dispatcher) | 58 // An implementation for a proxy endpoint (for which there's no dispatcher) |
| 49 // needs not override these methods, since they should never be called. | 59 // needs not override these methods, since they should never be called. |
| 50 // | 60 // |
| 51 // These methods implement the methods of the same name in |MessagePipe|, | 61 // These methods implement the methods of the same name in |MessagePipe|, |
| 52 // though |MessagePipe|'s implementation may have to do a little more if the | 62 // though |MessagePipe|'s implementation may have to do a little more if the |
| 53 // operation involves both endpoints. | 63 // operation involves both endpoints. |
| 54 virtual void CancelAllWaiters(); | 64 virtual void CancelAllWaiters(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 74 MessagePipeEndpoint() {} | 84 MessagePipeEndpoint() {} |
| 75 | 85 |
| 76 private: | 86 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); | 87 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); |
| 78 }; | 88 }; |
| 79 | 89 |
| 80 } // namespace system | 90 } // namespace system |
| 81 } // namespace mojo | 91 } // namespace mojo |
| 82 | 92 |
| 83 #endif // MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 93 #endif // MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
| OLD | NEW |