| 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. |
| 11 // | 11 // |
| 12 // See HttpTransactionFactory and HttpTransaction for more details. | 12 // See HttpTransactionFactory and HttpTransaction for more details. |
| 13 | 13 |
| 14 #ifndef NET_HTTP_HTTP_CACHE_H_ | 14 #ifndef NET_HTTP_HTTP_CACHE_H_ |
| 15 #define NET_HTTP_HTTP_CACHE_H_ | 15 #define NET_HTTP_HTTP_CACHE_H_ |
| 16 | 16 |
| 17 #include <list> | 17 #include <list> |
| 18 #include <map> | 18 #include <map> |
| 19 #include <memory> | 19 #include <memory> |
| 20 #include <string> | 20 #include <string> |
| 21 #include <unordered_map> | 21 #include <unordered_map> |
| 22 | 22 |
| 23 #include "base/files/file_path.h" | 23 #include "base/files/file_path.h" |
| 24 #include "base/macros.h" | 24 #include "base/macros.h" |
| 25 #include "base/memory/weak_ptr.h" | 25 #include "base/memory/weak_ptr.h" |
| 26 #include "base/threading/non_thread_safe.h" | 26 #include "base/threading/thread_checker.h" |
| 27 #include "base/time/clock.h" | 27 #include "base/time/clock.h" |
| 28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 29 #include "net/base/cache_type.h" | 29 #include "net/base/cache_type.h" |
| 30 #include "net/base/completion_callback.h" | 30 #include "net/base/completion_callback.h" |
| 31 #include "net/base/load_states.h" | 31 #include "net/base/load_states.h" |
| 32 #include "net/base/net_export.h" | 32 #include "net/base/net_export.h" |
| 33 #include "net/base/request_priority.h" | 33 #include "net/base/request_priority.h" |
| 34 #include "net/http/http_network_session.h" | 34 #include "net/http/http_network_session.h" |
| 35 #include "net/http/http_transaction_factory.h" | 35 #include "net/http/http_transaction_factory.h" |
| 36 | 36 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 namespace net { | 51 namespace net { |
| 52 | 52 |
| 53 class HttpNetworkSession; | 53 class HttpNetworkSession; |
| 54 class HttpResponseInfo; | 54 class HttpResponseInfo; |
| 55 class IOBuffer; | 55 class IOBuffer; |
| 56 class NetLog; | 56 class NetLog; |
| 57 class ViewCacheHelper; | 57 class ViewCacheHelper; |
| 58 struct HttpRequestInfo; | 58 struct HttpRequestInfo; |
| 59 | 59 |
| 60 class NET_EXPORT HttpCache : public HttpTransactionFactory, | 60 class NET_EXPORT HttpCache : public HttpTransactionFactory { |
| 61 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
| 62 public: | 61 public: |
| 63 // The cache mode of operation. | 62 // The cache mode of operation. |
| 64 enum Mode { | 63 enum Mode { |
| 65 // Normal mode just behaves like a standard web cache. | 64 // Normal mode just behaves like a standard web cache. |
| 66 NORMAL = 0, | 65 NORMAL = 0, |
| 67 // Disables reads and writes from the cache. | 66 // Disables reads and writes from the cache. |
| 68 // Equivalent to setting LOAD_DISABLE_CACHE on every request. | 67 // Equivalent to setting LOAD_DISABLE_CACHE on every request. |
| 69 DISABLE | 68 DISABLE |
| 70 }; | 69 }; |
| 71 | 70 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 ActiveEntriesSet doomed_entries_; | 426 ActiveEntriesSet doomed_entries_; |
| 428 | 427 |
| 429 // The set of entries "under construction". | 428 // The set of entries "under construction". |
| 430 PendingOpsMap pending_ops_; | 429 PendingOpsMap pending_ops_; |
| 431 | 430 |
| 432 std::unique_ptr<PlaybackCacheMap> playback_cache_map_; | 431 std::unique_ptr<PlaybackCacheMap> playback_cache_map_; |
| 433 | 432 |
| 434 // A clock that can be swapped out for testing. | 433 // A clock that can be swapped out for testing. |
| 435 std::unique_ptr<base::Clock> clock_; | 434 std::unique_ptr<base::Clock> clock_; |
| 436 | 435 |
| 436 THREAD_CHECKER(thread_checker_); |
| 437 |
| 437 base::WeakPtrFactory<HttpCache> weak_factory_; | 438 base::WeakPtrFactory<HttpCache> weak_factory_; |
| 438 | 439 |
| 439 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 440 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 440 }; | 441 }; |
| 441 | 442 |
| 442 } // namespace net | 443 } // namespace net |
| 443 | 444 |
| 444 #endif // NET_HTTP_HTTP_CACHE_H_ | 445 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |