| 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 13 matching lines...) Expand all Loading... |
| 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/thread_checker.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/disk_cache/disk_cache.h" |
| 34 #include "net/http/http_network_session.h" | 35 #include "net/http/http_network_session.h" |
| 35 #include "net/http/http_transaction_factory.h" | 36 #include "net/http/http_transaction_factory.h" |
| 36 | 37 |
| 37 class GURL; | 38 class GURL; |
| 38 | 39 |
| 39 namespace base { | 40 namespace base { |
| 40 class SingleThreadTaskRunner; | 41 class SingleThreadTaskRunner; |
| 41 namespace trace_event { | 42 namespace trace_event { |
| 42 class ProcessMemoryDump; | 43 class ProcessMemoryDump; |
| 43 } | 44 } |
| 44 } // namespace base | 45 } // namespace base |
| 45 | 46 |
| 46 namespace disk_cache { | 47 namespace disk_cache { |
| 47 class Backend; | |
| 48 class Entry; | 48 class Entry; |
| 49 } // namespace disk_cache | 49 } // namespace disk_cache |
| 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 public: | 61 public: |
| 62 // The cache mode of operation. | 62 // The cache mode of operation. |
| 63 enum Mode { | 63 enum Mode { |
| 64 // Normal mode just behaves like a standard web cache. | 64 // Normal mode just behaves like a standard web cache. |
| 65 NORMAL = 0, | 65 NORMAL = 0, |
| 66 // Disables reads and writes from the cache. | 66 // Disables reads and writes from the cache. |
| 67 // Equivalent to setting LOAD_DISABLE_CACHE on every request. | 67 // Equivalent to setting LOAD_DISABLE_CACHE on every request. |
| 68 DISABLE | 68 DISABLE |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // ### probably don't need to blow all of 3 bits on this. |
| 72 enum OracleByteHints { |
| 73 OBH_ZERO_LIFETIME = 1, |
| 74 OBH_RESPONSE_CANT_CONDITIONALIZE = 2, |
| 75 OBH_UNUSED_SINCE_PREFETCH = 4 |
| 76 }; |
| 77 |
| 71 // A BackendFactory creates a backend object to be used by the HttpCache. | 78 // A BackendFactory creates a backend object to be used by the HttpCache. |
| 72 class NET_EXPORT BackendFactory { | 79 class NET_EXPORT BackendFactory { |
| 73 public: | 80 public: |
| 74 virtual ~BackendFactory() {} | 81 virtual ~BackendFactory() {} |
| 75 | 82 |
| 76 // The actual method to build the backend. Returns a net error code. If | 83 // The actual method to build the backend. Returns a net error code. If |
| 77 // ERR_IO_PENDING is returned, the |callback| will be notified when the | 84 // ERR_IO_PENDING is returned, the |callback| will be notified when the |
| 78 // operation completes, and |backend| must remain valid until the | 85 // operation completes, and |backend| must remain valid until the |
| 79 // notification arrives. | 86 // notification arrives. |
| 80 // The implementation must not access the factory object after invoking the | 87 // The implementation must not access the factory object after invoking the |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // Returns the PendingOp for the desired |key|. If an entry is not under | 371 // Returns the PendingOp for the desired |key|. If an entry is not under |
| 365 // construction already, a new PendingOp structure is created. | 372 // construction already, a new PendingOp structure is created. |
| 366 PendingOp* GetPendingOp(const std::string& key); | 373 PendingOp* GetPendingOp(const std::string& key); |
| 367 | 374 |
| 368 // Deletes a PendingOp. | 375 // Deletes a PendingOp. |
| 369 void DeletePendingOp(PendingOp* pending_op); | 376 void DeletePendingOp(PendingOp* pending_op); |
| 370 | 377 |
| 371 // Opens the disk cache entry associated with |key|, returning an ActiveEntry | 378 // Opens the disk cache entry associated with |key|, returning an ActiveEntry |
| 372 // in |*entry|. |trans| will be notified via its IO callback if this method | 379 // in |*entry|. |trans| will be notified via its IO callback if this method |
| 373 // returns ERR_IO_PENDING. | 380 // returns ERR_IO_PENDING. |
| 374 int OpenEntry(const std::string& key, ActiveEntry** entry, | 381 int OpenEntry(const std::string& key, |
| 382 ActiveEntry** entry, |
| 375 Transaction* trans); | 383 Transaction* trans); |
| 376 | 384 |
| 377 // Creates the disk cache entry associated with |key|, returning an | 385 // Creates the disk cache entry associated with |key|, returning an |
| 378 // ActiveEntry in |*entry|. |trans| will be notified via its IO callback if | 386 // ActiveEntry in |*entry|. |trans| will be notified via its IO callback if |
| 379 // this method returns ERR_IO_PENDING. | 387 // this method returns ERR_IO_PENDING. |
| 380 int CreateEntry(const std::string& key, ActiveEntry** entry, | 388 int CreateEntry(const std::string& key, ActiveEntry** entry, |
| 381 Transaction* trans); | 389 Transaction* trans); |
| 382 | 390 |
| 383 // Destroys an ActiveEntry (active or doomed). | 391 // Destroys an ActiveEntry (active or doomed). |
| 384 void DestroyEntry(ActiveEntry* entry); | 392 void DestroyEntry(ActiveEntry* entry); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |