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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 | 188 |
189 // Initializes the Infinite Cache, if selected by the field trial. | 189 // Initializes the Infinite Cache, if selected by the field trial. |
190 void InitializeInfiniteCache(const base::FilePath& path); | 190 void InitializeInfiniteCache(const base::FilePath& path); |
191 | 191 |
192 // HttpTransactionFactory implementation: | 192 // HttpTransactionFactory implementation: |
193 virtual int CreateTransaction(RequestPriority priority, | 193 virtual int CreateTransaction(RequestPriority priority, |
194 scoped_ptr<HttpTransaction>* trans) OVERRIDE; | 194 scoped_ptr<HttpTransaction>* trans) OVERRIDE; |
195 virtual HttpCache* GetCache() OVERRIDE; | 195 virtual HttpCache* GetCache() OVERRIDE; |
196 virtual HttpNetworkSession* GetSession() OVERRIDE; | 196 virtual HttpNetworkSession* GetSession() OVERRIDE; |
197 | 197 |
198 // Reset the network layer to allow for browser tests that probe | |
rvargas (doing something else)
2014/01/15 03:26:29
nit: don't mention browser tests
Randy Smith (Not in Mondays)
2014/01/15 19:14:43
Done.
| |
199 // network changes (e.g. host unreachable). The old network layer is | |
200 // returned. Note ownership exchange. | |
201 scoped_ptr<HttpTransactionFactory> SetNetworkLayerForTesting( | |
rvargas (doing something else)
2014/01/15 03:26:29
I'm wondering what do you envision for the returne
Randy Smith (Not in Mondays)
2014/01/15 19:14:43
So that would work for this instance, and I'm will
rvargas (doing something else)
2014/01/15 19:39:45
ah, ok. That works.
| |
202 scoped_ptr<HttpTransactionFactory> new_network_layer); | |
203 | |
198 protected: | 204 protected: |
199 // Disk cache entry data indices. | 205 // Disk cache entry data indices. |
200 enum { | 206 enum { |
201 kResponseInfoIndex = 0, | 207 kResponseInfoIndex = 0, |
202 kResponseContentIndex, | 208 kResponseContentIndex, |
203 kMetadataIndex, | 209 kMetadataIndex, |
204 | 210 |
205 // Must remain at the end of the enum. | 211 // Must remain at the end of the enum. |
206 kNumCacheEntryDataIndices | 212 kNumCacheEntryDataIndices |
207 }; | 213 }; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 // Variables ---------------------------------------------------------------- | 380 // Variables ---------------------------------------------------------------- |
375 | 381 |
376 NetLog* net_log_; | 382 NetLog* net_log_; |
377 | 383 |
378 // Used when lazily constructing the disk_cache_. | 384 // Used when lazily constructing the disk_cache_. |
379 scoped_ptr<BackendFactory> backend_factory_; | 385 scoped_ptr<BackendFactory> backend_factory_; |
380 bool building_backend_; | 386 bool building_backend_; |
381 | 387 |
382 Mode mode_; | 388 Mode mode_; |
383 | 389 |
384 const scoped_ptr<HttpTransactionFactory> network_layer_; | 390 scoped_ptr<HttpTransactionFactory> network_layer_; |
385 scoped_ptr<disk_cache::Backend> disk_cache_; | 391 scoped_ptr<disk_cache::Backend> disk_cache_; |
386 | 392 |
387 // The set of active entries indexed by cache key. | 393 // The set of active entries indexed by cache key. |
388 ActiveEntriesMap active_entries_; | 394 ActiveEntriesMap active_entries_; |
389 | 395 |
390 // The set of doomed entries. | 396 // The set of doomed entries. |
391 ActiveEntriesSet doomed_entries_; | 397 ActiveEntriesSet doomed_entries_; |
392 | 398 |
393 // The set of entries "under construction". | 399 // The set of entries "under construction". |
394 PendingOpsMap pending_ops_; | 400 PendingOpsMap pending_ops_; |
395 | 401 |
396 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 402 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
397 | 403 |
398 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 404 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
399 }; | 405 }; |
400 | 406 |
401 } // namespace net | 407 } // namespace net |
402 | 408 |
403 #endif // NET_HTTP_HTTP_CACHE_H_ | 409 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |