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 #include "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 pending_ops_.erase(it); | 732 pending_ops_.erase(it); |
733 break; | 733 break; |
734 } | 734 } |
735 } | 735 } |
736 } | 736 } |
737 DCHECK(pending_op->pending_queue.empty()); | 737 DCHECK(pending_op->pending_queue.empty()); |
738 | 738 |
739 delete pending_op; | 739 delete pending_op; |
740 } | 740 } |
741 | 741 |
742 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, | 742 int HttpCache::OpenEntry(const std::string& key, |
| 743 ActiveEntry** entry, |
743 Transaction* trans) { | 744 Transaction* trans) { |
744 ActiveEntry* active_entry = FindActiveEntry(key); | 745 ActiveEntry* active_entry = FindActiveEntry(key); |
745 if (active_entry) { | 746 if (active_entry) { |
746 *entry = active_entry; | 747 *entry = active_entry; |
747 return OK; | 748 return OK; |
748 } | 749 } |
749 | 750 |
| 751 // See if we could potentially quick-reject the entry. |
| 752 uint8_t in_memory_info = disk_cache_->GetMemoryEntryData(key); |
| 753 if (trans->MaybeRejectBasedOnMemoryEntryData(in_memory_info)) { |
| 754 disk_cache_->DoomEntry(key, base::Bind([](int) {})); |
| 755 return net::ERR_CACHE_ENTRY_NOT_SUITABLE; |
| 756 } |
| 757 |
750 std::unique_ptr<WorkItem> item = | 758 std::unique_ptr<WorkItem> item = |
751 base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry); | 759 base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry); |
752 PendingOp* pending_op = GetPendingOp(key); | 760 PendingOp* pending_op = GetPendingOp(key); |
753 if (pending_op->writer) { | 761 if (pending_op->writer) { |
754 pending_op->pending_queue.push_back(std::move(item)); | 762 pending_op->pending_queue.push_back(std::move(item)); |
755 return ERR_IO_PENDING; | 763 return ERR_IO_PENDING; |
756 } | 764 } |
757 | 765 |
758 DCHECK(pending_op->pending_queue.empty()); | 766 DCHECK(pending_op->pending_queue.empty()); |
759 | 767 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 building_backend_ = false; | 1371 building_backend_ = false; |
1364 DeletePendingOp(pending_op); | 1372 DeletePendingOp(pending_op); |
1365 } | 1373 } |
1366 | 1374 |
1367 // The cache may be gone when we return from the callback. | 1375 // The cache may be gone when we return from the callback. |
1368 if (!item->DoCallback(result, disk_cache_.get())) | 1376 if (!item->DoCallback(result, disk_cache_.get())) |
1369 item->NotifyTransaction(result, NULL); | 1377 item->NotifyTransaction(result, NULL); |
1370 } | 1378 } |
1371 | 1379 |
1372 } // namespace net | 1380 } // namespace net |
OLD | NEW |