Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Side by Side Diff: net/http/http_cache.h

Issue 10909136: Http Cache: Add code for simulating an infinite HTTP cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_cache.cc » ('j') | net/http/http_cache_transaction.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
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_transaction_factory.h" 33 #include "net/http/http_transaction_factory.h"
34 #include "net/http/infinite_cache.h"
34 35
35 class GURL; 36 class GURL;
36 37
37 namespace disk_cache { 38 namespace disk_cache {
38 class Backend; 39 class Backend;
39 class Entry; 40 class Entry;
40 } 41 }
41 42
42 namespace net { 43 namespace net {
43 44
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // immediately, but they will not be reusable. This is for debugging. 184 // immediately, but they will not be reusable. This is for debugging.
184 void CloseAllConnections(); 185 void CloseAllConnections();
185 186
186 // Close all idle connections. Will close all sockets not in active use. 187 // Close all idle connections. Will close all sockets not in active use.
187 void CloseIdleConnections(); 188 void CloseIdleConnections();
188 189
189 // Called whenever an external cache in the system reuses the resource 190 // Called whenever an external cache in the system reuses the resource
190 // referred to by |url| and |http_method|. 191 // referred to by |url| and |http_method|.
191 void OnExternalCacheHit(const GURL& url, const std::string& http_method); 192 void OnExternalCacheHit(const GURL& url, const std::string& http_method);
192 193
194 // Initializes the Infinite Cache, if selected by the field trial.
195 void InitializeInfiniteCache(const FilePath& path);
196
193 // HttpTransactionFactory implementation: 197 // HttpTransactionFactory implementation:
194 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans, 198 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans,
195 HttpTransactionDelegate* delegate) OVERRIDE; 199 HttpTransactionDelegate* delegate) OVERRIDE;
196 virtual HttpCache* GetCache() OVERRIDE; 200 virtual HttpCache* GetCache() OVERRIDE;
197 virtual HttpNetworkSession* GetSession() OVERRIDE; 201 virtual HttpNetworkSession* GetSession() OVERRIDE;
198 202
199 protected: 203 protected:
200 // Disk cache entry data indices. 204 // Disk cache entry data indices.
201 enum { 205 enum {
202 kResponseInfoIndex = 0, 206 kResponseInfoIndex = 0,
203 kResponseContentIndex, 207 kResponseContentIndex,
204 kMetadataIndex, 208 kMetadataIndex,
205 209
206 // Must remain at the end of the enum. 210 // Must remain at the end of the enum.
207 kNumCacheEntryDataIndices 211 kNumCacheEntryDataIndices
208 }; 212 };
209 friend class ViewCacheHelper; 213 friend class ViewCacheHelper;
210 214
211 private: 215 private:
212 // Types -------------------------------------------------------------------- 216 // Types --------------------------------------------------------------------
213 217
214 class MetadataWriter; 218 class MetadataWriter;
215 class Transaction; 219 class Transaction;
216 class WorkItem; 220 class WorkItem;
217 friend class Transaction; 221 friend class Transaction;
222 friend class InfiniteCache;
218 struct PendingOp; // Info for an entry under construction. 223 struct PendingOp; // Info for an entry under construction.
219 224
220 typedef std::list<Transaction*> TransactionList; 225 typedef std::list<Transaction*> TransactionList;
221 typedef std::list<WorkItem*> WorkItemList; 226 typedef std::list<WorkItem*> WorkItemList;
222 227
223 struct ActiveEntry { 228 struct ActiveEntry {
224 explicit ActiveEntry(disk_cache::Entry* entry); 229 explicit ActiveEntry(disk_cache::Entry* entry);
225 ~ActiveEntry(); 230 ~ActiveEntry();
226 231
227 disk_cache::Entry* disk_entry; 232 disk_cache::Entry* disk_entry;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ActiveEntriesMap active_entries_; 391 ActiveEntriesMap active_entries_;
387 392
388 // The set of doomed entries. 393 // The set of doomed entries.
389 ActiveEntriesSet doomed_entries_; 394 ActiveEntriesSet doomed_entries_;
390 395
391 // The set of entries "under construction". 396 // The set of entries "under construction".
392 PendingOpsMap pending_ops_; 397 PendingOpsMap pending_ops_;
393 398
394 scoped_ptr<PlaybackCacheMap> playback_cache_map_; 399 scoped_ptr<PlaybackCacheMap> playback_cache_map_;
395 400
401 InfiniteCache infinite_cache_;
402
396 DISALLOW_COPY_AND_ASSIGN(HttpCache); 403 DISALLOW_COPY_AND_ASSIGN(HttpCache);
397 }; 404 };
398 405
399 } // namespace net 406 } // namespace net
400 407
401 #endif // NET_HTTP_HTTP_CACHE_H_ 408 #endif // NET_HTTP_HTTP_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_cache.cc » ('j') | net/http/http_cache_transaction.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698