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

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

Issue 2910553002: fully cache small audio/video (Closed)
Patch Set: tests fixed and added Created 3 years, 7 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 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return true; 142 return true;
143 } 143 }
144 144
145 void UrlData::OnEmpty() { 145 void UrlData::OnEmpty() {
146 DCHECK(thread_checker_.CalledOnValidThread()); 146 DCHECK(thread_checker_.CalledOnValidThread());
147 base::ThreadTaskRunnerHandle::Get()->PostTask( 147 base::ThreadTaskRunnerHandle::Get()->PostTask(
148 FROM_HERE, base::Bind(&UrlIndex::RemoveUrlDataIfEmpty, url_index_, 148 FROM_HERE, base::Bind(&UrlIndex::RemoveUrlDataIfEmpty, url_index_,
149 scoped_refptr<UrlData>(this))); 149 scoped_refptr<UrlData>(this)));
150 } 150 }
151 151
152 bool UrlData::Valid() const { 152 bool UrlData::FullyCached() {
153 DCHECK(thread_checker_.CalledOnValidThread());
154 if (length_ == kPositionNotSpecified)
155 return false;
156 return (multibuffer()->FindNextUnavailable(0) << kBlockSizeShift) >= length_;
DaleCurtis 2017/05/26 16:43:57 Needs an explanation.
hubbe 2017/05/26 17:39:45 Done.
157 }
158
159 bool UrlData::Valid() {
153 DCHECK(thread_checker_.CalledOnValidThread()); 160 DCHECK(thread_checker_.CalledOnValidThread());
154 base::Time now = base::Time::Now(); 161 base::Time now = base::Time::Now();
155 if (!range_supported_) 162 if (!range_supported_ && !FullyCached())
156 return false; 163 return false;
157 // When ranges are not supported, we cannot re-use cached data. 164 // When ranges are not supported, we cannot re-use cached data.
158 if (valid_until_ > now) 165 if (valid_until_ > now)
159 return true; 166 return true;
160 if (now - last_used_ < 167 if (now - last_used_ <
161 base::TimeDelta::FromSeconds(kUrlMappingTimeoutSeconds)) 168 base::TimeDelta::FromSeconds(kUrlMappingTimeoutSeconds))
162 return true; 169 return true;
163 return false; 170 return false;
164 } 171 }
165 172
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 url_data->CachedSize() > (*by_url_slot)->CachedSize())) { 276 url_data->CachedSize() > (*by_url_slot)->CachedSize())) {
270 *by_url_slot = url_data; 277 *by_url_slot = url_data;
271 } else { 278 } else {
272 (*by_url_slot)->MergeFrom(url_data); 279 (*by_url_slot)->MergeFrom(url_data);
273 } 280 }
274 } 281 }
275 return *by_url_slot; 282 return *by_url_slot;
276 } 283 }
277 284
278 } // namespace media 285 } // namespace media
OLDNEW
« media/blink/multibuffer_data_source.cc ('K') | « media/blink/url_index.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698