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 1353683005: EDK: Convert remaining scoped_ptr -> std::unique_ptr in //mojo/edk/system. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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/edk/system/channel.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 <memory>
9
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "mojo/edk/system/channel_endpoint_id.h" 11 #include "mojo/edk/system/channel_endpoint_id.h"
11 #include "mojo/edk/system/message_in_transit_queue.h" 12 #include "mojo/edk/system/message_in_transit_queue.h"
12 #include "mojo/edk/system/mutex.h" 13 #include "mojo/edk/system/mutex.h"
13 #include "mojo/edk/system/system_impl_export.h" 14 #include "mojo/edk/system/system_impl_export.h"
14 #include "mojo/public/cpp/system/macros.h" 15 #include "mojo/public/cpp/system/macros.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace system { 18 namespace system {
18 19
19 class Channel; 20 class Channel;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // |Channel| and immediately detach itself. 122 // |Channel| and immediately detach itself.
122 ChannelEndpoint(ChannelEndpointClient* client, 123 ChannelEndpoint(ChannelEndpointClient* client,
123 unsigned client_port, 124 unsigned client_port,
124 MessageInTransitQueue* message_queue = nullptr); 125 MessageInTransitQueue* message_queue = nullptr);
125 126
126 // Methods called by |ChannelEndpointClient|: 127 // Methods called by |ChannelEndpointClient|:
127 128
128 // Called to enqueue an outbound message. (If |AttachAndRun()| has not yet 129 // Called to enqueue an outbound message. (If |AttachAndRun()| has not yet
129 // been called, the message will be enqueued and sent when |AttachAndRun()| is 130 // been called, the message will be enqueued and sent when |AttachAndRun()| is
130 // called.) 131 // called.)
131 bool EnqueueMessage(scoped_ptr<MessageInTransit> message); 132 bool EnqueueMessage(std::unique_ptr<MessageInTransit> message);
132 133
133 // Called to *replace* current client with a new client (which must differ 134 // Called to *replace* current client with a new client (which must differ
134 // from the existing client). This must not be called after 135 // from the existing client). This must not be called after
135 // |DetachFromClient()| has been called. 136 // |DetachFromClient()| has been called.
136 // 137 //
137 // This returns true in the typical case, and false if this endpoint has been 138 // This returns true in the typical case, and false if this endpoint has been
138 // detached from the channel, in which case the caller should probably call 139 // detached from the channel, in which case the caller should probably call
139 // its (new) client's |OnDetachFromChannel()|. 140 // its (new) client's |OnDetachFromChannel()|.
140 bool ReplaceClient(ChannelEndpointClient* client, unsigned client_port); 141 bool ReplaceClient(ChannelEndpointClient* client, unsigned client_port);
141 142
142 // Called before the |ChannelEndpointClient| gives up its reference to this 143 // Called before the |ChannelEndpointClient| gives up its reference to this
143 // object. 144 // object.
144 void DetachFromClient(); 145 void DetachFromClient();
145 146
146 // Methods called by |Channel|: 147 // Methods called by |Channel|:
147 148
148 // Called when the |Channel| takes a reference to this object. This will send 149 // Called when the |Channel| takes a reference to this object. This will send
149 // all queue messages (in |channel_message_queue_|). 150 // all queue messages (in |channel_message_queue_|).
150 // TODO(vtl): Maybe rename this "OnAttach"? 151 // TODO(vtl): Maybe rename this "OnAttach"?
151 void AttachAndRun(Channel* channel, 152 void AttachAndRun(Channel* channel,
152 ChannelEndpointId local_id, 153 ChannelEndpointId local_id,
153 ChannelEndpointId remote_id); 154 ChannelEndpointId remote_id);
154 155
155 // Called when the |Channel| receives a message for the |ChannelEndpoint|. 156 // Called when the |Channel| receives a message for the |ChannelEndpoint|.
156 void OnReadMessage(scoped_ptr<MessageInTransit> message); 157 void OnReadMessage(std::unique_ptr<MessageInTransit> message);
157 158
158 // Called before the |Channel| gives up its reference to this object. 159 // Called before the |Channel| gives up its reference to this object.
159 void DetachFromChannel(); 160 void DetachFromChannel();
160 161
161 private: 162 private:
162 friend class base::RefCountedThreadSafe<ChannelEndpoint>; 163 friend class base::RefCountedThreadSafe<ChannelEndpoint>;
163 ~ChannelEndpoint(); 164 ~ChannelEndpoint();
164 165
165 bool WriteMessageNoLock(scoped_ptr<MessageInTransit> message) 166 bool WriteMessageNoLock(std::unique_ptr<MessageInTransit> message)
166 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 167 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
167 168
168 // Helper for |OnReadMessage()|, handling messages for the client. 169 // Helper for |OnReadMessage()|, handling messages for the client.
169 void OnReadMessageForClient(scoped_ptr<MessageInTransit> message); 170 void OnReadMessageForClient(std::unique_ptr<MessageInTransit> message);
170 171
171 // Moves |state_| from |RUNNING| to |DEAD|. |channel_| must be non-null, but 172 // Moves |state_| from |RUNNING| to |DEAD|. |channel_| must be non-null, but
172 // this does not call |channel_->DetachEndpoint()|. 173 // this does not call |channel_->DetachEndpoint()|.
173 void DieNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 174 void DieNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
174 175
175 Mutex mutex_; 176 Mutex mutex_;
176 177
177 enum class State { 178 enum class State {
178 // |AttachAndRun()| has not been called yet (|channel_| is null). 179 // |AttachAndRun()| has not been called yet (|channel_| is null).
179 PAUSED, 180 PAUSED,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // messages to the channel. 215 // messages to the channel.
215 MessageInTransitQueue channel_message_queue_ MOJO_GUARDED_BY(mutex_); 216 MessageInTransitQueue channel_message_queue_ MOJO_GUARDED_BY(mutex_);
216 217
217 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); 218 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint);
218 }; 219 };
219 220
220 } // namespace system 221 } // namespace system
221 } // namespace mojo 222 } // namespace mojo
222 223
223 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ 224 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/channel.cc ('k') | mojo/edk/system/channel_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698