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

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

Issue 677473002: Implement UMA and internal data structure for tracking EWOULDBLOCK. (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 (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 "base/sys_byteorder.h" 7 #include "base/sys_byteorder.h"
8 #include "content/common/p2p_messages.h" 8 #include "content/common/p2p_messages.h"
9 #include "ipc/ipc_sender.h" 9 #include "ipc/ipc_sender.h"
10 #include "jingle/glue/fake_ssl_client_socket.h" 10 #include "jingle/glue/fake_ssl_client_socket.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 P2PSocketHostTcpBase::P2PSocketHostTcpBase( 47 P2PSocketHostTcpBase::P2PSocketHostTcpBase(
48 IPC::Sender* message_sender, 48 IPC::Sender* message_sender,
49 int socket_id, 49 int socket_id,
50 P2PSocketType type, 50 P2PSocketType type,
51 net::URLRequestContextGetter* url_context) 51 net::URLRequestContextGetter* url_context)
52 : P2PSocketHost(message_sender, socket_id), 52 : P2PSocketHost(message_sender, socket_id),
53 write_pending_(false), 53 write_pending_(false),
54 connected_(false), 54 connected_(false),
55 type_(type), 55 type_(type),
56 url_context_(url_context) { 56 url_context_(url_context) {
57 protocol_type_ = P2PSocketHost::TCP;
57 } 58 }
58 59
59 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { 60 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() {
60 if (state_ == STATE_OPEN) { 61 if (state_ == STATE_OPEN) {
61 DCHECK(socket_.get()); 62 DCHECK(socket_.get());
62 socket_.reset(); 63 socket_.reset();
63 } 64 }
64 } 65 }
65 66
66 bool P2PSocketHostTcpBase::InitAccepted(const net::IPEndPoint& remote_address, 67 bool P2PSocketHostTcpBase::InitAccepted(const net::IPEndPoint& remote_address,
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 OnError(); 355 OnError();
355 return; 356 return;
356 } 357 }
357 } 358 }
358 359
359 DoSend(to, data, options); 360 DoSend(to, data, options);
360 } 361 }
361 362
362 void P2PSocketHostTcpBase::WriteOrQueue( 363 void P2PSocketHostTcpBase::WriteOrQueue(
363 scoped_refptr<net::DrainableIOBuffer>& buffer) { 364 scoped_refptr<net::DrainableIOBuffer>& buffer) {
365 IncrementTotalSentPackets();
364 if (write_buffer_.get()) { 366 if (write_buffer_.get()) {
365 write_queue_.push(buffer); 367 write_queue_.push(buffer);
368 IncrementDelayedPackets();
369 IncrementDelayedBytes(buffer->size());
366 return; 370 return;
367 } 371 }
368 372
369 write_buffer_ = buffer; 373 write_buffer_ = buffer;
370 DoWrite(); 374 DoWrite();
371 } 375 }
372 376
373 void P2PSocketHostTcpBase::DoWrite() { 377 void P2PSocketHostTcpBase::DoWrite() {
374 while (write_buffer_.get() && state_ == STATE_OPEN && !write_pending_) { 378 while (write_buffer_.get() && state_ == STATE_OPEN && !write_pending_) {
375 int result = socket_->Write( 379 int result = socket_->Write(
(...skipping 17 matching lines...) Expand all
393 DCHECK(write_buffer_.get()); 397 DCHECK(write_buffer_.get());
394 if (result >= 0) { 398 if (result >= 0) {
395 write_buffer_->DidConsume(result); 399 write_buffer_->DidConsume(result);
396 if (write_buffer_->BytesRemaining() == 0) { 400 if (write_buffer_->BytesRemaining() == 0) {
397 message_sender_->Send(new P2PMsg_OnSendComplete(id_)); 401 message_sender_->Send(new P2PMsg_OnSendComplete(id_));
398 if (write_queue_.empty()) { 402 if (write_queue_.empty()) {
399 write_buffer_ = NULL; 403 write_buffer_ = NULL;
400 } else { 404 } else {
401 write_buffer_ = write_queue_.front(); 405 write_buffer_ = write_queue_.front();
402 write_queue_.pop(); 406 write_queue_.pop();
407 // Update how many bytes are still waiting to be sent.
408 DecrementDelayedBytes(write_buffer_->size());
403 } 409 }
404 } 410 }
405 } else if (result == net::ERR_IO_PENDING) { 411 } else if (result == net::ERR_IO_PENDING) {
406 write_pending_ = true; 412 write_pending_ = true;
407 } else { 413 } else {
408 LOG(ERROR) << "Error when sending data in TCP socket: " << result; 414 LOG(ERROR) << "Error when sending data in TCP socket: " << result;
409 OnError(); 415 OnError();
410 } 416 }
411 } 417 }
412 418
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } else { 607 } else {
602 packet_size += kTurnChannelDataHeaderSize; 608 packet_size += kTurnChannelDataHeaderSize;
603 // Calculate any padding if present. 609 // Calculate any padding if present.
604 if (packet_size % 4) 610 if (packet_size % 4)
605 *pad_bytes = 4 - packet_size % 4; 611 *pad_bytes = 4 - packet_size % 4;
606 } 612 }
607 return packet_size; 613 return packet_size;
608 } 614 }
609 615
610 } // namespace content 616 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698