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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "mojo/system/message_in_transit.h" | 10 #include "mojo/system/message_in_transit.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // |MessagePipe|. | 30 // |MessagePipe|. |
31 // - A |ProxyMessagePipeEndpoint| starts out *detached*, i.e., not associated | 31 // - A |ProxyMessagePipeEndpoint| starts out *detached*, i.e., not associated |
32 // to any |Channel|. When *attached*, it gets a reference to a |Channel| and | 32 // to any |Channel|. When *attached*, it gets a reference to a |Channel| and |
33 // is assigned a local ID. A |ProxyMessagePipeEndpoint| must be detached | 33 // is assigned a local ID. A |ProxyMessagePipeEndpoint| must be detached |
34 // before destruction; this is done inside |Close()|. | 34 // before destruction; this is done inside |Close()|. |
35 // - When attached, a |ProxyMessagePipeEndpoint| starts out not running. When | 35 // - When attached, a |ProxyMessagePipeEndpoint| starts out not running. When |
36 // run, it gets a remote ID. | 36 // run, it gets a remote ID. |
37 class MOJO_SYSTEM_IMPL_EXPORT ProxyMessagePipeEndpoint | 37 class MOJO_SYSTEM_IMPL_EXPORT ProxyMessagePipeEndpoint |
38 : public MessagePipeEndpoint { | 38 : public MessagePipeEndpoint { |
39 public: | 39 public: |
40 ProxyMessagePipeEndpoint(); | 40 explicit ProxyMessagePipeEndpoint(ChannelEndpoint* channel_endpoint); |
41 // Constructs a |ProxyMessagePipeEndpoint| that replaces the given | 41 // Constructs a |ProxyMessagePipeEndpoint| that replaces the given |
42 // |LocalMessagePipeEndpoint| (which this constructor will close), taking its | 42 // |LocalMessagePipeEndpoint| (which this constructor will close), taking its |
43 // message queue's contents. This is done when transferring a message pipe | 43 // message queue's contents. This is done when transferring a message pipe |
44 // handle over a remote message pipe. | 44 // handle over a remote message pipe. |
45 ProxyMessagePipeEndpoint( | 45 ProxyMessagePipeEndpoint( |
| 46 ChannelEndpoint* channel_endpoint, |
46 LocalMessagePipeEndpoint* local_message_pipe_endpoint, | 47 LocalMessagePipeEndpoint* local_message_pipe_endpoint, |
47 bool is_peer_open); | 48 bool is_peer_open); |
48 virtual ~ProxyMessagePipeEndpoint(); | 49 virtual ~ProxyMessagePipeEndpoint(); |
49 | 50 |
50 // |MessagePipeEndpoint| implementation: | 51 // |MessagePipeEndpoint| implementation: |
51 virtual Type GetType() const OVERRIDE; | 52 virtual Type GetType() const OVERRIDE; |
52 virtual bool OnPeerClose() OVERRIDE; | 53 virtual bool OnPeerClose() OVERRIDE; |
53 virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE; | 54 virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE; |
54 virtual void Attach(ChannelEndpoint* channel_endpoint) OVERRIDE; | |
55 virtual bool Run() OVERRIDE; | 55 virtual bool Run() OVERRIDE; |
56 virtual void OnRemove() OVERRIDE; | 56 virtual void OnRemove() OVERRIDE; |
57 | 57 |
58 private: | 58 private: |
59 void Detach(); | 59 void Detach(); |
60 | 60 |
61 // TODO(vtl): Get rid of these. | 61 // TODO(vtl): Get rid of these. |
62 bool is_attached() const { return !!channel_endpoint_.get(); } | 62 bool is_attached() const { return !!channel_endpoint_.get(); } |
63 bool is_running() const { return is_running_; } | 63 bool is_running() const { return is_running_; } |
64 | 64 |
65 // This should only be set if we're attached. | 65 // This should only be set if we're attached. |
66 scoped_refptr<ChannelEndpoint> channel_endpoint_; | 66 scoped_refptr<ChannelEndpoint> channel_endpoint_; |
67 | 67 |
68 // TODO(vtl): Get rid of this. | 68 // TODO(vtl): Get rid of this. |
69 bool is_running_; | 69 bool is_running_; |
70 | 70 |
71 bool is_peer_open_; | 71 bool is_peer_open_; |
72 | 72 |
73 // This queue is only used while we're detached, to store messages while we're | 73 // This queue is only used while we're detached, to store messages while we're |
74 // not ready to send them yet. | 74 // not ready to send them yet. |
75 MessageInTransitQueue paused_message_queue_; | 75 MessageInTransitQueue paused_message_queue_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); | 77 DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace system | 80 } // namespace system |
81 } // namespace mojo | 81 } // namespace mojo |
82 | 82 |
83 #endif // MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 83 #endif // MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
OLD | NEW |