Chromium Code Reviews| 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 // This file declares a HttpTransactionFactory implementation that can be | 5 // This file declares a HttpTransactionFactory implementation that can be |
| 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The | 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The |
| 7 // caching logic follows RFC 7234 (any exceptions are called out in the code). | 7 // caching logic follows RFC 7234 (any exceptions are called out in the code). |
| 8 // | 8 // |
| 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for | 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for |
| 10 // the cache storage. | 10 // the cache storage. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 void CloseIdleConnections(); | 188 void CloseIdleConnections(); |
| 189 | 189 |
| 190 // Called whenever an external cache in the system reuses the resource | 190 // Called whenever an external cache in the system reuses the resource |
| 191 // referred to by |url| and |http_method|. | 191 // referred to by |url| and |http_method|. |
| 192 void OnExternalCacheHit(const GURL& url, const std::string& http_method); | 192 void OnExternalCacheHit(const GURL& url, const std::string& http_method); |
| 193 | 193 |
| 194 // Causes all transactions created after this point to simulate lock timeout | 194 // Causes all transactions created after this point to simulate lock timeout |
| 195 // and effectively bypass the cache lock whenever there is lock contention. | 195 // and effectively bypass the cache lock whenever there is lock contention. |
| 196 void SimulateCacheLockTimeout() { bypass_lock_for_test_ = true; } | 196 void SimulateCacheLockTimeout() { bypass_lock_for_test_ = true; } |
| 197 | 197 |
| 198 // Causes all transactions created after this point to simulate lock timeout | |
| 199 // and effectively bypass the cache lock whenever there is lock contention | |
| 200 // after the transaction has completed its headers phase. | |
| 201 void SimulateCacheLockTimeoutAfterHeaders() { | |
|
Randy Smith (Not in Mondays)
2017/06/23 17:38:01
nit: Can this method have a ForTesting suffix? I
shivanisha
2017/06/23 19:16:08
Done for both this and the existing SimulateCacheL
| |
| 202 bypass_lock_after_headers_for_test_ = true; | |
| 203 } | |
| 204 | |
| 198 // Causes all transactions created after this point to generate a failure | 205 // Causes all transactions created after this point to generate a failure |
| 199 // when attempting to conditionalize a network request. | 206 // when attempting to conditionalize a network request. |
| 200 void FailConditionalizationForTest() { | 207 void FailConditionalizationForTest() { |
| 201 fail_conditionalization_for_test_ = true; | 208 fail_conditionalization_for_test_ = true; |
| 202 } | 209 } |
| 203 | 210 |
| 204 // HttpTransactionFactory implementation: | 211 // HttpTransactionFactory implementation: |
| 205 int CreateTransaction(RequestPriority priority, | 212 int CreateTransaction(RequestPriority priority, |
| 206 std::unique_ptr<HttpTransaction>* trans) override; | 213 std::unique_ptr<HttpTransaction>* trans) override; |
| 207 HttpCache* GetCache() override; | 214 HttpCache* GetCache() override; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 void OnBackendCreated(int result, PendingOp* pending_op); | 513 void OnBackendCreated(int result, PendingOp* pending_op); |
| 507 | 514 |
| 508 // Variables ---------------------------------------------------------------- | 515 // Variables ---------------------------------------------------------------- |
| 509 | 516 |
| 510 NetLog* net_log_; | 517 NetLog* net_log_; |
| 511 | 518 |
| 512 // Used when lazily constructing the disk_cache_. | 519 // Used when lazily constructing the disk_cache_. |
| 513 std::unique_ptr<BackendFactory> backend_factory_; | 520 std::unique_ptr<BackendFactory> backend_factory_; |
| 514 bool building_backend_; | 521 bool building_backend_; |
| 515 bool bypass_lock_for_test_; | 522 bool bypass_lock_for_test_; |
| 523 bool bypass_lock_after_headers_for_test_; | |
| 516 bool fail_conditionalization_for_test_; | 524 bool fail_conditionalization_for_test_; |
| 517 | 525 |
| 518 Mode mode_; | 526 Mode mode_; |
| 519 | 527 |
| 520 std::unique_ptr<HttpTransactionFactory> network_layer_; | 528 std::unique_ptr<HttpTransactionFactory> network_layer_; |
| 521 | 529 |
| 522 std::unique_ptr<disk_cache::Backend> disk_cache_; | 530 std::unique_ptr<disk_cache::Backend> disk_cache_; |
| 523 | 531 |
| 524 // The set of active entries indexed by cache key. | 532 // The set of active entries indexed by cache key. |
| 525 ActiveEntriesMap active_entries_; | 533 ActiveEntriesMap active_entries_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 538 THREAD_CHECKER(thread_checker_); | 546 THREAD_CHECKER(thread_checker_); |
| 539 | 547 |
| 540 base::WeakPtrFactory<HttpCache> weak_factory_; | 548 base::WeakPtrFactory<HttpCache> weak_factory_; |
| 541 | 549 |
| 542 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 550 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 543 }; | 551 }; |
| 544 | 552 |
| 545 } // namespace net | 553 } // namespace net |
| 546 | 554 |
| 547 #endif // NET_HTTP_HTTP_CACHE_H_ | 555 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |