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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 kMetadataIndex, | 239 kMetadataIndex, |
240 | 240 |
241 // Must remain at the end of the enum. | 241 // Must remain at the end of the enum. |
242 kNumCacheEntryDataIndices | 242 kNumCacheEntryDataIndices |
243 }; | 243 }; |
244 | 244 |
245 class MetadataWriter; | 245 class MetadataWriter; |
246 class QuicServerInfoFactoryAdaptor; | 246 class QuicServerInfoFactoryAdaptor; |
247 class Transaction; | 247 class Transaction; |
248 class WorkItem; | 248 class WorkItem; |
| 249 class Writers; |
| 250 friend class WritersTest; // To access ActiveEntry in the test class. |
| 251 friend class MockHttpCacheTransaction; |
249 friend class Transaction; | 252 friend class Transaction; |
250 friend class ViewCacheHelper; | 253 friend class ViewCacheHelper; |
251 struct PendingOp; // Info for an entry under construction. | 254 struct PendingOp; // Info for an entry under construction. |
252 | 255 |
253 // To help with testing. | 256 // To help with testing. |
254 friend class MockHttpCache; | 257 friend class MockHttpCache; |
255 | 258 |
256 using TransactionList = std::list<Transaction*>; | 259 using TransactionList = std::list<Transaction*>; |
257 using TransactionSet = std::unordered_set<Transaction*>; | 260 using TransactionSet = std::unordered_set<Transaction*>; |
258 typedef std::list<std::unique_ptr<WorkItem>> WorkItemList; | 261 typedef std::list<std::unique_ptr<WorkItem>> WorkItemList; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 420 |
418 // Called when the transaction has finished writing to this entry. |success| | 421 // Called when the transaction has finished writing to this entry. |success| |
419 // is false if the cache entry should be deleted. | 422 // is false if the cache entry should be deleted. |
420 void DoneWritingToEntry(ActiveEntry* entry, | 423 void DoneWritingToEntry(ActiveEntry* entry, |
421 bool success, | 424 bool success, |
422 Transaction* transaction); | 425 Transaction* transaction); |
423 | 426 |
424 // Called when the transaction has finished reading from this entry. | 427 // Called when the transaction has finished reading from this entry. |
425 void DoneReadingFromEntry(ActiveEntry* entry, Transaction* transaction); | 428 void DoneReadingFromEntry(ActiveEntry* entry, Transaction* transaction); |
426 | 429 |
| 430 // Called when the transaction has received a non-matching response to |
| 431 // validation and it's not the transaction responsible for writing the |
| 432 // response body. |
| 433 void DoomEntryValidationNoMatch(ActiveEntry* entry); |
| 434 |
427 // Removes and returns all queued transactions in |entry| in FIFO order. This | 435 // Removes and returns all queued transactions in |entry| in FIFO order. This |
428 // includes transactions that have completed the headers phase and those that | 436 // includes transactions that have completed the headers phase and those that |
429 // have not been added to the entry yet in that order. |list| is the output | 437 // have not been added to the entry yet in that order. |list| is the output |
430 // argument. | 438 // argument. |
431 void RemoveAllQueuedTransactions(ActiveEntry* entry, TransactionList* list); | 439 void RemoveAllQueuedTransactions(ActiveEntry* entry, TransactionList* list); |
432 | 440 |
433 // Processes either writer's failure to write response body or | 441 // Processes either writer's failure to write response body or |
434 // headers_transactions's failure to write headers. Also invoked when headers | 442 // headers_transactions's failure to write headers. |
435 // transaction's validation result is not a match. | |
436 void ProcessEntryFailure(ActiveEntry* entry, Transaction* transaction); | 443 void ProcessEntryFailure(ActiveEntry* entry, Transaction* transaction); |
437 | 444 |
438 // Restarts headers_transaction and done_headers_queue transactions. | 445 // Restarts headers_transaction and done_headers_queue transactions. |
439 void RestartHeadersPhaseTransactions(ActiveEntry* entry, | 446 void RestartHeadersPhaseTransactions(ActiveEntry* entry, |
440 Transaction* transaction); | 447 Transaction* transaction); |
441 | 448 |
442 // Restarts the headers_transaction by setting its state. Since the | 449 // Restarts the headers_transaction by setting its state. Since the |
443 // headers_transaction is awaiting an asynchronous operation completion, | 450 // headers_transaction is awaiting an asynchronous operation completion, |
444 // it will be restarted when it's IO callback is invoked. | 451 // it will be restarted when it's IO callback is invoked. |
445 void RestartHeadersTransaction(ActiveEntry* entry); | 452 void RestartHeadersTransaction(ActiveEntry* entry); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 THREAD_CHECKER(thread_checker_); | 553 THREAD_CHECKER(thread_checker_); |
547 | 554 |
548 base::WeakPtrFactory<HttpCache> weak_factory_; | 555 base::WeakPtrFactory<HttpCache> weak_factory_; |
549 | 556 |
550 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 557 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
551 }; | 558 }; |
552 | 559 |
553 } // namespace net | 560 } // namespace net |
554 | 561 |
555 #endif // NET_HTTP_HTTP_CACHE_H_ | 562 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |