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

Side by Side Diff: remoting/protocol/pseudotcp_channel_factory.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
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/pseudotcp_channel_factory.h" 5 #include "remoting/protocol/pseudotcp_channel_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 datagram_channel_factory_->CancelChannelCreation(name); 54 datagram_channel_factory_->CancelChannelCreation(name);
55 } else { 55 } else {
56 delete it->second; 56 delete it->second;
57 pending_sockets_.erase(it); 57 pending_sockets_.erase(it);
58 } 58 }
59 } 59 }
60 60
61 void PseudoTcpChannelFactory::OnDatagramChannelCreated( 61 void PseudoTcpChannelFactory::OnDatagramChannelCreated(
62 const std::string& name, 62 const std::string& name,
63 const ChannelCreatedCallback& callback, 63 const ChannelCreatedCallback& callback,
64 scoped_ptr<P2PDatagramSocket> datagram_socket) { 64 std::unique_ptr<P2PDatagramSocket> datagram_socket) {
65 PseudoTcpAdapter* adapter = new PseudoTcpAdapter(std::move(datagram_socket)); 65 PseudoTcpAdapter* adapter = new PseudoTcpAdapter(std::move(datagram_socket));
66 pending_sockets_[name] = adapter; 66 pending_sockets_[name] = adapter;
67 67
68 adapter->SetSendBufferSize(kTcpSendBufferSize); 68 adapter->SetSendBufferSize(kTcpSendBufferSize);
69 adapter->SetReceiveBufferSize(kTcpReceiveBufferSize); 69 adapter->SetReceiveBufferSize(kTcpReceiveBufferSize);
70 adapter->SetNoDelay(true); 70 adapter->SetNoDelay(true);
71 adapter->SetAckDelay(kTcpAckDelayMilliseconds); 71 adapter->SetAckDelay(kTcpAckDelayMilliseconds);
72 72
73 // TODO(sergeyu): This is a hack to improve latency of the video channel. 73 // TODO(sergeyu): This is a hack to improve latency of the video channel.
74 // Consider removing it once we have better flow control implemented. 74 // Consider removing it once we have better flow control implemented.
75 if (name == kVideoChannelName) 75 if (name == kVideoChannelName)
76 adapter->SetWriteWaitsForSend(true); 76 adapter->SetWriteWaitsForSend(true);
77 77
78 int result = adapter->Connect( 78 int result = adapter->Connect(
79 base::Bind(&PseudoTcpChannelFactory::OnPseudoTcpConnected, 79 base::Bind(&PseudoTcpChannelFactory::OnPseudoTcpConnected,
80 base::Unretained(this), name, callback)); 80 base::Unretained(this), name, callback));
81 if (result != net::ERR_IO_PENDING) 81 if (result != net::ERR_IO_PENDING)
82 OnPseudoTcpConnected(name, callback, result); 82 OnPseudoTcpConnected(name, callback, result);
83 } 83 }
84 84
85 void PseudoTcpChannelFactory::OnPseudoTcpConnected( 85 void PseudoTcpChannelFactory::OnPseudoTcpConnected(
86 const std::string& name, 86 const std::string& name,
87 const ChannelCreatedCallback& callback, 87 const ChannelCreatedCallback& callback,
88 int result) { 88 int result) {
89 PendingSocketsMap::iterator it = pending_sockets_.find(name); 89 PendingSocketsMap::iterator it = pending_sockets_.find(name);
90 DCHECK(it != pending_sockets_.end()); 90 DCHECK(it != pending_sockets_.end());
91 scoped_ptr<P2PStreamSocket> socket(it->second); 91 std::unique_ptr<P2PStreamSocket> socket(it->second);
92 pending_sockets_.erase(it); 92 pending_sockets_.erase(it);
93 93
94 if (result != net::OK) 94 if (result != net::OK)
95 socket.reset(); 95 socket.reset();
96 96
97 callback.Run(std::move(socket)); 97 callback.Run(std::move(socket));
98 } 98 }
99 99
100 } // namespace protocol 100 } // namespace protocol
101 } // namespace remoting 101 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/pseudotcp_channel_factory.h ('k') | remoting/protocol/rejecting_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698