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 2616 (any exceptions are called out in the code). | 7 // caching logic follows RFC 2616 (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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 // Initializes the Infinite Cache, if selected by the field trial. | 196 // Initializes the Infinite Cache, if selected by the field trial. |
197 void InitializeInfiniteCache(const base::FilePath& path); | 197 void InitializeInfiniteCache(const base::FilePath& path); |
198 | 198 |
199 // Causes all transactions created after this point to effectively bypass | 199 // Causes all transactions created after this point to effectively bypass |
200 // the cache lock whenever there is lock contention. | 200 // the cache lock whenever there is lock contention. |
201 void BypassLockForTest() { | 201 void BypassLockForTest() { |
202 bypass_lock_for_test_ = true; | 202 bypass_lock_for_test_ = true; |
203 } | 203 } |
204 | 204 |
| 205 // Causes all transactions created after this point to generate a failure |
| 206 // when attempting to conditionalize a network request. |
| 207 void FailConditionalizationForTest() { |
| 208 fail_conditionalization_for_test_ = true; |
| 209 } |
| 210 |
205 bool use_stale_while_revalidate() const { | 211 bool use_stale_while_revalidate() const { |
206 return use_stale_while_revalidate_; | 212 return use_stale_while_revalidate_; |
207 } | 213 } |
208 | 214 |
209 // Enable stale_while_revalidate functionality for testing purposes. | 215 // Enable stale_while_revalidate functionality for testing purposes. |
210 void set_use_stale_while_revalidate_for_testing( | 216 void set_use_stale_while_revalidate_for_testing( |
211 bool use_stale_while_revalidate) { | 217 bool use_stale_while_revalidate) { |
212 use_stale_while_revalidate_ = use_stale_while_revalidate; | 218 use_stale_while_revalidate_ = use_stale_while_revalidate; |
213 } | 219 } |
214 | 220 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 void OnBackendCreated(int result, PendingOp* pending_op); | 425 void OnBackendCreated(int result, PendingOp* pending_op); |
420 | 426 |
421 // Variables ---------------------------------------------------------------- | 427 // Variables ---------------------------------------------------------------- |
422 | 428 |
423 NetLog* net_log_; | 429 NetLog* net_log_; |
424 | 430 |
425 // Used when lazily constructing the disk_cache_. | 431 // Used when lazily constructing the disk_cache_. |
426 scoped_ptr<BackendFactory> backend_factory_; | 432 scoped_ptr<BackendFactory> backend_factory_; |
427 bool building_backend_; | 433 bool building_backend_; |
428 bool bypass_lock_for_test_; | 434 bool bypass_lock_for_test_; |
| 435 bool fail_conditionalization_for_test_; |
429 | 436 |
430 // true if the implementation of Cache-Control: stale-while-revalidate | 437 // true if the implementation of Cache-Control: stale-while-revalidate |
431 // directive is enabled (either via command-line flag or experiment). | 438 // directive is enabled (either via command-line flag or experiment). |
432 bool use_stale_while_revalidate_; | 439 bool use_stale_while_revalidate_; |
433 | 440 |
434 Mode mode_; | 441 Mode mode_; |
435 | 442 |
436 scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; | 443 scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; |
437 | 444 |
438 scoped_ptr<HttpTransactionFactory> network_layer_; | 445 scoped_ptr<HttpTransactionFactory> network_layer_; |
(...skipping 17 matching lines...) Expand all Loading... |
456 AsyncValidationMap async_validations_; | 463 AsyncValidationMap async_validations_; |
457 | 464 |
458 base::WeakPtrFactory<HttpCache> weak_factory_; | 465 base::WeakPtrFactory<HttpCache> weak_factory_; |
459 | 466 |
460 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 467 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
461 }; | 468 }; |
462 | 469 |
463 } // namespace net | 470 } // namespace net |
464 | 471 |
465 #endif // NET_HTTP_HTTP_CACHE_H_ | 472 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |