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

Side by Side Diff: remoting/protocol/fake_stream_socket.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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 | « remoting/protocol/fake_stream_socket.h ('k') | remoting/protocol/fake_video_renderer.h » ('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 #include "remoting/protocol/fake_stream_socket.h" 5 #include "remoting/protocol/fake_stream_socket.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 void FakeStreamChannelFactory::PairWith( 163 void FakeStreamChannelFactory::PairWith(
164 FakeStreamChannelFactory* peer_factory) { 164 FakeStreamChannelFactory* peer_factory) {
165 peer_factory_ = peer_factory->weak_factory_.GetWeakPtr(); 165 peer_factory_ = peer_factory->weak_factory_.GetWeakPtr();
166 peer_factory->peer_factory_ = weak_factory_.GetWeakPtr(); 166 peer_factory->peer_factory_ = weak_factory_.GetWeakPtr();
167 } 167 }
168 168
169 void FakeStreamChannelFactory::CreateChannel( 169 void FakeStreamChannelFactory::CreateChannel(
170 const std::string& name, 170 const std::string& name,
171 const ChannelCreatedCallback& callback) { 171 const ChannelCreatedCallback& callback) {
172 scoped_ptr<FakeStreamSocket> channel(new FakeStreamSocket()); 172 std::unique_ptr<FakeStreamSocket> channel(new FakeStreamSocket());
173 channels_[name] = channel->GetWeakPtr(); 173 channels_[name] = channel->GetWeakPtr();
174 channel->set_async_write(async_write_); 174 channel->set_async_write(async_write_);
175 175
176 if (peer_factory_) { 176 if (peer_factory_) {
177 FakeStreamSocket* peer_channel = peer_factory_->GetFakeChannel(name); 177 FakeStreamSocket* peer_channel = peer_factory_->GetFakeChannel(name);
178 if (peer_channel) 178 if (peer_channel)
179 channel->PairWith(peer_channel); 179 channel->PairWith(peer_channel);
180 } 180 }
181 181
182 if (fail_create_) 182 if (fail_create_)
183 channel.reset(); 183 channel.reset();
184 184
185 if (asynchronous_create_) { 185 if (asynchronous_create_) {
186 task_runner_->PostTask(FROM_HERE, base::Bind( 186 task_runner_->PostTask(FROM_HERE, base::Bind(
187 &FakeStreamChannelFactory::NotifyChannelCreated, 187 &FakeStreamChannelFactory::NotifyChannelCreated,
188 weak_factory_.GetWeakPtr(), base::Passed(&channel), name, callback)); 188 weak_factory_.GetWeakPtr(), base::Passed(&channel), name, callback));
189 } else { 189 } else {
190 NotifyChannelCreated(std::move(channel), name, callback); 190 NotifyChannelCreated(std::move(channel), name, callback);
191 } 191 }
192 } 192 }
193 193
194 void FakeStreamChannelFactory::NotifyChannelCreated( 194 void FakeStreamChannelFactory::NotifyChannelCreated(
195 scoped_ptr<FakeStreamSocket> owned_channel, 195 std::unique_ptr<FakeStreamSocket> owned_channel,
196 const std::string& name, 196 const std::string& name,
197 const ChannelCreatedCallback& callback) { 197 const ChannelCreatedCallback& callback) {
198 if (channels_.find(name) != channels_.end()) 198 if (channels_.find(name) != channels_.end())
199 callback.Run(std::move(owned_channel)); 199 callback.Run(std::move(owned_channel));
200 } 200 }
201 201
202 void FakeStreamChannelFactory::CancelChannelCreation(const std::string& name) { 202 void FakeStreamChannelFactory::CancelChannelCreation(const std::string& name) {
203 channels_.erase(name); 203 channels_.erase(name);
204 } 204 }
205 205
206 } // namespace protocol 206 } // namespace protocol
207 } // namespace remoting 207 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/fake_stream_socket.h ('k') | remoting/protocol/fake_video_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698