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

Side by Side Diff: remoting/protocol/fake_datagram_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_datagram_socket.h ('k') | remoting/protocol/fake_desktop_capturer.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_datagram_socket.h" 5 #include "remoting/protocol/fake_datagram_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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 FakeDatagramSocket* FakeDatagramChannelFactory::GetFakeChannel( 150 FakeDatagramSocket* FakeDatagramChannelFactory::GetFakeChannel(
151 const std::string& name) { 151 const std::string& name) {
152 return channels_[name].get(); 152 return channels_[name].get();
153 } 153 }
154 154
155 void FakeDatagramChannelFactory::CreateChannel( 155 void FakeDatagramChannelFactory::CreateChannel(
156 const std::string& name, 156 const std::string& name,
157 const ChannelCreatedCallback& callback) { 157 const ChannelCreatedCallback& callback) {
158 EXPECT_TRUE(channels_[name] == nullptr); 158 EXPECT_TRUE(channels_[name] == nullptr);
159 159
160 scoped_ptr<FakeDatagramSocket> channel(new FakeDatagramSocket()); 160 std::unique_ptr<FakeDatagramSocket> channel(new FakeDatagramSocket());
161 channels_[name] = channel->GetWeakPtr(); 161 channels_[name] = channel->GetWeakPtr();
162 162
163 if (peer_factory_) { 163 if (peer_factory_) {
164 FakeDatagramSocket* peer_socket = peer_factory_->GetFakeChannel(name); 164 FakeDatagramSocket* peer_socket = peer_factory_->GetFakeChannel(name);
165 if (peer_socket) 165 if (peer_socket)
166 channel->PairWith(peer_socket); 166 channel->PairWith(peer_socket);
167 } 167 }
168 168
169 if (fail_create_) 169 if (fail_create_)
170 channel.reset(); 170 channel.reset();
171 171
172 if (asynchronous_create_) { 172 if (asynchronous_create_) {
173 task_runner_->PostTask( 173 task_runner_->PostTask(
174 FROM_HERE, 174 FROM_HERE,
175 base::Bind(&FakeDatagramChannelFactory::NotifyChannelCreated, 175 base::Bind(&FakeDatagramChannelFactory::NotifyChannelCreated,
176 weak_factory_.GetWeakPtr(), base::Passed(&channel), 176 weak_factory_.GetWeakPtr(), base::Passed(&channel),
177 name, callback)); 177 name, callback));
178 } else { 178 } else {
179 NotifyChannelCreated(std::move(channel), name, callback); 179 NotifyChannelCreated(std::move(channel), name, callback);
180 } 180 }
181 } 181 }
182 182
183 void FakeDatagramChannelFactory::NotifyChannelCreated( 183 void FakeDatagramChannelFactory::NotifyChannelCreated(
184 scoped_ptr<FakeDatagramSocket> owned_socket, 184 std::unique_ptr<FakeDatagramSocket> owned_socket,
185 const std::string& name, 185 const std::string& name,
186 const ChannelCreatedCallback& callback) { 186 const ChannelCreatedCallback& callback) {
187 if (channels_.find(name) != channels_.end()) 187 if (channels_.find(name) != channels_.end())
188 callback.Run(std::move(owned_socket)); 188 callback.Run(std::move(owned_socket));
189 } 189 }
190 190
191 void FakeDatagramChannelFactory::CancelChannelCreation( 191 void FakeDatagramChannelFactory::CancelChannelCreation(
192 const std::string& name) { 192 const std::string& name) {
193 channels_.erase(name); 193 channels_.erase(name);
194 } 194 }
195 195
196 } // namespace protocol 196 } // namespace protocol
197 } // namespace remoting 197 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/fake_datagram_socket.h ('k') | remoting/protocol/fake_desktop_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698