| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 26 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" | 
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" | 
| 28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" | 
| 29 #include "base/threading/worker_pool.h" | 29 #include "base/threading/worker_pool.h" | 
| 30 #include "net/base/cache_type.h" | 30 #include "net/base/cache_type.h" | 
| 31 #include "net/base/io_buffer.h" | 31 #include "net/base/io_buffer.h" | 
| 32 #include "net/base/load_flags.h" | 32 #include "net/base/load_flags.h" | 
| 33 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" | 
| 34 #include "net/base/upload_data_stream.h" | 34 #include "net/base/upload_data_stream.h" | 
| 35 #include "net/disk_cache/disk_cache.h" | 35 #include "net/disk_cache/disk_cache.h" | 
|  | 36 #include "net/http/disk_cache_based_ssl_host_info.h" | 
| 36 #include "net/http/http_cache_transaction.h" | 37 #include "net/http/http_cache_transaction.h" | 
| 37 #include "net/http/http_network_layer.h" | 38 #include "net/http/http_network_layer.h" | 
| 38 #include "net/http/http_network_session.h" | 39 #include "net/http/http_network_session.h" | 
| 39 #include "net/http/http_request_info.h" | 40 #include "net/http/http_request_info.h" | 
| 40 #include "net/http/http_response_headers.h" | 41 #include "net/http/http_response_headers.h" | 
| 41 #include "net/http/http_response_info.h" | 42 #include "net/http/http_response_info.h" | 
| 42 #include "net/http/http_util.h" | 43 #include "net/http/http_util.h" | 
|  | 44 #include "net/socket/ssl_host_info.h" | 
| 43 | 45 | 
| 44 namespace { | 46 namespace { | 
| 45 | 47 | 
| 46 // Adaptor to delete a file on a worker thread. | 48 // Adaptor to delete a file on a worker thread. | 
| 47 void DeletePath(base::FilePath path) { | 49 void DeletePath(base::FilePath path) { | 
| 48   base::DeleteFile(path, false); | 50   base::DeleteFile(path, false); | 
| 49 } | 51 } | 
| 50 | 52 | 
| 51 }  // namespace | 53 }  // namespace | 
| 52 | 54 | 
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 260 } | 262 } | 
| 261 | 263 | 
| 262 void HttpCache::MetadataWriter::OnIOComplete(int result) { | 264 void HttpCache::MetadataWriter::OnIOComplete(int result) { | 
| 263   if (!verified_) | 265   if (!verified_) | 
| 264     return VerifyResponse(result); | 266     return VerifyResponse(result); | 
| 265   SelfDestroy(); | 267   SelfDestroy(); | 
| 266 } | 268 } | 
| 267 | 269 | 
| 268 //----------------------------------------------------------------------------- | 270 //----------------------------------------------------------------------------- | 
| 269 | 271 | 
|  | 272 class HttpCache::SSLHostInfoFactoryAdaptor : public SSLHostInfoFactory { | 
|  | 273  public: | 
|  | 274   SSLHostInfoFactoryAdaptor(CertVerifier* cert_verifier, HttpCache* http_cache) | 
|  | 275       : cert_verifier_(cert_verifier), | 
|  | 276         http_cache_(http_cache) { | 
|  | 277   } | 
|  | 278 | 
|  | 279   virtual SSLHostInfo* GetForHost(const std::string& hostname, | 
|  | 280                                   const SSLConfig& ssl_config) OVERRIDE { | 
|  | 281     return new DiskCacheBasedSSLHostInfo( | 
|  | 282         hostname, ssl_config, cert_verifier_, http_cache_); | 
|  | 283   } | 
|  | 284 | 
|  | 285  private: | 
|  | 286   CertVerifier* const cert_verifier_; | 
|  | 287   HttpCache* const http_cache_; | 
|  | 288 }; | 
|  | 289 | 
|  | 290 //----------------------------------------------------------------------------- | 
| 270 HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, | 291 HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, | 
| 271                      BackendFactory* backend_factory) | 292                      BackendFactory* backend_factory) | 
| 272     : net_log_(params.net_log), | 293     : net_log_(params.net_log), | 
| 273       backend_factory_(backend_factory), | 294       backend_factory_(backend_factory), | 
| 274       building_backend_(false), | 295       building_backend_(false), | 
| 275       mode_(NORMAL), | 296       mode_(NORMAL), | 
|  | 297       ssl_host_info_factory_(new SSLHostInfoFactoryAdaptor( | 
|  | 298           params.cert_verifier, this)), | 
| 276       network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))) { | 299       network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))) { | 
| 277 } | 300 } | 
| 278 | 301 | 
| 279 | 302 | 
| 280 HttpCache::HttpCache(HttpNetworkSession* session, | 303 HttpCache::HttpCache(HttpNetworkSession* session, | 
| 281                      BackendFactory* backend_factory) | 304                      BackendFactory* backend_factory) | 
| 282     : net_log_(session->net_log()), | 305     : net_log_(session->net_log()), | 
| 283       backend_factory_(backend_factory), | 306       backend_factory_(backend_factory), | 
| 284       building_backend_(false), | 307       building_backend_(false), | 
| 285       mode_(NORMAL), | 308       mode_(NORMAL), | 
|  | 309       ssl_host_info_factory_(new SSLHostInfoFactoryAdaptor( | 
|  | 310           session->cert_verifier(), this)), | 
| 286       network_layer_(new HttpNetworkLayer(session)) { | 311       network_layer_(new HttpNetworkLayer(session)) { | 
| 287 } | 312 } | 
| 288 | 313 | 
| 289 HttpCache::HttpCache(HttpTransactionFactory* network_layer, | 314 HttpCache::HttpCache(HttpTransactionFactory* network_layer, | 
| 290                      NetLog* net_log, | 315                      NetLog* net_log, | 
| 291                      BackendFactory* backend_factory) | 316                      BackendFactory* backend_factory) | 
| 292     : net_log_(net_log), | 317     : net_log_(net_log), | 
| 293       backend_factory_(backend_factory), | 318       backend_factory_(backend_factory), | 
| 294       building_backend_(false), | 319       building_backend_(false), | 
| 295       mode_(NORMAL), | 320       mode_(NORMAL), | 
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1140     building_backend_ = false; | 1165     building_backend_ = false; | 
| 1141     DeletePendingOp(pending_op); | 1166     DeletePendingOp(pending_op); | 
| 1142   } | 1167   } | 
| 1143 | 1168 | 
| 1144   // The cache may be gone when we return from the callback. | 1169   // The cache may be gone when we return from the callback. | 
| 1145   if (!item->DoCallback(result, disk_cache_.get())) | 1170   if (!item->DoCallback(result, disk_cache_.get())) | 
| 1146     item->NotifyTransaction(result, NULL); | 1171     item->NotifyTransaction(result, NULL); | 
| 1147 } | 1172 } | 
| 1148 | 1173 | 
| 1149 }  // namespace net | 1174 }  // namespace net | 
| OLD | NEW | 
|---|