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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 std::move(backend_factory), | 305 std::move(backend_factory), |
306 is_main_cache) {} | 306 is_main_cache) {} |
307 | 307 |
308 HttpCache::HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer, | 308 HttpCache::HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer, |
309 std::unique_ptr<BackendFactory> backend_factory, | 309 std::unique_ptr<BackendFactory> backend_factory, |
310 bool is_main_cache) | 310 bool is_main_cache) |
311 : net_log_(nullptr), | 311 : net_log_(nullptr), |
312 backend_factory_(std::move(backend_factory)), | 312 backend_factory_(std::move(backend_factory)), |
313 building_backend_(false), | 313 building_backend_(false), |
314 bypass_lock_for_test_(false), | 314 bypass_lock_for_test_(false), |
| 315 bypass_lock_after_headers_for_test_(false), |
315 fail_conditionalization_for_test_(false), | 316 fail_conditionalization_for_test_(false), |
316 mode_(NORMAL), | 317 mode_(NORMAL), |
317 network_layer_(std::move(network_layer)), | 318 network_layer_(std::move(network_layer)), |
318 clock_(new base::DefaultClock()), | 319 clock_(new base::DefaultClock()), |
319 weak_factory_(this) { | 320 weak_factory_(this) { |
320 HttpNetworkSession* session = network_layer_->GetSession(); | 321 HttpNetworkSession* session = network_layer_->GetSession(); |
321 // Session may be NULL in unittests. | 322 // Session may be NULL in unittests. |
322 // TODO(mmenke): Seems like tests could be changed to provide a session, | 323 // TODO(mmenke): Seems like tests could be changed to provide a session, |
323 // rather than having logic only used in unit tests here. | 324 // rather than having logic only used in unit tests here. |
324 if (!session) | 325 if (!session) |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // Do lazy initialization of disk cache if needed. | 459 // Do lazy initialization of disk cache if needed. |
459 if (!disk_cache_.get()) { | 460 if (!disk_cache_.get()) { |
460 // We don't care about the result. | 461 // We don't care about the result. |
461 CreateBackend(NULL, CompletionCallback()); | 462 CreateBackend(NULL, CompletionCallback()); |
462 } | 463 } |
463 | 464 |
464 HttpCache::Transaction* transaction = | 465 HttpCache::Transaction* transaction = |
465 new HttpCache::Transaction(priority, this); | 466 new HttpCache::Transaction(priority, this); |
466 if (bypass_lock_for_test_) | 467 if (bypass_lock_for_test_) |
467 transaction->BypassLockForTest(); | 468 transaction->BypassLockForTest(); |
| 469 if (bypass_lock_after_headers_for_test_) |
| 470 transaction->BypassLockAfterHeadersForTest(); |
468 if (fail_conditionalization_for_test_) | 471 if (fail_conditionalization_for_test_) |
469 transaction->FailConditionalizationForTest(); | 472 transaction->FailConditionalizationForTest(); |
470 | 473 |
471 trans->reset(transaction); | 474 trans->reset(transaction); |
472 return OK; | 475 return OK; |
473 } | 476 } |
474 | 477 |
475 HttpCache* HttpCache::GetCache() { | 478 HttpCache* HttpCache::GetCache() { |
476 return this; | 479 return this; |
477 } | 480 } |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 building_backend_ = false; | 1366 building_backend_ = false; |
1364 DeletePendingOp(pending_op); | 1367 DeletePendingOp(pending_op); |
1365 } | 1368 } |
1366 | 1369 |
1367 // The cache may be gone when we return from the callback. | 1370 // The cache may be gone when we return from the callback. |
1368 if (!item->DoCallback(result, disk_cache_.get())) | 1371 if (!item->DoCallback(result, disk_cache_.get())) |
1369 item->NotifyTransaction(result, NULL); | 1372 item->NotifyTransaction(result, NULL); |
1370 } | 1373 } |
1371 | 1374 |
1372 } // namespace net | 1375 } // namespace net |
OLD | NEW |