| 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" |
| 27 #include "net/disk_cache/disk_cache.h" | 28 #include "net/disk_cache/disk_cache.h" |
| 29 #include "net/http/disk_cache_based_ssl_host_info.h" |
| 28 #include "net/http/http_cache_transaction.h" | 30 #include "net/http/http_cache_transaction.h" |
| 29 #include "net/http/http_network_layer.h" | 31 #include "net/http/http_network_layer.h" |
| 30 #include "net/http/http_network_session.h" | 32 #include "net/http/http_network_session.h" |
| 31 #include "net/http/http_request_info.h" | 33 #include "net/http/http_request_info.h" |
| 32 #include "net/http/http_response_headers.h" | 34 #include "net/http/http_response_headers.h" |
| 33 #include "net/http/http_response_info.h" | 35 #include "net/http/http_response_info.h" |
| 34 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
| 35 #include "net/spdy/spdy_session_pool.h" | 37 #include "net/spdy/spdy_session_pool.h" |
| 36 | 38 |
| 37 namespace net { | 39 namespace net { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 237 } |
| 236 | 238 |
| 237 void HttpCache::MetadataWriter::OnIOComplete(int result) { | 239 void HttpCache::MetadataWriter::OnIOComplete(int result) { |
| 238 if (!verified_) | 240 if (!verified_) |
| 239 return VerifyResponse(result); | 241 return VerifyResponse(result); |
| 240 SelfDestroy(); | 242 SelfDestroy(); |
| 241 } | 243 } |
| 242 | 244 |
| 243 //----------------------------------------------------------------------------- | 245 //----------------------------------------------------------------------------- |
| 244 | 246 |
| 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 |
| 245 HttpCache::HttpCache(HostResolver* host_resolver, | 263 HttpCache::HttpCache(HostResolver* host_resolver, |
| 246 DnsRRResolver* dnsrr_resolver, | 264 DnsRRResolver* dnsrr_resolver, |
| 247 ProxyService* proxy_service, | 265 ProxyService* proxy_service, |
| 248 SSLConfigService* ssl_config_service, | 266 SSLConfigService* ssl_config_service, |
| 249 HttpAuthHandlerFactory* http_auth_handler_factory, | 267 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 250 HttpNetworkDelegate* network_delegate, | 268 HttpNetworkDelegate* network_delegate, |
| 251 NetLog* net_log, | 269 NetLog* net_log, |
| 252 BackendFactory* backend_factory) | 270 BackendFactory* backend_factory) |
| 253 : backend_factory_(backend_factory), | 271 : backend_factory_(backend_factory), |
| 254 building_backend_(false), | 272 building_backend_(false), |
| 255 mode_(NORMAL), | 273 mode_(NORMAL), |
| 274 ssl_host_info_factory_(new SSLHostInfoFactoryAdaptor( |
| 275 ALLOW_THIS_IN_INITIALIZER_LIST(this))), |
| 256 network_layer_(HttpNetworkLayer::CreateFactory(host_resolver, | 276 network_layer_(HttpNetworkLayer::CreateFactory(host_resolver, |
| 257 dnsrr_resolver, proxy_service, ssl_config_service, | 277 dnsrr_resolver, ssl_host_info_factory_.get(), |
| 278 proxy_service, ssl_config_service, |
| 258 http_auth_handler_factory, network_delegate, net_log)), | 279 http_auth_handler_factory, network_delegate, net_log)), |
| 259 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 280 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |
| 260 enable_range_support_(true) { | 281 enable_range_support_(true) { |
| 261 } | 282 } |
| 262 | 283 |
| 263 HttpCache::HttpCache(HttpNetworkSession* session, | 284 HttpCache::HttpCache(HttpNetworkSession* session, |
| 264 BackendFactory* backend_factory) | 285 BackendFactory* backend_factory) |
| 265 : backend_factory_(backend_factory), | 286 : backend_factory_(backend_factory), |
| 266 building_backend_(false), | 287 building_backend_(false), |
| 267 mode_(NORMAL), | 288 mode_(NORMAL), |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 building_backend_ = false; | 1079 building_backend_ = false; |
| 1059 DeletePendingOp(pending_op); | 1080 DeletePendingOp(pending_op); |
| 1060 } | 1081 } |
| 1061 | 1082 |
| 1062 // The cache may be gone when we return from the callback. | 1083 // The cache may be gone when we return from the callback. |
| 1063 if (!item->DoCallback(result, backend)) | 1084 if (!item->DoCallback(result, backend)) |
| 1064 item->NotifyTransaction(result, NULL); | 1085 item->NotifyTransaction(result, NULL); |
| 1065 } | 1086 } |
| 1066 | 1087 |
| 1067 } // namespace net | 1088 } // namespace net |
| OLD | NEW |