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

Side by Side Diff: net/tools/fetch/fetch_client.cc

Issue 6402002: Simplify HttpCache/HttpNetworkLayer/HttpNetworkSession interaction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 9 years, 10 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 | « net/spdy/spdy_test_util.cc ('k') | net/url_request/url_request_test_util.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/metrics/stats_counters.h" 11 #include "base/metrics/stats_counters.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "net/base/cert_verifier.h" 14 #include "net/base/cert_verifier.h"
15 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
16 #include "net/base/host_resolver.h" 16 #include "net/base/host_resolver.h"
17 #include "net/base/io_buffer.h" 17 #include "net/base/io_buffer.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 #include "net/base/ssl_config_service.h" 19 #include "net/base/ssl_config_service.h"
20 #include "net/http/http_auth_handler_factory.h" 20 #include "net/http/http_auth_handler_factory.h"
21 #include "net/http/http_cache.h" 21 #include "net/http/http_cache.h"
22 #include "net/http/http_network_layer.h" 22 #include "net/http/http_network_layer.h"
23 #include "net/http/http_network_session.h"
23 #include "net/http/http_request_info.h" 24 #include "net/http/http_request_info.h"
24 #include "net/http/http_transaction.h" 25 #include "net/http/http_transaction.h"
25 #include "net/proxy/proxy_service.h" 26 #include "net/proxy/proxy_service.h"
26 #include "net/socket/client_socket_factory.h" 27 #include "net/socket/client_socket_factory.h"
28 #include "net/spdy/spdy_session_pool.h"
27 29
28 void usage(const char* program_name) { 30 void usage(const char* program_name) {
29 printf("usage: %s --url=<url> [--n=<clients>] [--stats] [--use_cache]\n", 31 printf("usage: %s --url=<url> [--n=<clients>] [--stats] [--use_cache]\n",
30 program_name); 32 program_name);
31 exit(1); 33 exit(1);
32 } 34 }
33 35
34 // Test Driver 36 // Test Driver
35 class Driver { 37 class Driver {
36 public: 38 public:
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 NULL, NULL)); 144 NULL, NULL));
143 145
144 scoped_ptr<net::CertVerifier> cert_verifier(new net::CertVerifier); 146 scoped_ptr<net::CertVerifier> cert_verifier(new net::CertVerifier);
145 scoped_refptr<net::ProxyService> proxy_service( 147 scoped_refptr<net::ProxyService> proxy_service(
146 net::ProxyService::CreateDirect()); 148 net::ProxyService::CreateDirect());
147 scoped_refptr<net::SSLConfigService> ssl_config_service( 149 scoped_refptr<net::SSLConfigService> ssl_config_service(
148 net::SSLConfigService::CreateSystemSSLConfigService()); 150 net::SSLConfigService::CreateSystemSSLConfigService());
149 net::HttpTransactionFactory* factory = NULL; 151 net::HttpTransactionFactory* factory = NULL;
150 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory( 152 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory(
151 net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); 153 net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
154 scoped_refptr<net::HttpNetworkSession> network_session(
155 new net::HttpNetworkSession(
156 host_resolver.get(),
157 cert_verifier.get(),
158 NULL /* dnsrr_resolver */,
159 NULL /* dns_cert_checker */,
160 NULL /* ssl_host_info_factory */,
161 proxy_service,
162 net::ClientSocketFactory::GetDefaultFactory(),
163 ssl_config_service,
164 new net::SpdySessionPool(NULL),
165 http_auth_handler_factory.get(),
166 NULL,
167 NULL));
152 if (use_cache) { 168 if (use_cache) {
153 factory = new net::HttpCache(host_resolver.get(), cert_verifier.get(), 169 factory = new net::HttpCache(network_session,
154 NULL, NULL, proxy_service, ssl_config_service, 170 net::HttpCache::DefaultBackend::InMemory(0));
155 http_auth_handler_factory.get(), NULL, NULL,
156 net::HttpCache::DefaultBackend::InMemory(0));
157 } else { 171 } else {
158 factory = new net::HttpNetworkLayer( 172 factory = new net::HttpNetworkLayer(network_session);
159 net::ClientSocketFactory::GetDefaultFactory(),
160 host_resolver.get(),
161 cert_verifier.get(),
162 NULL /* dnsrr_resolver */,
163 NULL /* dns_cert_checker */,
164 NULL /* ssl_host_info_factory */,
165 proxy_service,
166 ssl_config_service,
167 http_auth_handler_factory.get(),
168 NULL,
169 NULL);
170 } 173 }
171 174
172 { 175 {
173 base::StatsCounterTimer driver_time("FetchClient.total_time"); 176 base::StatsCounterTimer driver_time("FetchClient.total_time");
174 base::StatsScope<base::StatsCounterTimer> scope(driver_time); 177 base::StatsScope<base::StatsCounterTimer> scope(driver_time);
175 178
176 Client** clients = new Client*[client_limit]; 179 Client** clients = new Client*[client_limit];
177 for (int i = 0; i < client_limit; i++) 180 for (int i = 0; i < client_limit; i++)
178 clients[i] = new Client(factory, url); 181 clients[i] = new Client(factory, url);
179 182
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 std::string name(table.GetRowName(index)); 215 std::string name(table.GetRowName(index));
213 if (name.length() > 0) { 216 if (name.length() > 0) {
214 int value = table.GetRowValue(index); 217 int value = table.GetRowValue(index);
215 printf("%s:\t%d\n", name.c_str(), value); 218 printf("%s:\t%d\n", name.c_str(), value);
216 } 219 }
217 } 220 }
218 printf("</stats>\n"); 221 printf("</stats>\n");
219 } 222 }
220 return 0; 223 return 0;
221 } 224 }
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util.cc ('k') | net/url_request/url_request_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698