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

Side by Side Diff: net/http/http_cache_transaction.cc

Issue 478763004: Bypass http cache for concurrent range requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_cache_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 (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_transaction.h" 5 #include "net/http/http_cache_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 cache_pending_ = true; 1375 cache_pending_ = true;
1376 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; 1376 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE;
1377 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); 1377 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY);
1378 DCHECK(entry_lock_waiting_since_.is_null()); 1378 DCHECK(entry_lock_waiting_since_.is_null());
1379 entry_lock_waiting_since_ = TimeTicks::Now(); 1379 entry_lock_waiting_since_ = TimeTicks::Now();
1380 int rv = cache_->AddTransactionToEntry(new_entry_, this); 1380 int rv = cache_->AddTransactionToEntry(new_entry_, this);
1381 if (rv == ERR_IO_PENDING) { 1381 if (rv == ERR_IO_PENDING) {
1382 if (bypass_lock_for_test_) { 1382 if (bypass_lock_for_test_) {
1383 OnAddToEntryTimeout(entry_lock_waiting_since_); 1383 OnAddToEntryTimeout(entry_lock_waiting_since_);
1384 } else { 1384 } else {
1385 const int kTimeoutSeconds = 20; 1385 int timeout_secs = 20;
1386 if (partial_ && new_entry_->writer &&
1387 new_entry_->writer->range_requested_) {
1388 // Immediately timeout and bypass the cache if we're a range request and
1389 // we're blocked by the reader/writer lock. Doing so eliminates a long
1390 // running issue, http://crbug.com/31014, where two of the same media
1391 // resources could not be played back simultaneously due to one locking
1392 // the cache entry until the entire video was downloaded.
1393 //
1394 // Bypassing the cache is not ideal, as we are now ignoring the cache
1395 // entirely for all range requests to a resource beyond the first. This
1396 // is however a much more succinct solution than the alternatives, which
1397 // would require somewhat significant changes to the http caching logic.
1398 timeout_secs = 0;
1399 }
1386 base::MessageLoop::current()->PostDelayedTask( 1400 base::MessageLoop::current()->PostDelayedTask(
1387 FROM_HERE, 1401 FROM_HERE,
1388 base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout, 1402 base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout,
1389 weak_factory_.GetWeakPtr(), entry_lock_waiting_since_), 1403 weak_factory_.GetWeakPtr(), entry_lock_waiting_since_),
1390 TimeDelta::FromSeconds(kTimeoutSeconds)); 1404 TimeDelta::FromSeconds(timeout_secs));
1391 } 1405 }
1392 } 1406 }
1393 return rv; 1407 return rv;
1394 } 1408 }
1395 1409
1396 int HttpCache::Transaction::DoAddToEntryComplete(int result) { 1410 int HttpCache::Transaction::DoAddToEntryComplete(int result) {
1397 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, 1411 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY,
1398 result); 1412 result);
1399 const TimeDelta entry_lock_wait = 1413 const TimeDelta entry_lock_wait =
1400 TimeTicks::Now() - entry_lock_waiting_since_; 1414 TimeTicks::Now() - entry_lock_waiting_since_;
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 default: 2876 default:
2863 NOTREACHED(); 2877 NOTREACHED();
2864 } 2878 }
2865 } 2879 }
2866 2880
2867 void HttpCache::Transaction::OnIOComplete(int result) { 2881 void HttpCache::Transaction::OnIOComplete(int result) {
2868 DoLoop(result); 2882 DoLoop(result);
2869 } 2883 }
2870 2884
2871 } // namespace net 2885 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698