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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_tcp.cc

Issue 2249473002: Remove use of stl_util's STLDeleteContainerPairSecondPointers from content/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/p2p/socket_host_tcp.h" 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 url_context_(url_context) { 60 url_context_(url_context) {
61 } 61 }
62 62
63 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { 63 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() {
64 if (state_ == STATE_OPEN) { 64 if (state_ == STATE_OPEN) {
65 DCHECK(socket_.get()); 65 DCHECK(socket_.get());
66 socket_.reset(); 66 socket_.reset();
67 } 67 }
68 } 68 }
69 69
70 bool P2PSocketHostTcpBase::InitAccepted(const net::IPEndPoint& remote_address, 70 bool P2PSocketHostTcpBase::InitAccepted(
71 net::StreamSocket* socket) { 71 const net::IPEndPoint& remote_address,
72 std::unique_ptr<net::StreamSocket> socket) {
72 DCHECK(socket); 73 DCHECK(socket);
73 DCHECK_EQ(state_, STATE_UNINITIALIZED); 74 DCHECK_EQ(state_, STATE_UNINITIALIZED);
74 75
75 remote_address_.ip_address = remote_address; 76 remote_address_.ip_address = remote_address;
76 // TODO(ronghuawu): Add FakeSSLServerSocket. 77 // TODO(ronghuawu): Add FakeSSLServerSocket.
77 socket_.reset(socket); 78 socket_ = std::move(socket);
78 state_ = STATE_OPEN; 79 state_ = STATE_OPEN;
79 DoRead(); 80 DoRead();
80 return state_ != STATE_ERROR; 81 return state_ != STATE_ERROR;
81 } 82 }
82 83
83 bool P2PSocketHostTcpBase::Init(const net::IPEndPoint& local_address, 84 bool P2PSocketHostTcpBase::Init(const net::IPEndPoint& local_address,
84 uint16_t min_port, 85 uint16_t min_port,
85 uint16_t max_port, 86 uint16_t max_port,
86 const P2PHostAndIPEndPoint& remote_address) { 87 const P2PHostAndIPEndPoint& remote_address) {
87 DCHECK_EQ(state_, STATE_UNINITIALIZED); 88 DCHECK_EQ(state_, STATE_UNINITIALIZED);
(...skipping 15 matching lines...) Expand all
103 remote_address.ip_address); 104 remote_address.ip_address);
104 } 105 }
105 106
106 // TODO(mallinath) - We are ignoring local_address altogether. We should 107 // TODO(mallinath) - We are ignoring local_address altogether. We should
107 // find a way to inject this into ProxyResolvingClientSocket. This could be 108 // find a way to inject this into ProxyResolvingClientSocket. This could be
108 // a problem on multi-homed host. 109 // a problem on multi-homed host.
109 110
110 // The default SSLConfig is good enough for us for now. 111 // The default SSLConfig is good enough for us for now.
111 const net::SSLConfig ssl_config; 112 const net::SSLConfig ssl_config;
112 socket_.reset(new jingle_glue::ProxyResolvingClientSocket( 113 socket_.reset(new jingle_glue::ProxyResolvingClientSocket(
113 NULL, // Default socket pool provided by the net::Proxy. 114 nullptr, // Default socket pool provided by the net::Proxy.
114 url_context_, 115 url_context_, ssl_config, dest_host_port_pair));
115 ssl_config,
116 dest_host_port_pair));
117 116
118 int status = socket_->Connect( 117 int status = socket_->Connect(
119 base::Bind(&P2PSocketHostTcpBase::OnConnected, 118 base::Bind(&P2PSocketHostTcpBase::OnConnected,
120 base::Unretained(this))); 119 base::Unretained(this)));
121 if (status != net::ERR_IO_PENDING) { 120 if (status != net::ERR_IO_PENDING) {
122 // We defer execution of ProcessConnectDone instead of calling it 121 // We defer execution of ProcessConnectDone instead of calling it
123 // directly here as the caller may not expect an error/close to 122 // directly here as the caller may not expect an error/close to
124 // happen here. This is okay, as from the caller's point of view, 123 // happen here. This is okay, as from the caller's point of view,
125 // the connect always happens asynchronously. 124 // the connect always happens asynchronously.
126 base::MessageLoop* message_loop = base::MessageLoop::current(); 125 base::MessageLoop* message_loop = base::MessageLoop::current();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 418 }
420 419
421 void P2PSocketHostTcpBase::HandleWriteResult(int result) { 420 void P2PSocketHostTcpBase::HandleWriteResult(int result) {
422 DCHECK(write_buffer_.get()); 421 DCHECK(write_buffer_.get());
423 if (result >= 0) { 422 if (result >= 0) {
424 write_buffer_->DidConsume(result); 423 write_buffer_->DidConsume(result);
425 if (write_buffer_->BytesRemaining() == 0) { 424 if (write_buffer_->BytesRemaining() == 0) {
426 message_sender_->Send( 425 message_sender_->Send(
427 new P2PMsg_OnSendComplete(id_, P2PSendPacketMetrics())); 426 new P2PMsg_OnSendComplete(id_, P2PSendPacketMetrics()));
428 if (write_queue_.empty()) { 427 if (write_queue_.empty()) {
429 write_buffer_ = NULL; 428 write_buffer_ = nullptr;
430 } else { 429 } else {
431 write_buffer_ = write_queue_.front(); 430 write_buffer_ = write_queue_.front();
432 write_queue_.pop(); 431 write_queue_.pop();
433 // Update how many bytes are still waiting to be sent. 432 // Update how many bytes are still waiting to be sent.
434 DecrementDelayedBytes(write_buffer_->size()); 433 DecrementDelayedBytes(write_buffer_->size());
435 } 434 }
436 } 435 }
437 } else if (result == net::ERR_IO_PENDING) { 436 } else if (result == net::ERR_IO_PENDING) {
438 write_pending_ = true; 437 write_pending_ = true;
439 } else { 438 } else {
440 ReportSocketError(result, "WebRTC.ICE.TcpSocketWriteErrorCode"); 439 ReportSocketError(result, "WebRTC.ICE.TcpSocketWriteErrorCode");
441 440
442 LOG(ERROR) << "Error when sending data in TCP socket: " << result; 441 LOG(ERROR) << "Error when sending data in TCP socket: " << result;
443 OnError(); 442 OnError();
444 } 443 }
445 } 444 }
446 445
447 P2PSocketHost* P2PSocketHostTcpBase::AcceptIncomingTcpConnection( 446 std::unique_ptr<P2PSocketHost>
448 const net::IPEndPoint& remote_address, int id) { 447 P2PSocketHostTcpBase::AcceptIncomingTcpConnection(
448 const net::IPEndPoint& remote_address,
449 int id) {
449 NOTREACHED(); 450 NOTREACHED();
450 OnError(); 451 OnError();
451 return NULL; 452 return nullptr;
452 } 453 }
453 454
454 void P2PSocketHostTcpBase::DidCompleteRead(int result) { 455 void P2PSocketHostTcpBase::DidCompleteRead(int result) {
455 DCHECK_EQ(state_, STATE_OPEN); 456 DCHECK_EQ(state_, STATE_OPEN);
456 457
457 if (result == net::ERR_IO_PENDING) { 458 if (result == net::ERR_IO_PENDING) {
458 return; 459 return;
459 } else if (result < 0) { 460 } else if (result < 0) {
460 LOG(ERROR) << "Error when reading from TCP socket: " << result; 461 LOG(ERROR) << "Error when reading from TCP socket: " << result;
461 OnError(); 462 OnError();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } else { 643 } else {
643 packet_size += kTurnChannelDataHeaderSize; 644 packet_size += kTurnChannelDataHeaderSize;
644 // Calculate any padding if present. 645 // Calculate any padding if present.
645 if (packet_size % 4) 646 if (packet_size % 4)
646 *pad_bytes = 4 - packet_size % 4; 647 *pad_bytes = 4 - packet_size % 4;
647 } 648 }
648 return packet_size; 649 return packet_size;
649 } 650 }
650 651
651 } // namespace content 652 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_tcp.h ('k') | content/browser/renderer_host/p2p/socket_host_tcp_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698