OLD | NEW |
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/chromium_socket_factory.h" | 5 #include "remoting/protocol/chromium_socket_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "jingle/glue/utils.h" | 10 #include "jingle/glue/utils.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 bool UdpPacketSocket::Init(const rtc::SocketAddress& local_address, | 117 bool UdpPacketSocket::Init(const rtc::SocketAddress& local_address, |
118 uint16 min_port, uint16 max_port) { | 118 uint16 min_port, uint16 max_port) { |
119 net::IPEndPoint local_endpoint; | 119 net::IPEndPoint local_endpoint; |
120 if (!jingle_glue::SocketAddressToIPEndPoint( | 120 if (!jingle_glue::SocketAddressToIPEndPoint( |
121 local_address, &local_endpoint)) { | 121 local_address, &local_endpoint)) { |
122 return false; | 122 return false; |
123 } | 123 } |
124 | 124 |
125 for (uint32 port = min_port; port <= max_port; ++port) { | 125 for (uint32 port = min_port; port <= max_port; ++port) { |
126 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source())); | 126 socket_.reset(new net::UDPServerSocket(nullptr, net::NetLog::Source())); |
127 int result = socket_->Listen( | 127 int result = socket_->Listen( |
128 net::IPEndPoint(local_endpoint.address(), static_cast<uint16>(port))); | 128 net::IPEndPoint(local_endpoint.address(), static_cast<uint16>(port))); |
129 if (result == net::OK) { | 129 if (result == net::OK) { |
130 break; | 130 break; |
131 } else { | 131 } else { |
132 socket_.reset(); | 132 socket_.reset(); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 if (!socket_.get()) { | 136 if (!socket_.get()) { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 357 } |
358 | 358 |
359 ChromiumPacketSocketFactory::~ChromiumPacketSocketFactory() { | 359 ChromiumPacketSocketFactory::~ChromiumPacketSocketFactory() { |
360 } | 360 } |
361 | 361 |
362 rtc::AsyncPacketSocket* ChromiumPacketSocketFactory::CreateUdpSocket( | 362 rtc::AsyncPacketSocket* ChromiumPacketSocketFactory::CreateUdpSocket( |
363 const rtc::SocketAddress& local_address, | 363 const rtc::SocketAddress& local_address, |
364 uint16 min_port, uint16 max_port) { | 364 uint16 min_port, uint16 max_port) { |
365 scoped_ptr<UdpPacketSocket> result(new UdpPacketSocket()); | 365 scoped_ptr<UdpPacketSocket> result(new UdpPacketSocket()); |
366 if (!result->Init(local_address, min_port, max_port)) | 366 if (!result->Init(local_address, min_port, max_port)) |
367 return NULL; | 367 return nullptr; |
368 return result.release(); | 368 return result.release(); |
369 } | 369 } |
370 | 370 |
371 rtc::AsyncPacketSocket* | 371 rtc::AsyncPacketSocket* |
372 ChromiumPacketSocketFactory::CreateServerTcpSocket( | 372 ChromiumPacketSocketFactory::CreateServerTcpSocket( |
373 const rtc::SocketAddress& local_address, | 373 const rtc::SocketAddress& local_address, |
374 uint16 min_port, uint16 max_port, | 374 uint16 min_port, uint16 max_port, |
375 int opts) { | 375 int opts) { |
376 // We don't use TCP sockets for remoting connections. | 376 // We don't use TCP sockets for remoting connections. |
377 NOTIMPLEMENTED(); | 377 NOTIMPLEMENTED(); |
378 return NULL; | 378 return nullptr; |
379 } | 379 } |
380 | 380 |
381 rtc::AsyncPacketSocket* | 381 rtc::AsyncPacketSocket* |
382 ChromiumPacketSocketFactory::CreateClientTcpSocket( | 382 ChromiumPacketSocketFactory::CreateClientTcpSocket( |
383 const rtc::SocketAddress& local_address, | 383 const rtc::SocketAddress& local_address, |
384 const rtc::SocketAddress& remote_address, | 384 const rtc::SocketAddress& remote_address, |
385 const rtc::ProxyInfo& proxy_info, | 385 const rtc::ProxyInfo& proxy_info, |
386 const std::string& user_agent, | 386 const std::string& user_agent, |
387 int opts) { | 387 int opts) { |
388 // We don't use TCP sockets for remoting connections. | 388 // We don't use TCP sockets for remoting connections. |
389 NOTREACHED(); | 389 NOTREACHED(); |
390 return NULL; | 390 return nullptr; |
391 } | 391 } |
392 | 392 |
393 rtc::AsyncResolverInterface* | 393 rtc::AsyncResolverInterface* |
394 ChromiumPacketSocketFactory::CreateAsyncResolver() { | 394 ChromiumPacketSocketFactory::CreateAsyncResolver() { |
395 return new rtc::AsyncResolver(); | 395 return new rtc::AsyncResolver(); |
396 } | 396 } |
397 | 397 |
398 } // namespace protocol | 398 } // namespace protocol |
399 } // namespace remoting | 399 } // namespace remoting |
OLD | NEW |