| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // immediately, but they will not be reusable. This is for debugging. | 193 // immediately, but they will not be reusable. This is for debugging. |
| 194 void CloseAllConnections(); | 194 void CloseAllConnections(); |
| 195 | 195 |
| 196 // Close all idle connections. Will close all sockets not in active use. | 196 // Close all idle connections. Will close all sockets not in active use. |
| 197 void CloseIdleConnections(); | 197 void CloseIdleConnections(); |
| 198 | 198 |
| 199 // Called whenever an external cache in the system reuses the resource | 199 // Called whenever an external cache in the system reuses the resource |
| 200 // referred to by |url| and |http_method|. | 200 // referred to by |url| and |http_method|. |
| 201 void OnExternalCacheHit(const GURL& url, const std::string& http_method); | 201 void OnExternalCacheHit(const GURL& url, const std::string& http_method); |
| 202 | 202 |
| 203 // Causes all transactions created after this point to effectively bypass | |
| 204 // the cache lock whenever there is lock contention. | |
| 205 void BypassLockForTest() { | |
| 206 bypass_lock_for_test_ = true; | |
| 207 } | |
| 208 | |
| 209 // Causes all transactions created after this point to generate a failure | 203 // Causes all transactions created after this point to generate a failure |
| 210 // when attempting to conditionalize a network request. | 204 // when attempting to conditionalize a network request. |
| 211 void FailConditionalizationForTest() { | 205 void FailConditionalizationForTest() { |
| 212 fail_conditionalization_for_test_ = true; | 206 fail_conditionalization_for_test_ = true; |
| 213 } | 207 } |
| 214 | 208 |
| 215 // HttpTransactionFactory implementation: | 209 // HttpTransactionFactory implementation: |
| 216 int CreateTransaction(RequestPriority priority, | 210 int CreateTransaction(RequestPriority priority, |
| 217 scoped_ptr<HttpTransaction>* trans) override; | 211 scoped_ptr<HttpTransaction>* trans) override; |
| 218 HttpCache* GetCache() override; | 212 HttpCache* GetCache() override; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // Processes the backend creation notification. | 397 // Processes the backend creation notification. |
| 404 void OnBackendCreated(int result, PendingOp* pending_op); | 398 void OnBackendCreated(int result, PendingOp* pending_op); |
| 405 | 399 |
| 406 // Variables ---------------------------------------------------------------- | 400 // Variables ---------------------------------------------------------------- |
| 407 | 401 |
| 408 NetLog* net_log_; | 402 NetLog* net_log_; |
| 409 | 403 |
| 410 // Used when lazily constructing the disk_cache_. | 404 // Used when lazily constructing the disk_cache_. |
| 411 scoped_ptr<BackendFactory> backend_factory_; | 405 scoped_ptr<BackendFactory> backend_factory_; |
| 412 bool building_backend_; | 406 bool building_backend_; |
| 413 bool bypass_lock_for_test_; | |
| 414 bool fail_conditionalization_for_test_; | 407 bool fail_conditionalization_for_test_; |
| 415 | 408 |
| 416 Mode mode_; | 409 Mode mode_; |
| 417 | 410 |
| 418 scoped_ptr<HttpTransactionFactory> network_layer_; | 411 scoped_ptr<HttpTransactionFactory> network_layer_; |
| 419 | 412 |
| 420 scoped_ptr<disk_cache::Backend> disk_cache_; | 413 scoped_ptr<disk_cache::Backend> disk_cache_; |
| 421 | 414 |
| 422 scoped_ptr<DiskBasedCertCache> cert_cache_; | 415 scoped_ptr<DiskBasedCertCache> cert_cache_; |
| 423 | 416 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 436 scoped_ptr<base::Clock> clock_; | 429 scoped_ptr<base::Clock> clock_; |
| 437 | 430 |
| 438 base::WeakPtrFactory<HttpCache> weak_factory_; | 431 base::WeakPtrFactory<HttpCache> weak_factory_; |
| 439 | 432 |
| 440 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 433 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 441 }; | 434 }; |
| 442 | 435 |
| 443 } // namespace net | 436 } // namespace net |
| 444 | 437 |
| 445 #endif // NET_HTTP_HTTP_CACHE_H_ | 438 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |