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

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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 } // namespace 43 } // namespace
44 44
45 namespace content { 45 namespace content {
46 46
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, P2PSocketHost::TCP),
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 } 57 }
58 58
59 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { 59 P2PSocketHostTcpBase::~P2PSocketHostTcpBase() {
60 if (state_ == STATE_OPEN) { 60 if (state_ == STATE_OPEN) {
61 DCHECK(socket_.get()); 61 DCHECK(socket_.get());
62 socket_.reset(); 62 socket_.reset();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 OnError(); 354 OnError();
355 return; 355 return;
356 } 356 }
357 } 357 }
358 358
359 DoSend(to, data, options); 359 DoSend(to, data, options);
360 } 360 }
361 361
362 void P2PSocketHostTcpBase::WriteOrQueue( 362 void P2PSocketHostTcpBase::WriteOrQueue(
363 scoped_refptr<net::DrainableIOBuffer>& buffer) { 363 scoped_refptr<net::DrainableIOBuffer>& buffer) {
364 IncrementTotalSentPackets();
364 if (write_buffer_.get()) { 365 if (write_buffer_.get()) {
365 write_queue_.push(buffer); 366 write_queue_.push(buffer);
367 IncrementDelayedPackets();
368 IncrementDelayedBytes(buffer->size());
366 return; 369 return;
367 } 370 }
368 371
369 write_buffer_ = buffer; 372 write_buffer_ = buffer;
370 DoWrite(); 373 DoWrite();
371 } 374 }
372 375
373 void P2PSocketHostTcpBase::DoWrite() { 376 void P2PSocketHostTcpBase::DoWrite() {
374 while (write_buffer_.get() && state_ == STATE_OPEN && !write_pending_) { 377 while (write_buffer_.get() && state_ == STATE_OPEN && !write_pending_) {
375 int result = socket_->Write( 378 int result = socket_->Write(
(...skipping 17 matching lines...) Expand all
393 DCHECK(write_buffer_.get()); 396 DCHECK(write_buffer_.get());
394 if (result >= 0) { 397 if (result >= 0) {
395 write_buffer_->DidConsume(result); 398 write_buffer_->DidConsume(result);
396 if (write_buffer_->BytesRemaining() == 0) { 399 if (write_buffer_->BytesRemaining() == 0) {
397 message_sender_->Send(new P2PMsg_OnSendComplete(id_)); 400 message_sender_->Send(new P2PMsg_OnSendComplete(id_));
398 if (write_queue_.empty()) { 401 if (write_queue_.empty()) {
399 write_buffer_ = NULL; 402 write_buffer_ = NULL;
400 } else { 403 } else {
401 write_buffer_ = write_queue_.front(); 404 write_buffer_ = write_queue_.front();
402 write_queue_.pop(); 405 write_queue_.pop();
406 // Update how many bytes are still waiting to be sent.
407 DecrementDelayedBytes(write_buffer_->size());
403 } 408 }
404 } 409 }
405 } else if (result == net::ERR_IO_PENDING) { 410 } else if (result == net::ERR_IO_PENDING) {
406 write_pending_ = true; 411 write_pending_ = true;
407 } else { 412 } else {
408 LOG(ERROR) << "Error when sending data in TCP socket: " << result; 413 LOG(ERROR) << "Error when sending data in TCP socket: " << result;
409 OnError(); 414 OnError();
410 } 415 }
411 } 416 }
412 417
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } else { 606 } else {
602 packet_size += kTurnChannelDataHeaderSize; 607 packet_size += kTurnChannelDataHeaderSize;
603 // Calculate any padding if present. 608 // Calculate any padding if present.
604 if (packet_size % 4) 609 if (packet_size % 4)
605 *pad_bytes = 4 - packet_size % 4; 610 *pad_bytes = 4 - packet_size % 4;
606 } 611 }
607 return packet_size; 612 return packet_size;
608 } 613 }
609 614
610 } // namespace content 615 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host.cc ('k') | content/browser/renderer_host/p2p/socket_host_tcp_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698