| 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 "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 | 10 |
| 11 #if defined(OS_POSIX) | 11 #if defined(OS_POSIX) |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
| 17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 18 #include "base/pickle.h" | 18 #include "base/pickle.h" |
| 19 #include "base/ref_counted.h" | 19 #include "base/ref_counted.h" |
| 20 #include "base/stl_util-inl.h" | 20 #include "base/stl_util-inl.h" |
| 21 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
| 22 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
| 24 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 25 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 26 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 27 #include "net/base/ssl_host_info.h" | |
| 28 #include "net/disk_cache/disk_cache.h" | 27 #include "net/disk_cache/disk_cache.h" |
| 29 #include "net/http/disk_cache_based_ssl_host_info.h" | |
| 30 #include "net/http/http_cache_transaction.h" | 28 #include "net/http/http_cache_transaction.h" |
| 31 #include "net/http/http_network_layer.h" | 29 #include "net/http/http_network_layer.h" |
| 32 #include "net/http/http_network_session.h" | 30 #include "net/http/http_network_session.h" |
| 33 #include "net/http/http_request_info.h" | 31 #include "net/http/http_request_info.h" |
| 34 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| 35 #include "net/http/http_response_info.h" | 33 #include "net/http/http_response_info.h" |
| 36 #include "net/http/http_util.h" | 34 #include "net/http/http_util.h" |
| 37 #include "net/spdy/spdy_session_pool.h" | 35 #include "net/spdy/spdy_session_pool.h" |
| 38 | 36 |
| 39 namespace net { | 37 namespace net { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 235 } |
| 238 | 236 |
| 239 void HttpCache::MetadataWriter::OnIOComplete(int result) { | 237 void HttpCache::MetadataWriter::OnIOComplete(int result) { |
| 240 if (!verified_) | 238 if (!verified_) |
| 241 return VerifyResponse(result); | 239 return VerifyResponse(result); |
| 242 SelfDestroy(); | 240 SelfDestroy(); |
| 243 } | 241 } |
| 244 | 242 |
| 245 //----------------------------------------------------------------------------- | 243 //----------------------------------------------------------------------------- |
| 246 | 244 |
| 247 class HttpCache::SSLHostInfoFactoryAdaptor : public SSLHostInfoFactory { | |
| 248 public: | |
| 249 SSLHostInfoFactoryAdaptor(HttpCache* http_cache) | |
| 250 : http_cache_(http_cache) { | |
| 251 } | |
| 252 | |
| 253 SSLHostInfo* GetForHost(const std::string& hostname) { | |
| 254 return new DiskCacheBasedSSLHostInfo(hostname, http_cache_); | |
| 255 } | |
| 256 | |
| 257 private: | |
| 258 HttpCache* const http_cache_; | |
| 259 }; | |
| 260 | |
| 261 //----------------------------------------------------------------------------- | |
| 262 | |
| 263 HttpCache::HttpCache(HostResolver* host_resolver, | 245 HttpCache::HttpCache(HostResolver* host_resolver, |
| 264 DnsRRResolver* dnsrr_resolver, | 246 DnsRRResolver* dnsrr_resolver, |
| 265 ProxyService* proxy_service, | 247 ProxyService* proxy_service, |
| 266 SSLConfigService* ssl_config_service, | 248 SSLConfigService* ssl_config_service, |
| 267 HttpAuthHandlerFactory* http_auth_handler_factory, | 249 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 268 HttpNetworkDelegate* network_delegate, | 250 HttpNetworkDelegate* network_delegate, |
| 269 NetLog* net_log, | 251 NetLog* net_log, |
| 270 BackendFactory* backend_factory) | 252 BackendFactory* backend_factory) |
| 271 : backend_factory_(backend_factory), | 253 : backend_factory_(backend_factory), |
| 272 building_backend_(false), | 254 building_backend_(false), |
| 273 mode_(NORMAL), | 255 mode_(NORMAL), |
| 274 ssl_host_info_factory_(new SSLHostInfoFactoryAdaptor( | |
| 275 ALLOW_THIS_IN_INITIALIZER_LIST(this))), | |
| 276 network_layer_(HttpNetworkLayer::CreateFactory(host_resolver, | 256 network_layer_(HttpNetworkLayer::CreateFactory(host_resolver, |
| 277 dnsrr_resolver, ssl_host_info_factory_.get(), | 257 dnsrr_resolver, proxy_service, ssl_config_service, |
| 278 proxy_service, ssl_config_service, | |
| 279 http_auth_handler_factory, network_delegate, net_log)), | 258 http_auth_handler_factory, network_delegate, net_log)), |
| 280 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 259 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |
| 281 enable_range_support_(true) { | 260 enable_range_support_(true) { |
| 282 } | 261 } |
| 283 | 262 |
| 284 HttpCache::HttpCache(HttpNetworkSession* session, | 263 HttpCache::HttpCache(HttpNetworkSession* session, |
| 285 BackendFactory* backend_factory) | 264 BackendFactory* backend_factory) |
| 286 : backend_factory_(backend_factory), | 265 : backend_factory_(backend_factory), |
| 287 building_backend_(false), | 266 building_backend_(false), |
| 288 mode_(NORMAL), | 267 mode_(NORMAL), |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 building_backend_ = false; | 1058 building_backend_ = false; |
| 1080 DeletePendingOp(pending_op); | 1059 DeletePendingOp(pending_op); |
| 1081 } | 1060 } |
| 1082 | 1061 |
| 1083 // The cache may be gone when we return from the callback. | 1062 // The cache may be gone when we return from the callback. |
| 1084 if (!item->DoCallback(result, backend)) | 1063 if (!item->DoCallback(result, backend)) |
| 1085 item->NotifyTransaction(result, NULL); | 1064 item->NotifyTransaction(result, NULL); |
| 1086 } | 1065 } |
| 1087 | 1066 |
| 1088 } // namespace net | 1067 } // namespace net |
| OLD | NEW |