| 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/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/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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 134 } |
| 134 bool use_cache = parsed_command_line.HasSwitch("use-cache"); | 135 bool use_cache = parsed_command_line.HasSwitch("use-cache"); |
| 135 | 136 |
| 136 // Do work here. | 137 // Do work here. |
| 137 MessageLoop loop(MessageLoop::TYPE_IO); | 138 MessageLoop loop(MessageLoop::TYPE_IO); |
| 138 | 139 |
| 139 scoped_ptr<net::HostResolver> host_resolver( | 140 scoped_ptr<net::HostResolver> host_resolver( |
| 140 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, | 141 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, |
| 141 NULL, NULL)); | 142 NULL, NULL)); |
| 142 | 143 |
| 144 scoped_ptr<net::CertVerifier> cert_verifier(new net::CertVerifier); |
| 143 scoped_refptr<net::ProxyService> proxy_service( | 145 scoped_refptr<net::ProxyService> proxy_service( |
| 144 net::ProxyService::CreateDirect()); | 146 net::ProxyService::CreateDirect()); |
| 145 scoped_refptr<net::SSLConfigService> ssl_config_service( | 147 scoped_refptr<net::SSLConfigService> ssl_config_service( |
| 146 net::SSLConfigService::CreateSystemSSLConfigService()); | 148 net::SSLConfigService::CreateSystemSSLConfigService()); |
| 147 net::HttpTransactionFactory* factory = NULL; | 149 net::HttpTransactionFactory* factory = NULL; |
| 148 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory( | 150 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory( |
| 149 net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); | 151 net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); |
| 150 if (use_cache) { | 152 if (use_cache) { |
| 151 factory = new net::HttpCache(host_resolver.get(), NULL, NULL, proxy_service, | 153 factory = new net::HttpCache(host_resolver.get(), cert_verifier.get(), |
| 152 ssl_config_service, http_auth_handler_factory.get(), NULL, NULL, | 154 NULL, NULL, proxy_service, ssl_config_service, |
| 155 http_auth_handler_factory.get(), NULL, NULL, |
| 153 net::HttpCache::DefaultBackend::InMemory(0)); | 156 net::HttpCache::DefaultBackend::InMemory(0)); |
| 154 } else { | 157 } else { |
| 155 factory = new net::HttpNetworkLayer( | 158 factory = new net::HttpNetworkLayer( |
| 156 net::ClientSocketFactory::GetDefaultFactory(), | 159 net::ClientSocketFactory::GetDefaultFactory(), |
| 157 host_resolver.get(), | 160 host_resolver.get(), |
| 161 cert_verifier.get(), |
| 158 NULL /* dnsrr_resolver */, | 162 NULL /* dnsrr_resolver */, |
| 159 NULL /* dns_cert_checker */, | 163 NULL /* dns_cert_checker */, |
| 160 NULL /* ssl_host_info_factory */, | 164 NULL /* ssl_host_info_factory */, |
| 161 proxy_service, | 165 proxy_service, |
| 162 ssl_config_service, | 166 ssl_config_service, |
| 163 http_auth_handler_factory.get(), | 167 http_auth_handler_factory.get(), |
| 164 NULL, | 168 NULL, |
| 165 NULL); | 169 NULL); |
| 166 } | 170 } |
| 167 | 171 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 197 bps /= 1024; | 201 bps /= 1024; |
| 198 units = "Kbps"; | 202 units = "Kbps"; |
| 199 } | 203 } |
| 200 printf("Bandwidth : %.2f%s\n", bps, units); | 204 printf("Bandwidth : %.2f%s\n", bps, units); |
| 201 } | 205 } |
| 202 | 206 |
| 203 if (parsed_command_line.HasSwitch("stats")) { | 207 if (parsed_command_line.HasSwitch("stats")) { |
| 204 // Dump the stats table. | 208 // Dump the stats table. |
| 205 printf("<stats>\n"); | 209 printf("<stats>\n"); |
| 206 int counter_max = table.GetMaxCounters(); | 210 int counter_max = table.GetMaxCounters(); |
| 207 for (int index=0; index < counter_max; index++) { | 211 for (int index = 0; index < counter_max; index++) { |
| 208 std::string name(table.GetRowName(index)); | 212 std::string name(table.GetRowName(index)); |
| 209 if (name.length() > 0) { | 213 if (name.length() > 0) { |
| 210 int value = table.GetRowValue(index); | 214 int value = table.GetRowValue(index); |
| 211 printf("%s:\t%d\n", name.c_str(), value); | 215 printf("%s:\t%d\n", name.c_str(), value); |
| 212 } | 216 } |
| 213 } | 217 } |
| 214 printf("</stats>\n"); | 218 printf("</stats>\n"); |
| 215 } | 219 } |
| 216 return 0; | 220 return 0; |
| 217 } | 221 } |
| OLD | NEW |