| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const base::FilePath path_; | 118 const base::FilePath path_; |
| 119 int max_bytes_; | 119 int max_bytes_; |
| 120 scoped_refptr<base::MessageLoopProxy> thread_; | 120 scoped_refptr<base::MessageLoopProxy> thread_; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 123 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| 124 // The HttpCache takes ownership of the |backend_factory|. | 124 // The HttpCache takes ownership of the |backend_factory|. |
| 125 HttpCache(const net::HttpNetworkSession::Params& params, | 125 HttpCache(const net::HttpNetworkSession::Params& params, |
| 126 BackendFactory* backend_factory); | 126 BackendFactory* backend_factory); |
| 127 | 127 |
| 128 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 128 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| 129 // Provide an existing HttpNetworkSession, the cache can construct a | 129 // Provide an existing HttpNetworkSession, the cache can construct a |
| 130 // network layer with a shared HttpNetworkSession in order for multiple | 130 // network layer with a shared HttpNetworkSession in order for multiple |
| 131 // network layers to share information (e.g. authentication data). The | 131 // network layers to share information (e.g. authentication data). The |
| 132 // HttpCache takes ownership of the |backend_factory|. | 132 // HttpCache takes ownership of the |backend_factory|. |
| 133 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); | 133 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); |
| 134 | 134 |
| 135 // Initialize the cache from its component parts, which is useful for | 135 // Initialize the cache from its component parts. The lifetime of the |
| 136 // testing. The lifetime of the network_layer and backend_factory are managed | 136 // |network_layer| and |backend_factory| are managed by the HttpCache and |
| 137 // by the HttpCache and will be destroyed using |delete| when the HttpCache is | 137 // will be destroyed using |delete| when the HttpCache is destroyed. |
| 138 // destroyed. | |
| 139 HttpCache(HttpTransactionFactory* network_layer, | 138 HttpCache(HttpTransactionFactory* network_layer, |
| 140 NetLog* net_log, | 139 NetLog* net_log, |
| 141 BackendFactory* backend_factory); | 140 BackendFactory* backend_factory); |
| 142 | 141 |
| 143 virtual ~HttpCache(); | 142 virtual ~HttpCache(); |
| 144 | 143 |
| 145 HttpTransactionFactory* network_layer() { return network_layer_.get(); } | 144 HttpTransactionFactory* network_layer() { return network_layer_.get(); } |
| 146 | 145 |
| 147 // Retrieves the cache backend for this HttpCache instance. If the backend | 146 // Retrieves the cache backend for this HttpCache instance. If the backend |
| 148 // is not initialized yet, this method will initialize it. The return value is | 147 // is not initialized yet, this method will initialize it. The return value is |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 void RemovePendingTransaction(Transaction* trans); | 346 void RemovePendingTransaction(Transaction* trans); |
| 348 | 347 |
| 349 // Removes the transaction |trans|, from the pending list of |entry|. | 348 // Removes the transaction |trans|, from the pending list of |entry|. |
| 350 bool RemovePendingTransactionFromEntry(ActiveEntry* entry, | 349 bool RemovePendingTransactionFromEntry(ActiveEntry* entry, |
| 351 Transaction* trans); | 350 Transaction* trans); |
| 352 | 351 |
| 353 // Removes the transaction |trans|, from the pending list of |pending_op|. | 352 // Removes the transaction |trans|, from the pending list of |pending_op|. |
| 354 bool RemovePendingTransactionFromPendingOp(PendingOp* pending_op, | 353 bool RemovePendingTransactionFromPendingOp(PendingOp* pending_op, |
| 355 Transaction* trans); | 354 Transaction* trans); |
| 356 | 355 |
| 356 // Instantiates and sets QUIC server info factory. |
| 357 void SetupQuicServerInfoFactory(HttpNetworkSession* session); |
| 358 |
| 357 // Resumes processing the pending list of |entry|. | 359 // Resumes processing the pending list of |entry|. |
| 358 void ProcessPendingQueue(ActiveEntry* entry); | 360 void ProcessPendingQueue(ActiveEntry* entry); |
| 359 | 361 |
| 360 // Events (called via PostTask) --------------------------------------------- | 362 // Events (called via PostTask) --------------------------------------------- |
| 361 | 363 |
| 362 void OnProcessPendingQueue(ActiveEntry* entry); | 364 void OnProcessPendingQueue(ActiveEntry* entry); |
| 363 | 365 |
| 364 // Callbacks ---------------------------------------------------------------- | 366 // Callbacks ---------------------------------------------------------------- |
| 365 | 367 |
| 366 // Processes BackendCallback notifications. | 368 // Processes BackendCallback notifications. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 382 // Variables ---------------------------------------------------------------- | 384 // Variables ---------------------------------------------------------------- |
| 383 | 385 |
| 384 NetLog* net_log_; | 386 NetLog* net_log_; |
| 385 | 387 |
| 386 // Used when lazily constructing the disk_cache_. | 388 // Used when lazily constructing the disk_cache_. |
| 387 scoped_ptr<BackendFactory> backend_factory_; | 389 scoped_ptr<BackendFactory> backend_factory_; |
| 388 bool building_backend_; | 390 bool building_backend_; |
| 389 | 391 |
| 390 Mode mode_; | 392 Mode mode_; |
| 391 | 393 |
| 392 const scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; | 394 scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; |
| 393 | 395 |
| 394 scoped_ptr<HttpTransactionFactory> network_layer_; | 396 scoped_ptr<HttpTransactionFactory> network_layer_; |
| 395 | 397 |
| 396 scoped_ptr<disk_cache::Backend> disk_cache_; | 398 scoped_ptr<disk_cache::Backend> disk_cache_; |
| 397 | 399 |
| 398 // The set of active entries indexed by cache key. | 400 // The set of active entries indexed by cache key. |
| 399 ActiveEntriesMap active_entries_; | 401 ActiveEntriesMap active_entries_; |
| 400 | 402 |
| 401 // The set of doomed entries. | 403 // The set of doomed entries. |
| 402 ActiveEntriesSet doomed_entries_; | 404 ActiveEntriesSet doomed_entries_; |
| 403 | 405 |
| 404 // The set of entries "under construction". | 406 // The set of entries "under construction". |
| 405 PendingOpsMap pending_ops_; | 407 PendingOpsMap pending_ops_; |
| 406 | 408 |
| 407 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 409 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 408 | 410 |
| 409 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 411 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 410 }; | 412 }; |
| 411 | 413 |
| 412 } // namespace net | 414 } // namespace net |
| 413 | 415 |
| 414 #endif // NET_HTTP_HTTP_CACHE_H_ | 416 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |