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

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

Issue 707713006: Update Chromium for webrtc r7656. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/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 18 matching lines...) Expand all
29 // Pepper's UDP API can handle it. This maximum should never be 29 // Pepper's UDP API can handle it. This maximum should never be
30 // reached under normal conditions. 30 // reached under normal conditions.
31 const int kMaxSendBufferSize = 256 * 1024; 31 const int kMaxSendBufferSize = 256 * 1024;
32 32
33 class UdpPacketSocket : public rtc::AsyncPacketSocket { 33 class UdpPacketSocket : public rtc::AsyncPacketSocket {
34 public: 34 public:
35 UdpPacketSocket(); 35 UdpPacketSocket();
36 ~UdpPacketSocket() override; 36 ~UdpPacketSocket() override;
37 37
38 bool Init(const rtc::SocketAddress& local_address, 38 bool Init(const rtc::SocketAddress& local_address,
39 int min_port, int max_port); 39 uint16 min_port, uint16 max_port);
40 40
41 // rtc::AsyncPacketSocket interface. 41 // rtc::AsyncPacketSocket interface.
42 rtc::SocketAddress GetLocalAddress() const override; 42 rtc::SocketAddress GetLocalAddress() const override;
43 rtc::SocketAddress GetRemoteAddress() const override; 43 rtc::SocketAddress GetRemoteAddress() const override;
44 int Send(const void* data, 44 int Send(const void* data,
45 size_t data_size, 45 size_t data_size,
46 const rtc::PacketOptions& options) override; 46 const rtc::PacketOptions& options) override;
47 int SendTo(const void* data, 47 int SendTo(const void* data,
48 size_t data_size, 48 size_t data_size,
49 const rtc::SocketAddress& address, 49 const rtc::SocketAddress& address,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 error_(0), 108 error_(0),
109 send_pending_(false), 109 send_pending_(false),
110 send_queue_size_(0) { 110 send_queue_size_(0) {
111 } 111 }
112 112
113 UdpPacketSocket::~UdpPacketSocket() { 113 UdpPacketSocket::~UdpPacketSocket() {
114 Close(); 114 Close();
115 } 115 }
116 116
117 bool UdpPacketSocket::Init(const rtc::SocketAddress& local_address, 117 bool UdpPacketSocket::Init(const rtc::SocketAddress& local_address,
118 int min_port, int 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 (int port = min_port; port <= max_port; ++port) { 125 for (uint16 port = min_port; port <= max_port; ++port) {
126 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source())); 126 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source()));
127 int result = socket_->Listen( 127 int result = socket_->Listen(
128 net::IPEndPoint(local_endpoint.address(), port)); 128 net::IPEndPoint(local_endpoint.address(), 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
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } // namespace 354 } // namespace
355 355
356 ChromiumPacketSocketFactory::ChromiumPacketSocketFactory() { 356 ChromiumPacketSocketFactory::ChromiumPacketSocketFactory() {
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 int min_port, int 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 NULL;
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 int min_port, int 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 NULL;
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 NULL;
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
OLDNEW
« no previous file with comments | « remoting/protocol/chromium_socket_factory.h ('k') | remoting/protocol/chromium_socket_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698