| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 DefaultBackend(CacheType type, const FilePath& path, int max_bytes, | 102 DefaultBackend(CacheType type, const FilePath& path, int max_bytes, |
| 103 base::MessageLoopProxy* thread); | 103 base::MessageLoopProxy* thread); |
| 104 virtual ~DefaultBackend(); | 104 virtual ~DefaultBackend(); |
| 105 | 105 |
| 106 // Returns a factory for an in-memory cache. | 106 // Returns a factory for an in-memory cache. |
| 107 static BackendFactory* InMemory(int max_bytes); | 107 static BackendFactory* InMemory(int max_bytes); |
| 108 | 108 |
| 109 // BackendFactory implementation. | 109 // BackendFactory implementation. |
| 110 virtual int CreateBackend(NetLog* net_log, | 110 virtual int CreateBackend(NetLog* net_log, |
| 111 disk_cache::Backend** backend, | 111 disk_cache::Backend** backend, |
| 112 OldCompletionCallback* callback); | 112 OldCompletionCallback* callback) OVERRIDE; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 CacheType type_; | 115 CacheType type_; |
| 116 const FilePath path_; | 116 const FilePath path_; |
| 117 int max_bytes_; | 117 int max_bytes_; |
| 118 scoped_refptr<base::MessageLoopProxy> thread_; | 118 scoped_refptr<base::MessageLoopProxy> thread_; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 121 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| 122 // The HttpCache takes ownership of the |backend_factory|. | 122 // The HttpCache takes ownership of the |backend_factory|. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 void CloseAllConnections(); | 184 void CloseAllConnections(); |
| 185 | 185 |
| 186 // Close all idle connections. Will close all sockets not in active use. | 186 // Close all idle connections. Will close all sockets not in active use. |
| 187 void CloseIdleConnections(); | 187 void CloseIdleConnections(); |
| 188 | 188 |
| 189 // Called whenever an external cache in the system reuses the resource | 189 // Called whenever an external cache in the system reuses the resource |
| 190 // referred to by |url| and |http_method|. | 190 // referred to by |url| and |http_method|. |
| 191 void OnExternalCacheHit(const GURL& url, const std::string& http_method); | 191 void OnExternalCacheHit(const GURL& url, const std::string& http_method); |
| 192 | 192 |
| 193 // HttpTransactionFactory implementation: | 193 // HttpTransactionFactory implementation: |
| 194 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); | 194 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans) OVERRIDE; |
| 195 virtual HttpCache* GetCache(); | 195 virtual HttpCache* GetCache() OVERRIDE; |
| 196 virtual HttpNetworkSession* GetSession(); | 196 virtual HttpNetworkSession* GetSession() OVERRIDE; |
| 197 | 197 |
| 198 protected: | 198 protected: |
| 199 // Disk cache entry data indices. | 199 // Disk cache entry data indices. |
| 200 enum { | 200 enum { |
| 201 kResponseInfoIndex = 0, | 201 kResponseInfoIndex = 0, |
| 202 kResponseContentIndex, | 202 kResponseContentIndex, |
| 203 kMetadataIndex, | 203 kMetadataIndex, |
| 204 | 204 |
| 205 // Must remain at the end of the enum. | 205 // Must remain at the end of the enum. |
| 206 kNumCacheEntryDataIndices | 206 kNumCacheEntryDataIndices |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 PendingOpsMap pending_ops_; | 381 PendingOpsMap pending_ops_; |
| 382 | 382 |
| 383 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 383 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 384 | 384 |
| 385 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 385 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 386 }; | 386 }; |
| 387 | 387 |
| 388 } // namespace net | 388 } // namespace net |
| 389 | 389 |
| 390 #endif // NET_HTTP_HTTP_CACHE_H_ | 390 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |