| 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/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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |