| 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_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 5 #ifndef MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
| 6 #define MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 6 #define MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // |LocalMessagePipeEndpoint| (which this constructor will close), taking its | 46 // |LocalMessagePipeEndpoint| (which this constructor will close), taking its |
| 47 // message queue's contents. This is done when transferring a message pipe | 47 // message queue's contents. This is done when transferring a message pipe |
| 48 // handle over a remote message pipe. | 48 // handle over a remote message pipe. |
| 49 ProxyMessagePipeEndpoint( | 49 ProxyMessagePipeEndpoint( |
| 50 LocalMessagePipeEndpoint* local_message_pipe_endpoint, | 50 LocalMessagePipeEndpoint* local_message_pipe_endpoint, |
| 51 bool is_peer_open); | 51 bool is_peer_open); |
| 52 virtual ~ProxyMessagePipeEndpoint(); | 52 virtual ~ProxyMessagePipeEndpoint(); |
| 53 | 53 |
| 54 // |MessagePipeEndpoint| implementation: | 54 // |MessagePipeEndpoint| implementation: |
| 55 virtual Type GetType() const OVERRIDE; | 55 virtual Type GetType() const OVERRIDE; |
| 56 virtual void Close() OVERRIDE; | 56 virtual bool OnPeerClose() OVERRIDE; |
| 57 virtual void OnPeerClose() OVERRIDE; | |
| 58 virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE; | 57 virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE; |
| 59 virtual void Attach(scoped_refptr<Channel> channel, | 58 virtual void Attach(scoped_refptr<Channel> channel, |
| 60 MessageInTransit::EndpointId local_id) OVERRIDE; | 59 MessageInTransit::EndpointId local_id) OVERRIDE; |
| 61 virtual void Run(MessageInTransit::EndpointId remote_id) OVERRIDE; | 60 virtual bool Run(MessageInTransit::EndpointId remote_id) OVERRIDE; |
| 61 virtual void OnRemove() OVERRIDE; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 void Detach(); |
| 65 |
| 66 #ifdef NDEBUG |
| 67 void AssertConsistentState() const {} |
| 68 #else |
| 69 void AssertConsistentState() const; |
| 70 #endif |
| 71 |
| 64 bool is_attached() const { | 72 bool is_attached() const { |
| 65 return !!channel_.get(); | 73 return !!channel_.get(); |
| 66 } | 74 } |
| 67 | 75 |
| 68 bool is_running() const { | 76 bool is_running() const { |
| 69 return remote_id_ != MessageInTransit::kInvalidEndpointId; | 77 return remote_id_ != MessageInTransit::kInvalidEndpointId; |
| 70 } | 78 } |
| 71 | 79 |
| 72 #ifdef NDEBUG | |
| 73 void AssertConsistentState() const {} | |
| 74 #else | |
| 75 void AssertConsistentState() const; | |
| 76 #endif | |
| 77 | |
| 78 // This should only be set if we're attached. | 80 // This should only be set if we're attached. |
| 79 scoped_refptr<Channel> channel_; | 81 scoped_refptr<Channel> channel_; |
| 80 | 82 |
| 81 // |local_id_| should be set to something other than | 83 // |local_id_| should be set to something other than |
| 82 // |MessageInTransit::kInvalidEndpointId| when we're attached. | 84 // |MessageInTransit::kInvalidEndpointId| when we're attached. |
| 83 MessageInTransit::EndpointId local_id_; | 85 MessageInTransit::EndpointId local_id_; |
| 84 | 86 |
| 85 // |remote_id_| being set to anything other than | 87 // |remote_id_| being set to anything other than |
| 86 // |MessageInTransit::kInvalidEndpointId| indicates that we're "running", | 88 // |MessageInTransit::kInvalidEndpointId| indicates that we're "running", |
| 87 // i.e., actively able to send messages. We should only ever be running if | 89 // i.e., actively able to send messages. We should only ever be running if |
| 88 // we're attached. | 90 // we're attached. |
| 89 MessageInTransit::EndpointId remote_id_; | 91 MessageInTransit::EndpointId remote_id_; |
| 90 | 92 |
| 91 bool is_open_; | |
| 92 bool is_peer_open_; | 93 bool is_peer_open_; |
| 93 | 94 |
| 94 // This queue is only used while we're detached, to store messages while we're | 95 // This queue is only used while we're detached, to store messages while we're |
| 95 // not ready to send them yet. | 96 // not ready to send them yet. |
| 96 MessageInTransitQueue paused_message_queue_; | 97 MessageInTransitQueue paused_message_queue_; |
| 97 | 98 |
| 98 DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); | 99 DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 } // namespace system | 102 } // namespace system |
| 102 } // namespace mojo | 103 } // namespace mojo |
| 103 | 104 |
| 104 #endif // MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 105 #endif // MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
| OLD | NEW |