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

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: cleanup naming in SimpleCache impl of this some 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "net/http/http_util.h" 46 #include "net/http/http_util.h"
47 #include "net/log/net_log_with_source.h" 47 #include "net/log/net_log_with_source.h"
48 #include "net/quic/chromium/quic_server_info.h" 48 #include "net/quic/chromium/quic_server_info.h"
49 49
50 #if defined(OS_POSIX) 50 #if defined(OS_POSIX)
51 #include <unistd.h> 51 #include <unistd.h>
52 #endif 52 #endif
53 53
54 namespace net { 54 namespace net {
55 55
56 namespace {
57
58 void DoNothing(int rv) {}
59
60 } // anonymous namespace
61
56 HttpCache::DefaultBackend::DefaultBackend( 62 HttpCache::DefaultBackend::DefaultBackend(
57 CacheType type, 63 CacheType type,
58 BackendType backend_type, 64 BackendType backend_type,
59 const base::FilePath& path, 65 const base::FilePath& path,
60 int max_bytes, 66 int max_bytes,
61 const scoped_refptr<base::SingleThreadTaskRunner>& thread) 67 const scoped_refptr<base::SingleThreadTaskRunner>& thread)
62 : type_(type), 68 : type_(type),
63 backend_type_(backend_type), 69 backend_type_(backend_type),
64 path_(path), 70 path_(path),
65 max_bytes_(max_bytes), 71 max_bytes_(max_bytes),
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 pending_ops_.erase(it); 738 pending_ops_.erase(it);
733 break; 739 break;
734 } 740 }
735 } 741 }
736 } 742 }
737 DCHECK(pending_op->pending_queue.empty()); 743 DCHECK(pending_op->pending_queue.empty());
738 744
739 delete pending_op; 745 delete pending_op;
740 } 746 }
741 747
742 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, 748 int HttpCache::OpenEntry(const std::string& key,
749 ActiveEntry** entry,
743 Transaction* trans) { 750 Transaction* trans) {
744 ActiveEntry* active_entry = FindActiveEntry(key); 751 ActiveEntry* active_entry = FindActiveEntry(key);
745 if (active_entry) { 752 if (active_entry) {
746 *entry = active_entry; 753 *entry = active_entry;
747 return OK; 754 return OK;
748 } 755 }
749 756
757 // See if we could potentially quick-reject the entry.
758 uint8_t in_memory_info = disk_cache_->GetMemoryEntryData(key);
759 if (trans->CanRejectBasedOnMemoryEntryData(in_memory_info)) {
760 disk_cache_->DoomEntry(key, base::Bind(DoNothing));
761 return net::ERR_FAILED;
Randy Smith (Not in Mondays) 2017/06/13 17:52:21 Won't this result in failing the consuming HttpCac
Maks Orlovich 2017/06/13 18:15:08 It's the same status a miss on OpenEntry would ret
762 }
763
750 std::unique_ptr<WorkItem> item = 764 std::unique_ptr<WorkItem> item =
751 base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry); 765 base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry);
752 PendingOp* pending_op = GetPendingOp(key); 766 PendingOp* pending_op = GetPendingOp(key);
753 if (pending_op->writer) { 767 if (pending_op->writer) {
754 pending_op->pending_queue.push_back(std::move(item)); 768 pending_op->pending_queue.push_back(std::move(item));
755 return ERR_IO_PENDING; 769 return ERR_IO_PENDING;
756 } 770 }
757 771
758 DCHECK(pending_op->pending_queue.empty()); 772 DCHECK(pending_op->pending_queue.empty());
759 773
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 building_backend_ = false; 1192 building_backend_ = false;
1179 DeletePendingOp(pending_op); 1193 DeletePendingOp(pending_op);
1180 } 1194 }
1181 1195
1182 // The cache may be gone when we return from the callback. 1196 // The cache may be gone when we return from the callback.
1183 if (!item->DoCallback(result, disk_cache_.get())) 1197 if (!item->DoCallback(result, disk_cache_.get()))
1184 item->NotifyTransaction(result, NULL); 1198 item->NotifyTransaction(result, NULL);
1185 } 1199 }
1186 1200
1187 } // namespace net 1201 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698