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

Side by Side Diff: mojo/edk/system/channel_endpoint.h

Issue 694923002: Update mojo sdk to rev 91d94d6993c9b0c4135a95687a7d541ce90629b (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/application_manager/application_manager.cc ('k') | mojo/edk/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_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_
6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ 6 #define MOJO_EDK_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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // running since under the current scheme it wouldn't have a remote ID 105 // running since under the current scheme it wouldn't have a remote ID
106 // yet.] 106 // yet.]
107 // - Note that even if the local side is closed, it may still receive a 107 // - Note that even if the local side is closed, it may still receive a
108 // "remove" message from the other side (if the other side is closed 108 // "remove" message from the other side (if the other side is closed
109 // simultaneously, and both sides send "remove" messages). In that 109 // simultaneously, and both sides send "remove" messages). In that
110 // case, it must still remain alive until it receives the "remove 110 // case, it must still remain alive until it receives the "remove
111 // ack" (and it must ack the "remove" message that it received). 111 // ack" (and it must ack the "remove" message that it received).
112 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpoint 112 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpoint
113 : public base::RefCountedThreadSafe<ChannelEndpoint> { 113 : public base::RefCountedThreadSafe<ChannelEndpoint> {
114 public: 114 public:
115 // TODO(vtl): More comments.... 115 // Constructor for a |ChannelEndpoint| attached to the given message pipe
116 ChannelEndpoint(MessagePipe* message_pipe, unsigned port); 116 // endpoint (specified by |message_pipe| and |port|). Optionally takes
117 117 // messages from |*message_queue| if |message_queue| is non-null.
118 // Takes messages from the given |MessageInTransitQueue|. This must be called 118 //
119 // before this object is attached to a channel, and before anyone has a chance 119 // |message_pipe| may be null if this endpoint will never need to receive
120 // to enqueue any messages. 120 // messages, in which case |message_queue| should not be null. In that case,
121 void TakeMessages(MessageInTransitQueue* message_queue); 121 // this endpoint will simply send queued messages upon being attached to a
122 // |Channel| and immediately detach itself.
123 ChannelEndpoint(MessagePipe* message_pipe,
124 unsigned port,
125 MessageInTransitQueue* message_queue = nullptr);
122 126
123 // Methods called by |MessagePipe| (via |ProxyMessagePipeEndpoint|): 127 // Methods called by |MessagePipe| (via |ProxyMessagePipeEndpoint|):
124 128
125 // TODO(vtl): This currently only works if we're "running". We'll move the 129 // TODO(vtl): This currently only works if we're "running". We'll move the
126 // "paused message queue" here (will this be needed when we have 130 // "paused message queue" here (will this be needed when we have
127 // locally-allocated remote IDs?). 131 // locally-allocated remote IDs?).
128 bool EnqueueMessage(scoped_ptr<MessageInTransit> message); 132 bool EnqueueMessage(scoped_ptr<MessageInTransit> message);
129 133
130 void DetachFromMessagePipe(); 134 void DetachFromMessagePipe();
131 135
(...skipping 19 matching lines...) Expand all
151 // Called by |Channel| before it gives up its reference to this object. 155 // Called by |Channel| before it gives up its reference to this object.
152 void DetachFromChannel(); 156 void DetachFromChannel();
153 157
154 private: 158 private:
155 friend class base::RefCountedThreadSafe<ChannelEndpoint>; 159 friend class base::RefCountedThreadSafe<ChannelEndpoint>;
156 ~ChannelEndpoint(); 160 ~ChannelEndpoint();
157 161
158 // Must be called with |lock_| held. 162 // Must be called with |lock_| held.
159 bool WriteMessageNoLock(scoped_ptr<MessageInTransit> message); 163 bool WriteMessageNoLock(scoped_ptr<MessageInTransit> message);
160 164
161 // TODO(vtl): Move the things above under lock.
162 // Protects the members below. 165 // Protects the members below.
163 base::Lock lock_; 166 base::Lock lock_;
164 167
165 // |message_pipe_| must be valid whenever it is non-null. Before 168 // |message_pipe_| must be valid whenever it is non-null. Before
166 // |*message_pipe_| gives up its reference to this object, it must call 169 // |*message_pipe_| gives up its reference to this object, it must call
167 // |DetachFromMessagePipe()|. 170 // |DetachFromMessagePipe()|.
168 // NOTE: This is a |scoped_refptr<>|, rather than a raw pointer, since the 171 // NOTE: This is a |scoped_refptr<>|, rather than a raw pointer, since the
169 // |Channel| needs to keep the |MessagePipe| alive for the "proxy-proxy" case. 172 // |Channel| needs to keep the |MessagePipe| alive for the "proxy-proxy" case.
170 // Possibly we'll be able to eliminate that case when we have full 173 // Possibly we'll be able to eliminate that case when we have full
171 // multiprocess support. 174 // multiprocess support.
(...skipping 13 matching lines...) Expand all
185 // messages. 188 // messages.
186 MessageInTransitQueue paused_message_queue_; 189 MessageInTransitQueue paused_message_queue_;
187 190
188 DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); 191 DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint);
189 }; 192 };
190 193
191 } // namespace system 194 } // namespace system
192 } // namespace mojo 195 } // namespace mojo
193 196
194 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ 197 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_
OLDNEW
« no previous file with comments | « mojo/application_manager/application_manager.cc ('k') | mojo/edk/system/channel_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698