| 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 14 matching lines...) Expand all  Loading... | 
| 25 #include "base/memory/weak_ptr.h" | 25 #include "base/memory/weak_ptr.h" | 
| 26 #include "base/message_loop_proxy.h" | 26 #include "base/message_loop_proxy.h" | 
| 27 #include "base/time.h" | 27 #include "base/time.h" | 
| 28 #include "base/threading/non_thread_safe.h" | 28 #include "base/threading/non_thread_safe.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/http/http_network_session.h" | 33 #include "net/http/http_network_session.h" | 
| 34 #include "net/http/http_transaction_factory.h" | 34 #include "net/http/http_transaction_factory.h" | 
|  | 35 #include "net/http/infinite_cache.h" | 
| 35 | 36 | 
| 36 class GURL; | 37 class GURL; | 
| 37 | 38 | 
| 38 namespace disk_cache { | 39 namespace disk_cache { | 
| 39 class Backend; | 40 class Backend; | 
| 40 class Entry; | 41 class Entry; | 
| 41 } | 42 } | 
| 42 | 43 | 
| 43 namespace net { | 44 namespace net { | 
| 44 | 45 | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 176   // Close all idle connections. Will close all sockets not in active use. | 177   // Close all idle connections. Will close all sockets not in active use. | 
| 177   void CloseIdleConnections(); | 178   void CloseIdleConnections(); | 
| 178 | 179 | 
| 179   // Called whenever an external cache in the system reuses the resource | 180   // Called whenever an external cache in the system reuses the resource | 
| 180   // referred to by |url| and |http_method|. | 181   // referred to by |url| and |http_method|. | 
| 181   void OnExternalCacheHit(const GURL& url, const std::string& http_method); | 182   void OnExternalCacheHit(const GURL& url, const std::string& http_method); | 
| 182 | 183 | 
| 183   // Initializes the Infinite Cache, if selected by the field trial. | 184   // Initializes the Infinite Cache, if selected by the field trial. | 
| 184   void InitializeInfiniteCache(const FilePath& path); | 185   void InitializeInfiniteCache(const FilePath& path); | 
| 185 | 186 | 
|  | 187   // Returns a pointer to the Infinite Cache. | 
|  | 188   InfiniteCache* infinite_cache() { return &infinite_cache_; } | 
|  | 189 | 
| 186   // HttpTransactionFactory implementation: | 190   // HttpTransactionFactory implementation: | 
| 187   virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans, | 191   virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans, | 
| 188                                 HttpTransactionDelegate* delegate) OVERRIDE; | 192                                 HttpTransactionDelegate* delegate) OVERRIDE; | 
| 189   virtual HttpCache* GetCache() OVERRIDE; | 193   virtual HttpCache* GetCache() OVERRIDE; | 
| 190   virtual HttpNetworkSession* GetSession() OVERRIDE; | 194   virtual HttpNetworkSession* GetSession() OVERRIDE; | 
| 191 | 195 | 
| 192  protected: | 196  protected: | 
| 193   // Disk cache entry data indices. | 197   // Disk cache entry data indices. | 
| 194   enum { | 198   enum { | 
| 195     kResponseInfoIndex = 0, | 199     kResponseInfoIndex = 0, | 
| 196     kResponseContentIndex, | 200     kResponseContentIndex, | 
| 197     kMetadataIndex, | 201     kMetadataIndex, | 
| 198 | 202 | 
| 199     // Must remain at the end of the enum. | 203     // Must remain at the end of the enum. | 
| 200     kNumCacheEntryDataIndices | 204     kNumCacheEntryDataIndices | 
| 201   }; | 205   }; | 
| 202   friend class ViewCacheHelper; | 206   friend class ViewCacheHelper; | 
| 203 | 207 | 
| 204  private: | 208  private: | 
| 205   // Types -------------------------------------------------------------------- | 209   // Types -------------------------------------------------------------------- | 
| 206 | 210 | 
| 207   class MetadataWriter; | 211   class MetadataWriter; | 
| 208   class Transaction; | 212   class Transaction; | 
| 209   class WorkItem; | 213   class WorkItem; | 
| 210   friend class Transaction; | 214   friend class Transaction; | 
|  | 215   friend class InfiniteCache; | 
| 211   struct PendingOp;  // Info for an entry under construction. | 216   struct PendingOp;  // Info for an entry under construction. | 
| 212 | 217 | 
| 213   typedef std::list<Transaction*> TransactionList; | 218   typedef std::list<Transaction*> TransactionList; | 
| 214   typedef std::list<WorkItem*> WorkItemList; | 219   typedef std::list<WorkItem*> WorkItemList; | 
| 215 | 220 | 
| 216   struct ActiveEntry { | 221   struct ActiveEntry { | 
| 217     explicit ActiveEntry(disk_cache::Entry* entry); | 222     explicit ActiveEntry(disk_cache::Entry* entry); | 
| 218     ~ActiveEntry(); | 223     ~ActiveEntry(); | 
| 219 | 224 | 
| 220     disk_cache::Entry* disk_entry; | 225     disk_cache::Entry* disk_entry; | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 379   ActiveEntriesMap active_entries_; | 384   ActiveEntriesMap active_entries_; | 
| 380 | 385 | 
| 381   // The set of doomed entries. | 386   // The set of doomed entries. | 
| 382   ActiveEntriesSet doomed_entries_; | 387   ActiveEntriesSet doomed_entries_; | 
| 383 | 388 | 
| 384   // The set of entries "under construction". | 389   // The set of entries "under construction". | 
| 385   PendingOpsMap pending_ops_; | 390   PendingOpsMap pending_ops_; | 
| 386 | 391 | 
| 387   scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 392   scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 
| 388 | 393 | 
|  | 394   InfiniteCache infinite_cache_; | 
|  | 395 | 
| 389   DISALLOW_COPY_AND_ASSIGN(HttpCache); | 396   DISALLOW_COPY_AND_ASSIGN(HttpCache); | 
| 390 }; | 397 }; | 
| 391 | 398 | 
| 392 }  // namespace net | 399 }  // namespace net | 
| 393 | 400 | 
| 394 #endif  // NET_HTTP_HTTP_CACHE_H_ | 401 #endif  // NET_HTTP_HTTP_CACHE_H_ | 
| OLD | NEW | 
|---|