| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "jingle/glue/utils.h" | 15 #include "jingle/glue/utils.h" |
| 15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 16 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/udp/udp_server_socket.h" | 19 #include "net/udp/udp_server_socket.h" |
| 19 #include "remoting/protocol/socket_util.h" | 20 #include "remoting/protocol/socket_util.h" |
| 20 #include "third_party/webrtc/base/asyncpacketsocket.h" | 21 #include "third_party/webrtc/base/asyncpacketsocket.h" |
| 21 #include "third_party/webrtc/base/nethelpers.h" | 22 #include "third_party/webrtc/base/nethelpers.h" |
| 22 #include "third_party/webrtc/media/base/rtputils.h" | 23 #include "third_party/webrtc/media/base/rtputils.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 void OnBindCompleted(int error); | 76 void OnBindCompleted(int error); |
| 76 | 77 |
| 77 void DoSend(); | 78 void DoSend(); |
| 78 void OnSendCompleted(int result); | 79 void OnSendCompleted(int result); |
| 79 | 80 |
| 80 void DoRead(); | 81 void DoRead(); |
| 81 void OnReadCompleted(int result); | 82 void OnReadCompleted(int result); |
| 82 void HandleReadResult(int result); | 83 void HandleReadResult(int result); |
| 83 | 84 |
| 84 scoped_ptr<net::UDPServerSocket> socket_; | 85 std::unique_ptr<net::UDPServerSocket> socket_; |
| 85 | 86 |
| 86 State state_; | 87 State state_; |
| 87 int error_; | 88 int error_; |
| 88 | 89 |
| 89 rtc::SocketAddress local_address_; | 90 rtc::SocketAddress local_address_; |
| 90 | 91 |
| 91 // Receive buffer and address are populated by asynchronous reads. | 92 // Receive buffer and address are populated by asynchronous reads. |
| 92 scoped_refptr<net::IOBuffer> receive_buffer_; | 93 scoped_refptr<net::IOBuffer> receive_buffer_; |
| 93 net::IPEndPoint receive_address_; | 94 net::IPEndPoint receive_address_; |
| 94 | 95 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 ChromiumPacketSocketFactory::ChromiumPacketSocketFactory() { | 369 ChromiumPacketSocketFactory::ChromiumPacketSocketFactory() { |
| 369 } | 370 } |
| 370 | 371 |
| 371 ChromiumPacketSocketFactory::~ChromiumPacketSocketFactory() { | 372 ChromiumPacketSocketFactory::~ChromiumPacketSocketFactory() { |
| 372 } | 373 } |
| 373 | 374 |
| 374 rtc::AsyncPacketSocket* ChromiumPacketSocketFactory::CreateUdpSocket( | 375 rtc::AsyncPacketSocket* ChromiumPacketSocketFactory::CreateUdpSocket( |
| 375 const rtc::SocketAddress& local_address, | 376 const rtc::SocketAddress& local_address, |
| 376 uint16_t min_port, | 377 uint16_t min_port, |
| 377 uint16_t max_port) { | 378 uint16_t max_port) { |
| 378 scoped_ptr<UdpPacketSocket> result(new UdpPacketSocket()); | 379 std::unique_ptr<UdpPacketSocket> result(new UdpPacketSocket()); |
| 379 if (!result->Init(local_address, min_port, max_port)) | 380 if (!result->Init(local_address, min_port, max_port)) |
| 380 return nullptr; | 381 return nullptr; |
| 381 return result.release(); | 382 return result.release(); |
| 382 } | 383 } |
| 383 | 384 |
| 384 rtc::AsyncPacketSocket* ChromiumPacketSocketFactory::CreateServerTcpSocket( | 385 rtc::AsyncPacketSocket* ChromiumPacketSocketFactory::CreateServerTcpSocket( |
| 385 const rtc::SocketAddress& local_address, | 386 const rtc::SocketAddress& local_address, |
| 386 uint16_t min_port, | 387 uint16_t min_port, |
| 387 uint16_t max_port, | 388 uint16_t max_port, |
| 388 int opts) { | 389 int opts) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 405 return nullptr; | 406 return nullptr; |
| 406 } | 407 } |
| 407 | 408 |
| 408 rtc::AsyncResolverInterface* | 409 rtc::AsyncResolverInterface* |
| 409 ChromiumPacketSocketFactory::CreateAsyncResolver() { | 410 ChromiumPacketSocketFactory::CreateAsyncResolver() { |
| 410 return new rtc::AsyncResolver(); | 411 return new rtc::AsyncResolver(); |
| 411 } | 412 } |
| 412 | 413 |
| 413 } // namespace protocol | 414 } // namespace protocol |
| 414 } // namespace remoting | 415 } // namespace remoting |
| OLD | NEW |