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

Side by Side Diff: mojo/system/channel_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/channel.cc ('k') | mojo/system/channel_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 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_SYSTEM_CHANNEL_ENDPOINT_H_ 5 #ifndef MOJO_SYSTEM_CHANNEL_ENDPOINT_H_
6 #define MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ 6 #define MOJO_SYSTEM_CHANNEL_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 "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // ack" (and it must ack the "remove" message that it received). 107 // ack" (and it must ack the "remove" message that it received).
108 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpoint 108 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpoint
109 : public base::RefCountedThreadSafe<ChannelEndpoint> { 109 : public base::RefCountedThreadSafe<ChannelEndpoint> {
110 public: 110 public:
111 // TODO(vtl): More comments.... 111 // TODO(vtl): More comments....
112 // The caller must keep |channel| alive until the |Channel| has taken 112 // The caller must keep |channel| alive until the |Channel| has taken
113 // ownership of a reference to the created object. (TODO(vtl): Convert 113 // ownership of a reference to the created object. (TODO(vtl): Convert
114 // |Channel::AttachMessagePipeEndpoint()| to a |Channel::AttachEndpoint()| 114 // |Channel::AttachMessagePipeEndpoint()| to a |Channel::AttachEndpoint()|
115 // that takes a |ChannelEndpoint|, and move |ChannelEndpoint| creation out of 115 // that takes a |ChannelEndpoint|, and move |ChannelEndpoint| creation out of
116 // |Channel|.) 116 // |Channel|.)
117 ChannelEndpoint(MessagePipe* message_pipe, 117 ChannelEndpoint(MessagePipe* message_pipe, unsigned port);
118 unsigned port, 118
119 Channel* channel, 119 void AttachToChannel(Channel* channel, MessageInTransit::EndpointId local_id);
120 MessageInTransit::EndpointId local_id); 120 void Run(MessageInTransit::EndpointId remote_id);
121 121
122 // Called by |Channel| before it gives up its reference to this object. 122 // Called by |Channel| before it gives up its reference to this object.
123 void DetachFromChannel(); 123 void DetachFromChannel();
124 124
125 private: 125 private:
126 enum State { 126 enum State {
127 // Attached, possibly running or not. 127 // Attached, possibly running or not.
128 STATE_NORMAL, 128 STATE_NORMAL,
129 // "Zombie" states: 129 // "Zombie" states:
130 // Waiting for |DetachMessagePipeEndpoint()| before removing. 130 // Waiting for |DetachMessagePipeEndpoint()| before removing.
131 STATE_WAIT_LOCAL_DETACH, 131 STATE_WAIT_LOCAL_DETACH,
132 // Waiting for a |kSubtypeChannelRemoveMessagePipeEndpointAck| before 132 // Waiting for a |kSubtypeChannelRemoveMessagePipeEndpointAck| before
133 // removing. 133 // removing.
134 STATE_WAIT_REMOTE_REMOVE_ACK, 134 STATE_WAIT_REMOTE_REMOVE_ACK,
135 }; 135 };
136 136
137 // TODO(vtl): This is totally temporary, until this becomes a proper 137 // TODO(vtl): This is totally temporary, until this becomes a proper
138 // self-contained class. See the plan above. 138 // self-contained class. See the plan above.
139 friend class Channel; 139 friend class Channel;
140 140
141 friend class base::RefCountedThreadSafe<ChannelEndpoint>; 141 friend class base::RefCountedThreadSafe<ChannelEndpoint>;
142 ~ChannelEndpoint(); 142 ~ChannelEndpoint();
143 143
144 State state_; 144 State state_;
145 // TODO(vtl): When moved under lock, this can/should be made a raw pointer.
145 scoped_refptr<MessagePipe> message_pipe_; 146 scoped_refptr<MessagePipe> message_pipe_;
146 unsigned port_; 147 unsigned port_;
147 148
148 // TODO(vtl): Move the things above under lock. 149 // TODO(vtl): Move the things above under lock.
149 // Protects the members below. 150 // Protects the members below.
150 base::Lock lock_; 151 base::Lock lock_;
151 152
152 // |channel_| must be alive whenever this is nonnull. Before the |channel_| 153 // |channel_| must be alive whenever this is non-null. Before the |channel_|
153 // gives up its reference to this object, it will call |DetachFromChannel()|. 154 // gives up its reference to this object, it will call |DetachFromChannel()|.
154 Channel* channel_; 155 Channel* channel_;
155 MessageInTransit::EndpointId local_id_; 156 MessageInTransit::EndpointId local_id_;
156 // TODO(vtl): 157 MessageInTransit::EndpointId remote_id_;
157 // MessageInTransit::EndpointId remote_id_;
158 158
159 DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); 159 DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint);
160 }; 160 };
161 161
162 } // namespace system 162 } // namespace system
163 } // namespace mojo 163 } // namespace mojo
164 164
165 #endif // MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ 165 #endif // MOJO_SYSTEM_CHANNEL_ENDPOINT_H_
OLDNEW
« no previous file with comments | « mojo/system/channel.cc ('k') | mojo/system/channel_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698