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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 } | 736 } |
737 | 737 |
738 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, | 738 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, |
739 Transaction* trans) { | 739 Transaction* trans) { |
740 ActiveEntry* active_entry = FindActiveEntry(key); | 740 ActiveEntry* active_entry = FindActiveEntry(key); |
741 if (active_entry) { | 741 if (active_entry) { |
742 *entry = active_entry; | 742 *entry = active_entry; |
743 return OK; | 743 return OK; |
744 } | 744 } |
745 | 745 |
| 746 // See if we could potentially quick-reject the entry. |
| 747 uint8_t in_memory_info = disk_cache_->GetEntryInMemoryData(key); |
| 748 if (trans->MaybeRejectBasedOnEntryInMemoryData(in_memory_info)) { |
| 749 disk_cache_->DoomEntry(key, base::Bind([](int) {})); |
| 750 return net::ERR_CACHE_ENTRY_NOT_SUITABLE; |
| 751 } |
| 752 |
746 std::unique_ptr<WorkItem> item = | 753 std::unique_ptr<WorkItem> item = |
747 std::make_unique<WorkItem>(WI_OPEN_ENTRY, trans, entry); | 754 std::make_unique<WorkItem>(WI_OPEN_ENTRY, trans, entry); |
748 PendingOp* pending_op = GetPendingOp(key); | 755 PendingOp* pending_op = GetPendingOp(key); |
749 if (pending_op->writer) { | 756 if (pending_op->writer) { |
750 pending_op->pending_queue.push_back(std::move(item)); | 757 pending_op->pending_queue.push_back(std::move(item)); |
751 return ERR_IO_PENDING; | 758 return ERR_IO_PENDING; |
752 } | 759 } |
753 | 760 |
754 DCHECK(pending_op->pending_queue.empty()); | 761 DCHECK(pending_op->pending_queue.empty()); |
755 | 762 |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 building_backend_ = false; | 1419 building_backend_ = false; |
1413 DeletePendingOp(pending_op); | 1420 DeletePendingOp(pending_op); |
1414 } | 1421 } |
1415 | 1422 |
1416 // The cache may be gone when we return from the callback. | 1423 // The cache may be gone when we return from the callback. |
1417 if (!item->DoCallback(result, disk_cache_.get())) | 1424 if (!item->DoCallback(result, disk_cache_.get())) |
1418 item->NotifyTransaction(result, NULL); | 1425 item->NotifyTransaction(result, NULL); |
1419 } | 1426 } |
1420 | 1427 |
1421 } // namespace net | 1428 } // namespace net |
OLD | NEW |