| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, which is useful for |
| 136 // testing. The lifetime of the network_layer and backend_factory are managed | 136 // testing. The lifetime of the network_layer and backend_factory are managed |
| 137 // by the HttpCache and will be destroyed using |delete| when the HttpCache is | 137 // by the HttpCache and will be destroyed using |delete| when the HttpCache is |
| 138 // destroyed. | 138 // destroyed. |
| 139 HttpCache(HttpTransactionFactory* network_layer, | 139 HttpCache(HttpTransactionFactory* network_layer, |
| 140 NetLog* net_log, | 140 NetLog* net_log, |
| 141 BackendFactory* backend_factory); | 141 BackendFactory* backend_factory, |
| 142 bool setup_network_session); |
| 142 | 143 |
| 143 virtual ~HttpCache(); | 144 virtual ~HttpCache(); |
| 144 | 145 |
| 145 HttpTransactionFactory* network_layer() { return network_layer_.get(); } | 146 HttpTransactionFactory* network_layer() { return network_layer_.get(); } |
| 146 | 147 |
| 147 // Retrieves the cache backend for this HttpCache instance. If the backend | 148 // 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 | 149 // is not initialized yet, this method will initialize it. The return value is |
| 149 // a network error code, and it could be ERR_IO_PENDING, in which case the | 150 // a network error code, and it could be ERR_IO_PENDING, in which case the |
| 150 // |callback| will be notified when the operation completes. The pointer that | 151 // |callback| will be notified when the operation completes. The pointer that |
| 151 // receives the |backend| must remain valid until the operation completes. | 152 // receives the |backend| must remain valid until the operation completes. |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 void RemovePendingTransaction(Transaction* trans); | 348 void RemovePendingTransaction(Transaction* trans); |
| 348 | 349 |
| 349 // Removes the transaction |trans|, from the pending list of |entry|. | 350 // Removes the transaction |trans|, from the pending list of |entry|. |
| 350 bool RemovePendingTransactionFromEntry(ActiveEntry* entry, | 351 bool RemovePendingTransactionFromEntry(ActiveEntry* entry, |
| 351 Transaction* trans); | 352 Transaction* trans); |
| 352 | 353 |
| 353 // Removes the transaction |trans|, from the pending list of |pending_op|. | 354 // Removes the transaction |trans|, from the pending list of |pending_op|. |
| 354 bool RemovePendingTransactionFromPendingOp(PendingOp* pending_op, | 355 bool RemovePendingTransactionFromPendingOp(PendingOp* pending_op, |
| 355 Transaction* trans); | 356 Transaction* trans); |
| 356 | 357 |
| 358 // Instantiates and sets QUIC server info factory. Should be invoked only |
| 359 // once for every network session. |
| 360 void SetupNetworkSession(HttpNetworkSession* session); |
| 361 |
| 357 // Resumes processing the pending list of |entry|. | 362 // Resumes processing the pending list of |entry|. |
| 358 void ProcessPendingQueue(ActiveEntry* entry); | 363 void ProcessPendingQueue(ActiveEntry* entry); |
| 359 | 364 |
| 360 // Events (called via PostTask) --------------------------------------------- | 365 // Events (called via PostTask) --------------------------------------------- |
| 361 | 366 |
| 362 void OnProcessPendingQueue(ActiveEntry* entry); | 367 void OnProcessPendingQueue(ActiveEntry* entry); |
| 363 | 368 |
| 364 // Callbacks ---------------------------------------------------------------- | 369 // Callbacks ---------------------------------------------------------------- |
| 365 | 370 |
| 366 // Processes BackendCallback notifications. | 371 // Processes BackendCallback notifications. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 382 // Variables ---------------------------------------------------------------- | 387 // Variables ---------------------------------------------------------------- |
| 383 | 388 |
| 384 NetLog* net_log_; | 389 NetLog* net_log_; |
| 385 | 390 |
| 386 // Used when lazily constructing the disk_cache_. | 391 // Used when lazily constructing the disk_cache_. |
| 387 scoped_ptr<BackendFactory> backend_factory_; | 392 scoped_ptr<BackendFactory> backend_factory_; |
| 388 bool building_backend_; | 393 bool building_backend_; |
| 389 | 394 |
| 390 Mode mode_; | 395 Mode mode_; |
| 391 | 396 |
| 392 const scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; | 397 scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; |
| 393 | 398 |
| 394 scoped_ptr<HttpTransactionFactory> network_layer_; | 399 scoped_ptr<HttpTransactionFactory> network_layer_; |
| 395 | 400 |
| 396 scoped_ptr<disk_cache::Backend> disk_cache_; | 401 scoped_ptr<disk_cache::Backend> disk_cache_; |
| 397 | 402 |
| 398 // The set of active entries indexed by cache key. | 403 // The set of active entries indexed by cache key. |
| 399 ActiveEntriesMap active_entries_; | 404 ActiveEntriesMap active_entries_; |
| 400 | 405 |
| 401 // The set of doomed entries. | 406 // The set of doomed entries. |
| 402 ActiveEntriesSet doomed_entries_; | 407 ActiveEntriesSet doomed_entries_; |
| 403 | 408 |
| 404 // The set of entries "under construction". | 409 // The set of entries "under construction". |
| 405 PendingOpsMap pending_ops_; | 410 PendingOpsMap pending_ops_; |
| 406 | 411 |
| 407 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 412 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 408 | 413 |
| 409 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 414 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 410 }; | 415 }; |
| 411 | 416 |
| 412 } // namespace net | 417 } // namespace net |
| 413 | 418 |
| 414 #endif // NET_HTTP_HTTP_CACHE_H_ | 419 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |