| 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 return net::OK; // ERR_FAILED; |
| 755 } |
| 756 |
| 750 std::unique_ptr<WorkItem> item = | 757 std::unique_ptr<WorkItem> item = |
| 751 base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry); | 758 base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry); |
| 752 PendingOp* pending_op = GetPendingOp(key); | 759 PendingOp* pending_op = GetPendingOp(key); |
| 753 if (pending_op->writer) { | 760 if (pending_op->writer) { |
| 754 pending_op->pending_queue.push_back(std::move(item)); | 761 pending_op->pending_queue.push_back(std::move(item)); |
| 755 return ERR_IO_PENDING; | 762 return ERR_IO_PENDING; |
| 756 } | 763 } |
| 757 | 764 |
| 758 DCHECK(pending_op->pending_queue.empty()); | 765 DCHECK(pending_op->pending_queue.empty()); |
| 759 | 766 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 building_backend_ = false; | 1370 building_backend_ = false; |
| 1364 DeletePendingOp(pending_op); | 1371 DeletePendingOp(pending_op); |
| 1365 } | 1372 } |
| 1366 | 1373 |
| 1367 // The cache may be gone when we return from the callback. | 1374 // The cache may be gone when we return from the callback. |
| 1368 if (!item->DoCallback(result, disk_cache_.get())) | 1375 if (!item->DoCallback(result, disk_cache_.get())) |
| 1369 item->NotifyTransaction(result, NULL); | 1376 item->NotifyTransaction(result, NULL); |
| 1370 } | 1377 } |
| 1371 | 1378 |
| 1372 } // namespace net | 1379 } // namespace net |
| OLD | NEW |