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

Side by Side Diff: chrome/browser/net/network_stats.cc

Issue 16296002: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/evicted_domain_cookie_counter.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/net/network_stats.h" 5 #include "chrome/browser/net/network_stats.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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 int rv; 360 int rv;
361 do { 361 do {
362 if (!socket_.get()) 362 if (!socket_.get())
363 break; 363 break;
364 364
365 DCHECK(!read_buffer_.get()); 365 DCHECK(!read_buffer_.get());
366 366
367 // We release the read_buffer_ in the destructor if there is an error. 367 // We release the read_buffer_ in the destructor if there is an error.
368 read_buffer_ = new net::IOBuffer(kMaxMessage); 368 read_buffer_ = new net::IOBuffer(kMaxMessage);
369 369
370 rv = socket_->Read(read_buffer_, kMaxMessage, 370 rv = socket_->Read(
371 base::Bind(&NetworkStats::OnReadComplete, 371 read_buffer_.get(),
372 base::Unretained(this))); 372 kMaxMessage,
373 base::Bind(&NetworkStats::OnReadComplete, base::Unretained(this)));
373 if (rv == net::ERR_IO_PENDING) 374 if (rv == net::ERR_IO_PENDING)
374 break; 375 break;
375 376
376 // If we have read all the data then return. 377 // If we have read all the data then return.
377 if (ReadComplete(rv)) 378 if (ReadComplete(rv))
378 break; 379 break;
379 } while (rv > 0); 380 } while (rv > 0);
380 } 381 }
381 382
382 int NetworkStats::SendData() { 383 int NetworkStats::SendData() {
383 DCHECK(bytes_to_send_); // We should have data to send. 384 DCHECK(bytes_to_send_); // We should have data to send.
384 do { 385 do {
385 if (!write_buffer_.get()) { 386 if (!write_buffer_.get()) {
386 // Send a new packet. 387 // Send a new packet.
387 scoped_refptr<net::IOBufferWithSize> buffer( 388 scoped_refptr<net::IOBufferWithSize> buffer(
388 new net::IOBufferWithSize(bytes_to_send_)); 389 new net::IOBufferWithSize(bytes_to_send_));
389 GetEchoRequest(buffer); 390 GetEchoRequest(buffer.get());
390 write_buffer_ = new net::DrainableIOBuffer(buffer, bytes_to_send_); 391 write_buffer_ = new net::DrainableIOBuffer(buffer.get(), bytes_to_send_);
391 392
392 // As soon as we write, a read could happen. Thus update all the book 393 // As soon as we write, a read could happen. Thus update all the book
393 // keeping data. 394 // keeping data.
394 bytes_to_read_ += ReceivingPacketSize(); 395 bytes_to_read_ += ReceivingPacketSize();
395 ++packets_sent_; 396 ++packets_sent_;
396 if (packets_sent_ >= packets_to_send_) 397 if (packets_sent_ >= packets_to_send_)
397 sending_complete_ = true; 398 sending_complete_ = true;
398 399
399 uint32 packet_index = packet_number_ - base_packet_number_; 400 uint32 packet_index = packet_number_ - base_packet_number_;
400 DCHECK_GE(packet_index, 0u); 401 DCHECK_GE(packet_index, 0u);
401 DCHECK_LT(packet_index, packet_status_.size()); 402 DCHECK_LT(packet_index, packet_status_.size());
402 packet_status_[packet_index].start_time_ = base::TimeTicks::Now(); 403 packet_status_[packet_index].start_time_ = base::TimeTicks::Now();
403 } 404 }
404 405
405 if (!socket_.get()) 406 if (!socket_.get())
406 return net::ERR_UNEXPECTED; 407 return net::ERR_UNEXPECTED;
407 int rv = socket_->Write(write_buffer_, 408 int rv = socket_->Write(
408 write_buffer_->BytesRemaining(), 409 write_buffer_.get(),
409 base::Bind(&NetworkStats::OnWriteComplete, 410 write_buffer_->BytesRemaining(),
410 base::Unretained(this))); 411 base::Bind(&NetworkStats::OnWriteComplete, base::Unretained(this)));
411 if (rv < 0) 412 if (rv < 0)
412 return rv; 413 return rv;
413 DidSendData(rv); 414 DidSendData(rv);
414 } while (bytes_to_send_); 415 } while (bytes_to_send_);
415 return net::OK; 416 return net::OK;
416 } 417 }
417 418
418 uint32 NetworkStats::SendingPacketSize() const { 419 uint32 NetworkStats::SendingPacketSize() const {
419 return kVersionLength + kChecksumLength + kPayloadSizeLength + load_size_; 420 return kVersionLength + kChecksumLength + kPayloadSizeLength + load_size_;
420 } 421 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 udp_stats_client->Start( 1013 udp_stats_client->Start(
1013 host_resolver, server_address, histogram_port, has_proxy_server, 1014 host_resolver, server_address, histogram_port, has_proxy_server,
1014 kLargeTestBytesToSend, kMaximumSequentialPackets, 1015 kLargeTestBytesToSend, kMaximumSequentialPackets,
1015 net::CompletionCallback()); 1016 net::CompletionCallback());
1016 } 1017 }
1017 break; 1018 break;
1018 } 1019 }
1019 } 1020 }
1020 1021
1021 } // namespace chrome_browser_net 1022 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/evicted_domain_cookie_counter.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698