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

Side by Side Diff: media/blink/url_index.cc

Issue 1829163002: Lazily prune the multibuffer block cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no export Created 4 years, 8 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
« no previous file with comments | « media/blink/multibuffer_unittest.cc ('k') | media/blink/url_index_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <set> 5 #include <set>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 size_t UrlData::CachedSize() { 162 size_t UrlData::CachedSize() {
163 DCHECK(thread_checker_.CalledOnValidThread()); 163 DCHECK(thread_checker_.CalledOnValidThread());
164 return multibuffer()->map().size(); 164 return multibuffer()->map().size();
165 } 165 }
166 166
167 UrlIndex::UrlIndex(blink::WebFrame* frame) : UrlIndex(frame, kBlockSizeShift) {} 167 UrlIndex::UrlIndex(blink::WebFrame* frame) : UrlIndex(frame, kBlockSizeShift) {}
168 168
169 UrlIndex::UrlIndex(blink::WebFrame* frame, int block_shift) 169 UrlIndex::UrlIndex(blink::WebFrame* frame, int block_shift)
170 : frame_(frame), 170 : frame_(frame),
171 lru_(new MultiBuffer::GlobalLRU()), 171 lru_(new MultiBuffer::GlobalLRU(
172 base::MessageLoop::current()->task_runner())),
172 block_shift_(block_shift), 173 block_shift_(block_shift),
173 weak_factory_(this) {} 174 weak_factory_(this) {}
174 175
175 UrlIndex::~UrlIndex() {} 176 UrlIndex::~UrlIndex() {}
176 177
177 void UrlIndex::RemoveUrlDataIfEmpty(const scoped_refptr<UrlData>& url_data) { 178 void UrlIndex::RemoveUrlDataIfEmpty(const scoped_refptr<UrlData>& url_data) {
178 if (!url_data->multibuffer()->map().empty()) 179 if (!url_data->multibuffer()->map().empty())
179 return; 180 return;
180 181
181 auto i = by_url_.find(url_data->key()); 182 auto i = by_url_.find(url_data->key());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 url_data->CachedSize() > (*by_url_slot)->CachedSize())) { 229 url_data->CachedSize() > (*by_url_slot)->CachedSize())) {
229 *by_url_slot = url_data; 230 *by_url_slot = url_data;
230 } else { 231 } else {
231 (*by_url_slot)->MergeFrom(url_data); 232 (*by_url_slot)->MergeFrom(url_data);
232 } 233 }
233 } 234 }
234 return *by_url_slot; 235 return *by_url_slot;
235 } 236 }
236 237
237 } // namespace media 238 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer_unittest.cc ('k') | media/blink/url_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698