Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: net/http/http_cache.cc

Issue 2922973003: RFC: use some in-memory state in SimpleCache to quickly cache-miss some CantConditionalize cases
Patch Set: omewhat better take at higher-level HC::T impl, a bit lessy hacky, and actually write to cache now. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698