OLD | NEW |
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/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ResourceMultiBuffer* UrlData::multibuffer() { | 190 ResourceMultiBuffer* UrlData::multibuffer() { |
191 DCHECK(thread_checker_.CalledOnValidThread()); | 191 DCHECK(thread_checker_.CalledOnValidThread()); |
192 return &multibuffer_; | 192 return &multibuffer_; |
193 } | 193 } |
194 | 194 |
195 size_t UrlData::CachedSize() { | 195 size_t UrlData::CachedSize() { |
196 DCHECK(thread_checker_.CalledOnValidThread()); | 196 DCHECK(thread_checker_.CalledOnValidThread()); |
197 return multibuffer()->map().size(); | 197 return multibuffer()->map().size(); |
198 } | 198 } |
199 | 199 |
200 UrlIndex::UrlIndex(blink::WebFrame* frame) : UrlIndex(frame, kBlockSizeShift) {} | 200 UrlIndex::UrlIndex(blink::WebLocalFrame* frame) |
| 201 : UrlIndex(frame, kBlockSizeShift) {} |
201 | 202 |
202 UrlIndex::UrlIndex(blink::WebFrame* frame, int block_shift) | 203 UrlIndex::UrlIndex(blink::WebLocalFrame* frame, int block_shift) |
203 : frame_(frame), | 204 : frame_(frame), |
204 lru_(new MultiBuffer::GlobalLRU(base::ThreadTaskRunnerHandle::Get())), | 205 lru_(new MultiBuffer::GlobalLRU(base::ThreadTaskRunnerHandle::Get())), |
205 block_shift_(block_shift), | 206 block_shift_(block_shift), |
206 weak_factory_(this) {} | 207 weak_factory_(this) {} |
207 | 208 |
208 UrlIndex::~UrlIndex() {} | 209 UrlIndex::~UrlIndex() {} |
209 | 210 |
210 void UrlIndex::RemoveUrlDataIfEmpty(const scoped_refptr<UrlData>& url_data) { | 211 void UrlIndex::RemoveUrlDataIfEmpty(const scoped_refptr<UrlData>& url_data) { |
211 if (!url_data->multibuffer()->map().empty()) | 212 if (!url_data->multibuffer()->map().empty()) |
212 return; | 213 return; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 url_data->CachedSize() > (*by_url_slot)->CachedSize())) { | 279 url_data->CachedSize() > (*by_url_slot)->CachedSize())) { |
279 *by_url_slot = url_data; | 280 *by_url_slot = url_data; |
280 } else { | 281 } else { |
281 (*by_url_slot)->MergeFrom(url_data); | 282 (*by_url_slot)->MergeFrom(url_data); |
282 } | 283 } |
283 } | 284 } |
284 return *by_url_slot; | 285 return *by_url_slot; |
285 } | 286 } |
286 | 287 |
287 } // namespace media | 288 } // namespace media |
OLD | NEW |