Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: mojo/system/proxy_message_pipe_endpoint.h

Issue 577313002: Mojo: Give ChannelEndpoint the remote ID and ProxyMessagePipeEndpoint the ChannelEndpoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/system/message_pipe_endpoint.cc ('k') | mojo/system/proxy_message_pipe_endpoint.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "mojo/system/message_in_transit.h" 13 #include "mojo/system/message_in_transit.h"
14 #include "mojo/system/message_in_transit_queue.h" 14 #include "mojo/system/message_in_transit_queue.h"
15 #include "mojo/system/message_pipe_endpoint.h" 15 #include "mojo/system/message_pipe_endpoint.h"
16 #include "mojo/system/system_impl_export.h" 16 #include "mojo/system/system_impl_export.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace system { 19 namespace system {
20 20
21 class Channel; 21 class Channel;
22 class ChannelEndpoint;
22 class LocalMessagePipeEndpoint; 23 class LocalMessagePipeEndpoint;
23 class MessagePipe; 24 class MessagePipe;
24 25
25 // A |ProxyMessagePipeEndpoint| connects an end of a |MessagePipe| to a 26 // A |ProxyMessagePipeEndpoint| connects an end of a |MessagePipe| to a
26 // |Channel|, over which it transmits and receives data (to/from another 27 // |Channel|, over which it transmits and receives data (to/from another
27 // |ProxyMessagePipeEndpoint|). So a |MessagePipe| with one endpoint local and 28 // |ProxyMessagePipeEndpoint|). So a |MessagePipe| with one endpoint local and
28 // the other endpoint remote consists of a |LocalMessagePipeEndpoint| and a 29 // the other endpoint remote consists of a |LocalMessagePipeEndpoint| and a
29 // |ProxyMessagePipeEndpoint|, with only the local endpoint being accessible via 30 // |ProxyMessagePipeEndpoint|, with only the local endpoint being accessible via
30 // a |MessagePipeDispatcher|. 31 // a |MessagePipeDispatcher|.
31 // 32 //
(...skipping 15 matching lines...) Expand all
47 // handle over a remote message pipe. 48 // handle over a remote message pipe.
48 ProxyMessagePipeEndpoint( 49 ProxyMessagePipeEndpoint(
49 LocalMessagePipeEndpoint* local_message_pipe_endpoint, 50 LocalMessagePipeEndpoint* local_message_pipe_endpoint,
50 bool is_peer_open); 51 bool is_peer_open);
51 virtual ~ProxyMessagePipeEndpoint(); 52 virtual ~ProxyMessagePipeEndpoint();
52 53
53 // |MessagePipeEndpoint| implementation: 54 // |MessagePipeEndpoint| implementation:
54 virtual Type GetType() const OVERRIDE; 55 virtual Type GetType() const OVERRIDE;
55 virtual bool OnPeerClose() OVERRIDE; 56 virtual bool OnPeerClose() OVERRIDE;
56 virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE; 57 virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE;
57 virtual void Attach(scoped_refptr<Channel> channel, 58 virtual void Attach(ChannelEndpoint* channel_endpoint,
59 Channel* channel,
58 MessageInTransit::EndpointId local_id) OVERRIDE; 60 MessageInTransit::EndpointId local_id) OVERRIDE;
59 virtual bool Run(MessageInTransit::EndpointId remote_id) OVERRIDE; 61 virtual bool Run(MessageInTransit::EndpointId remote_id) OVERRIDE;
60 virtual void OnRemove() OVERRIDE; 62 virtual void OnRemove() OVERRIDE;
61 63
62 private: 64 private:
63 void Detach(); 65 void Detach();
64 66
65 #ifdef NDEBUG 67 #ifdef NDEBUG
66 void AssertConsistentState() const {} 68 void AssertConsistentState() const {}
67 #else 69 #else
68 void AssertConsistentState() const; 70 void AssertConsistentState() const;
69 #endif 71 #endif
70 72
71 bool is_attached() const { return !!channel_.get(); } 73 bool is_attached() const { return !!channel_.get(); }
72 74
73 bool is_running() const { 75 bool is_running() const {
74 return remote_id_ != MessageInTransit::kInvalidEndpointId; 76 return remote_id_ != MessageInTransit::kInvalidEndpointId;
75 } 77 }
76 78
77 // This should only be set if we're attached. 79 // This should only be set if we're attached.
80 scoped_refptr<ChannelEndpoint> channel_endpoint_;
81
82 // TODO(vtl): Remove this, local_id_, and remote_id_.
83 // This should only be set if we're attached.
78 scoped_refptr<Channel> channel_; 84 scoped_refptr<Channel> channel_;
79 85
80 // |local_id_| should be set to something other than 86 // |local_id_| should be set to something other than
81 // |MessageInTransit::kInvalidEndpointId| when we're attached. 87 // |MessageInTransit::kInvalidEndpointId| when we're attached.
82 MessageInTransit::EndpointId local_id_; 88 MessageInTransit::EndpointId local_id_;
83 89
84 // |remote_id_| being set to anything other than 90 // |remote_id_| being set to anything other than
85 // |MessageInTransit::kInvalidEndpointId| indicates that we're "running", 91 // |MessageInTransit::kInvalidEndpointId| indicates that we're "running",
86 // i.e., actively able to send messages. We should only ever be running if 92 // i.e., actively able to send messages. We should only ever be running if
87 // we're attached. 93 // we're attached.
88 MessageInTransit::EndpointId remote_id_; 94 MessageInTransit::EndpointId remote_id_;
89 95
90 bool is_peer_open_; 96 bool is_peer_open_;
91 97
92 // This queue is only used while we're detached, to store messages while we're 98 // This queue is only used while we're detached, to store messages while we're
93 // not ready to send them yet. 99 // not ready to send them yet.
94 MessageInTransitQueue paused_message_queue_; 100 MessageInTransitQueue paused_message_queue_;
95 101
96 DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); 102 DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint);
97 }; 103 };
98 104
99 } // namespace system 105 } // namespace system
100 } // namespace mojo 106 } // namespace mojo
101 107
102 #endif // MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ 108 #endif // MOJO_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_
OLDNEW
« no previous file with comments | « mojo/system/message_pipe_endpoint.cc ('k') | mojo/system/proxy_message_pipe_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698