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

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

Issue 8549004: base::Bind: Convert HostResolver::Resolve. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/network_stats.h ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/callback_old.h" 7 #include "base/callback_old.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // the <encoded_payload> in "echo response". 75 // the <encoded_payload> in "echo response".
76 static const uint32 kEncodedPayloadStart = kKeyEnd; 76 static const uint32 kEncodedPayloadStart = kKeyEnd;
77 77
78 // NetworkStats methods and members. 78 // NetworkStats methods and members.
79 NetworkStats::NetworkStats() 79 NetworkStats::NetworkStats()
80 : load_size_(0), 80 : load_size_(0),
81 bytes_to_read_(0), 81 bytes_to_read_(0),
82 bytes_to_send_(0), 82 bytes_to_send_(0),
83 encoded_message_(""), 83 encoded_message_(""),
84 ALLOW_THIS_IN_INITIALIZER_LIST( 84 ALLOW_THIS_IN_INITIALIZER_LIST(
85 resolve_callback_(this, &NetworkStats::OnResolveComplete)),
86 ALLOW_THIS_IN_INITIALIZER_LIST(
87 read_callback_(this, &NetworkStats::OnReadComplete)), 85 read_callback_(this, &NetworkStats::OnReadComplete)),
88 ALLOW_THIS_IN_INITIALIZER_LIST( 86 ALLOW_THIS_IN_INITIALIZER_LIST(
89 write_callback_(this, &NetworkStats::OnWriteComplete)), 87 write_callback_(this, &NetworkStats::OnWriteComplete)),
90 finished_callback_(NULL), 88 finished_callback_(NULL),
91 start_time_(base::TimeTicks::Now()), 89 start_time_(base::TimeTicks::Now()),
92 ALLOW_THIS_IN_INITIALIZER_LIST(timers_factory_(this)) { 90 ALLOW_THIS_IN_INITIALIZER_LIST(timers_factory_(this)) {
93 } 91 }
94 92
95 NetworkStats::~NetworkStats() { 93 NetworkStats::~NetworkStats() {
96 socket_.reset(); 94 socket_.reset();
97 } 95 }
98 96
99 bool NetworkStats::Start(net::HostResolver* host_resolver, 97 bool NetworkStats::Start(net::HostResolver* host_resolver,
100 const net::HostPortPair& server_host_port_pair, 98 const net::HostPortPair& server_host_port_pair,
101 uint32 bytes_to_send, 99 uint32 bytes_to_send,
102 net::OldCompletionCallback* finished_callback) { 100 net::OldCompletionCallback* finished_callback) {
103 DCHECK(bytes_to_send); // We should have data to send. 101 DCHECK(bytes_to_send); // We should have data to send.
104 102
105 Initialize(bytes_to_send, finished_callback); 103 Initialize(bytes_to_send, finished_callback);
106 104
107 net::HostResolver::RequestInfo request(server_host_port_pair); 105 net::HostResolver::RequestInfo request(server_host_port_pair);
108 int rv = host_resolver->Resolve(request, 106 int rv = host_resolver->Resolve(
109 &addresses_, 107 request, &addresses_,
110 &resolve_callback_, 108 base::Bind(&NetworkStats::OnResolveComplete,
111 NULL, 109 base::Unretained(this)),
112 net::BoundNetLog()); 110 NULL, net::BoundNetLog());
113 if (rv == net::ERR_IO_PENDING) 111 if (rv == net::ERR_IO_PENDING)
114 return true; 112 return true;
115 return DoConnect(rv); 113 return DoConnect(rv);
116 } 114 }
117 115
118 void NetworkStats::Initialize(uint32 bytes_to_send, 116 void NetworkStats::Initialize(uint32 bytes_to_send,
119 net::OldCompletionCallback* finished_callback) { 117 net::OldCompletionCallback* finished_callback) {
120 DCHECK(bytes_to_send); // We should have data to send. 118 DCHECK(bytes_to_send); // We should have data to send.
121 119
122 load_size_ = bytes_to_send; 120 load_size_ = bytes_to_send;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 TCPStatsClient* small_tcp_client = new TCPStatsClient(); 596 TCPStatsClient* small_tcp_client = new TCPStatsClient();
599 small_tcp_client->Start( 597 small_tcp_client->Start(
600 host_resolver, tcp_server_address, kSmallTestBytesToSend, NULL); 598 host_resolver, tcp_server_address, kSmallTestBytesToSend, NULL);
601 599
602 TCPStatsClient* large_tcp_client = new TCPStatsClient(); 600 TCPStatsClient* large_tcp_client = new TCPStatsClient();
603 large_tcp_client->Start( 601 large_tcp_client->Start(
604 host_resolver, tcp_server_address, kLargeTestBytesToSend, NULL); 602 host_resolver, tcp_server_address, kLargeTestBytesToSend, NULL);
605 } 603 }
606 604
607 } // namespace chrome_browser_net 605 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/network_stats.h ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698