OLD | NEW |
---|---|
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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
11 #include "base/singleton.h" | 11 #include "base/singleton.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/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
15 #include "net/base/host_resolver.h" | 16 #include "net/base/host_resolver.h" |
16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
18 #include "net/base/ssl_config_service.h" | 19 #include "net/base/ssl_config_service.h" |
19 #include "net/http/http_auth_handler_factory.h" | 20 #include "net/http/http_auth_handler_factory.h" |
20 #include "net/http/http_cache.h" | 21 #include "net/http/http_cache.h" |
21 #include "net/http/http_network_layer.h" | 22 #include "net/http/http_network_layer.h" |
22 #include "net/http/http_request_info.h" | 23 #include "net/http/http_request_info.h" |
23 #include "net/http/http_transaction.h" | 24 #include "net/http/http_transaction.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 } | 133 } |
133 bool use_cache = parsed_command_line.HasSwitch("use-cache"); | 134 bool use_cache = parsed_command_line.HasSwitch("use-cache"); |
134 | 135 |
135 // Do work here. | 136 // Do work here. |
136 MessageLoop loop(MessageLoop::TYPE_IO); | 137 MessageLoop loop(MessageLoop::TYPE_IO); |
137 | 138 |
138 scoped_ptr<net::HostResolver> host_resolver( | 139 scoped_ptr<net::HostResolver> host_resolver( |
139 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, | 140 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, |
140 NULL, NULL)); | 141 NULL, NULL)); |
141 | 142 |
143 scoped_ptr<net::CertVerifier> cert_verifier(new net::CertVerifier); | |
willchan no longer on Chromium
2010/12/13 09:30:53
Why not just do CertVerifier cert_verifier? Do yo
| |
142 scoped_refptr<net::ProxyService> proxy_service( | 144 scoped_refptr<net::ProxyService> proxy_service( |
143 net::ProxyService::CreateDirect()); | 145 net::ProxyService::CreateDirect()); |
144 scoped_refptr<net::SSLConfigService> ssl_config_service( | 146 scoped_refptr<net::SSLConfigService> ssl_config_service( |
145 net::SSLConfigService::CreateSystemSSLConfigService()); | 147 net::SSLConfigService::CreateSystemSSLConfigService()); |
146 net::HttpTransactionFactory* factory = NULL; | 148 net::HttpTransactionFactory* factory = NULL; |
147 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory( | 149 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory( |
148 net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); | 150 net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); |
149 if (use_cache) { | 151 if (use_cache) { |
150 factory = new net::HttpCache(host_resolver.get(), NULL, NULL, proxy_service, | 152 factory = new net::HttpCache(host_resolver.get(), cert_verifier.get(), |
151 ssl_config_service, http_auth_handler_factory.get(), NULL, NULL, | 153 NULL, NULL, proxy_service, ssl_config_service, |
154 http_auth_handler_factory.get(), NULL, NULL, | |
152 net::HttpCache::DefaultBackend::InMemory(0)); | 155 net::HttpCache::DefaultBackend::InMemory(0)); |
153 } else { | 156 } else { |
154 factory = new net::HttpNetworkLayer( | 157 factory = new net::HttpNetworkLayer( |
155 net::ClientSocketFactory::GetDefaultFactory(), | 158 net::ClientSocketFactory::GetDefaultFactory(), |
156 host_resolver.get(), | 159 host_resolver.get(), |
160 cert_verifier.get(), | |
157 NULL /* dnsrr_resolver */, | 161 NULL /* dnsrr_resolver */, |
158 NULL /* dns_cert_checker */, | 162 NULL /* dns_cert_checker */, |
159 NULL /* ssl_host_info_factory */, | 163 NULL /* ssl_host_info_factory */, |
160 proxy_service, | 164 proxy_service, |
161 ssl_config_service, | 165 ssl_config_service, |
162 http_auth_handler_factory.get(), | 166 http_auth_handler_factory.get(), |
163 NULL, | 167 NULL, |
164 NULL); | 168 NULL); |
165 } | 169 } |
166 | 170 |
(...skipping 29 matching lines...) Expand all Loading... | |
196 bps /= 1024; | 200 bps /= 1024; |
197 units = "Kbps"; | 201 units = "Kbps"; |
198 } | 202 } |
199 printf("Bandwidth : %.2f%s\n", bps, units); | 203 printf("Bandwidth : %.2f%s\n", bps, units); |
200 } | 204 } |
201 | 205 |
202 if (parsed_command_line.HasSwitch("stats")) { | 206 if (parsed_command_line.HasSwitch("stats")) { |
203 // Dump the stats table. | 207 // Dump the stats table. |
204 printf("<stats>\n"); | 208 printf("<stats>\n"); |
205 int counter_max = table.GetMaxCounters(); | 209 int counter_max = table.GetMaxCounters(); |
206 for (int index=0; index < counter_max; index++) { | 210 for (int index = 0; index < counter_max; index++) { |
207 std::string name(table.GetRowName(index)); | 211 std::string name(table.GetRowName(index)); |
208 if (name.length() > 0) { | 212 if (name.length() > 0) { |
209 int value = table.GetRowValue(index); | 213 int value = table.GetRowValue(index); |
210 printf("%s:\t%d\n", name.c_str(), value); | 214 printf("%s:\t%d\n", name.c_str(), value); |
211 } | 215 } |
212 } | 216 } |
213 printf("</stats>\n"); | 217 printf("</stats>\n"); |
214 } | 218 } |
215 return 0; | 219 return 0; |
216 } | 220 } |
OLD | NEW |