| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 QuicServerInfo* GetForServer(const QuicServerId& server_id) override { | 288 QuicServerInfo* GetForServer(const QuicServerId& server_id) override { |
| 289 return new DiskCacheBasedQuicServerInfo(server_id, http_cache_); | 289 return new DiskCacheBasedQuicServerInfo(server_id, http_cache_); |
| 290 } | 290 } |
| 291 | 291 |
| 292 private: | 292 private: |
| 293 HttpCache* const http_cache_; | 293 HttpCache* const http_cache_; |
| 294 }; | 294 }; |
| 295 | 295 |
| 296 //----------------------------------------------------------------------------- | 296 //----------------------------------------------------------------------------- |
| 297 HttpCache::HttpCache(const HttpNetworkSession::Params& params, | |
| 298 BackendFactory* backend_factory) | |
| 299 : net_log_(params.net_log), | |
| 300 backend_factory_(backend_factory), | |
| 301 building_backend_(false), | |
| 302 bypass_lock_for_test_(false), | |
| 303 fail_conditionalization_for_test_(false), | |
| 304 mode_(NORMAL), | |
| 305 network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))), | |
| 306 clock_(new base::DefaultClock()), | |
| 307 weak_factory_(this) { | |
| 308 SetupQuicServerInfoFactory(network_layer_->GetSession()); | |
| 309 } | |
| 310 | |
| 311 | |
| 312 // This call doesn't change the shared |session|'s QuicServerInfoFactory because | 297 // This call doesn't change the shared |session|'s QuicServerInfoFactory because |
| 313 // |session| is shared. | 298 // |session| is shared. |
| 314 HttpCache::HttpCache(HttpNetworkSession* session, | 299 HttpCache::HttpCache(HttpNetworkSession* session, |
| 315 BackendFactory* backend_factory) | 300 BackendFactory* backend_factory, |
| 316 : net_log_(session->net_log()), | 301 bool set_up_quic_server_info) |
| 317 backend_factory_(backend_factory), | 302 : HttpCache(new HttpNetworkLayer(session), |
| 318 building_backend_(false), | 303 session->net_log(), |
| 319 bypass_lock_for_test_(false), | 304 backend_factory, |
| 320 fail_conditionalization_for_test_(false), | 305 set_up_quic_server_info) {} |
| 321 mode_(NORMAL), | |
| 322 network_layer_(new HttpNetworkLayer(session)), | |
| 323 clock_(new base::DefaultClock()), | |
| 324 weak_factory_(this) { | |
| 325 } | |
| 326 | 306 |
| 327 HttpCache::HttpCache(HttpTransactionFactory* network_layer, | 307 HttpCache::HttpCache(HttpTransactionFactory* network_layer, |
| 328 NetLog* net_log, | 308 NetLog* net_log, |
| 329 BackendFactory* backend_factory) | 309 BackendFactory* backend_factory, |
| 310 bool set_up_quic_server_info) |
| 330 : net_log_(net_log), | 311 : net_log_(net_log), |
| 331 backend_factory_(backend_factory), | 312 backend_factory_(backend_factory), |
| 332 building_backend_(false), | 313 building_backend_(false), |
| 333 bypass_lock_for_test_(false), | 314 bypass_lock_for_test_(false), |
| 334 fail_conditionalization_for_test_(false), | 315 fail_conditionalization_for_test_(false), |
| 335 mode_(NORMAL), | 316 mode_(NORMAL), |
| 336 network_layer_(network_layer), | 317 network_layer_(network_layer), |
| 337 clock_(new base::DefaultClock()), | 318 clock_(new base::DefaultClock()), |
| 338 weak_factory_(this) { | 319 weak_factory_(this) { |
| 339 SetupQuicServerInfoFactory(network_layer_->GetSession()); | 320 if (set_up_quic_server_info) |
| 321 SetupQuicServerInfoFactory(network_layer_->GetSession()); |
| 340 } | 322 } |
| 341 | 323 |
| 342 HttpCache::~HttpCache() { | 324 HttpCache::~HttpCache() { |
| 343 // Transactions should see an invalid cache after this point; otherwise they | 325 // Transactions should see an invalid cache after this point; otherwise they |
| 344 // could see an inconsistent object (half destroyed). | 326 // could see an inconsistent object (half destroyed). |
| 345 weak_factory_.InvalidateWeakPtrs(); | 327 weak_factory_.InvalidateWeakPtrs(); |
| 346 | 328 |
| 347 // If we have any active entries remaining, then we need to deactivate them. | 329 // If we have any active entries remaining, then we need to deactivate them. |
| 348 // We may have some pending calls to OnProcessPendingQueue, but since those | 330 // We may have some pending calls to OnProcessPendingQueue, but since those |
| 349 // won't run (due to our destruction), we can simply ignore the corresponding | 331 // won't run (due to our destruction), we can simply ignore the corresponding |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 building_backend_ = false; | 1163 building_backend_ = false; |
| 1182 DeletePendingOp(pending_op); | 1164 DeletePendingOp(pending_op); |
| 1183 } | 1165 } |
| 1184 | 1166 |
| 1185 // The cache may be gone when we return from the callback. | 1167 // The cache may be gone when we return from the callback. |
| 1186 if (!item->DoCallback(result, disk_cache_.get())) | 1168 if (!item->DoCallback(result, disk_cache_.get())) |
| 1187 item->NotifyTransaction(result, NULL); | 1169 item->NotifyTransaction(result, NULL); |
| 1188 } | 1170 } |
| 1189 | 1171 |
| 1190 } // namespace net | 1172 } // namespace net |
| OLD | NEW |