Chromium Code Reviews| 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 7234 (any exceptions are called out in the code). | 7 // caching logic follows RFC 7234 (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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 // Destroys an ActiveEntry (active or doomed). | 340 // Destroys an ActiveEntry (active or doomed). |
| 341 void DestroyEntry(ActiveEntry* entry); | 341 void DestroyEntry(ActiveEntry* entry); |
| 342 | 342 |
| 343 // Adds a transaction to an ActiveEntry. If this method returns ERR_IO_PENDING | 343 // Adds a transaction to an ActiveEntry. If this method returns ERR_IO_PENDING |
| 344 // the transaction will be notified about completion via its IO callback. This | 344 // the transaction will be notified about completion via its IO callback. This |
| 345 // method returns ERR_CACHE_RACE to signal the transaction that it cannot be | 345 // method returns ERR_CACHE_RACE to signal the transaction that it cannot be |
| 346 // added to the provided entry, and it should retry the process with another | 346 // added to the provided entry, and it should retry the process with another |
| 347 // one (in this case, the entry is no longer valid). | 347 // one (in this case, the entry is no longer valid). |
| 348 int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); | 348 int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); |
| 349 | 349 |
| 350 // Called when the transaction has finished working with this entry. |cancel| | 350 // Used with DoneWithEntry() to indicate the state of the entry. |
| 351 // is true if the operation was cancelled by the caller instead of running | 351 enum class EntryState { SUCCEEDED, DOOMED }; |
|
rvargas (doing something else)
2015/09/11 23:56:17
nit: types go before methods.
asanka
2015/09/17 21:59:40
Done.
| |
| 352 // to completion. | |
| 353 void DoneWithEntry(ActiveEntry* entry, Transaction* trans, bool cancel); | |
| 354 | 352 |
| 355 // Called when the transaction has finished writing to this entry. |success| | 353 // Removes |trans| from |entry|. |trans| is required to be a reader or writer |
| 356 // is false if the cache entry should be deleted. | 354 // that was added to |trans| by AddTransactionToEntry(). For writers, |
| 357 void DoneWritingToEntry(ActiveEntry* entry, bool success); | 355 // |entry_state| indicates the state of the entry after releasing. |
|
rvargas (doing something else)
2015/09/11 23:56:17
nit: what is "after releasing"?
asanka
2015/09/17 21:59:40
Clarified.
| |
| 358 | 356 // |
| 359 // Called when the transaction has finished reading from this entry. | 357 // If |entry_state| is DOOMED, then the cache entry is destroyed and any |
|
rvargas (doing something else)
2015/09/11 23:56:17
nit: Can we change this to a command like word ins
asanka
2015/09/17 21:59:40
Changed to KEEP/DOOM
| |
| 360 void DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans); | 358 // pending transactions that were formerly waiting to be added to |entry| will |
| 359 // receive ERR_CACHE_RACE. | |
| 360 // | |
| 361 // If |entry_state| is SUCCEEDED, then |entry| is assumed to be safe for | |
| 362 // further consumption and pending transaction will be permitted to use it. | |
| 363 void DoneWithEntry(ActiveEntry* entry, | |
| 364 Transaction* trans, | |
| 365 EntryState entry_state); | |
| 361 | 366 |
| 362 // Converts the active writer transaction to a reader so that other | 367 // Converts the active writer transaction to a reader so that other |
| 363 // transactions can start reading from this entry. | 368 // transactions can start reading from this entry. |
| 364 void ConvertWriterToReader(ActiveEntry* entry); | 369 void ConvertWriterToReader(ActiveEntry* entry); |
| 365 | 370 |
| 366 // Returns the LoadState of the provided pending transaction. | 371 // Returns the LoadState of the provided pending transaction. |
| 367 LoadState GetLoadStateForPendingTransaction(const Transaction* trans); | 372 LoadState GetLoadStateForPendingTransaction(const Transaction* trans); |
| 368 | 373 |
| 369 // Removes the transaction |trans|, from the pending list of an entry | 374 // Removes the transaction |trans|, from the pending list of an entry |
| 370 // (PendingOp, active or doomed entry). | 375 // (PendingOp, active or doomed entry). |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 scoped_ptr<base::Clock> clock_; | 446 scoped_ptr<base::Clock> clock_; |
| 442 | 447 |
| 443 base::WeakPtrFactory<HttpCache> weak_factory_; | 448 base::WeakPtrFactory<HttpCache> weak_factory_; |
| 444 | 449 |
| 445 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 450 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 446 }; | 451 }; |
| 447 | 452 |
| 448 } // namespace net | 453 } // namespace net |
| 449 | 454 |
| 450 #endif // NET_HTTP_HTTP_CACHE_H_ | 455 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |