OLD | NEW |
---|---|
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 Loading... | |
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 // Immediately timeout and bypass the cache if we're a range request and |
1386 // we're blocked by the reader/writer lock. Doing so eliminates a long | |
1387 // running issue, http://crbug.com/31014, where two of the same media | |
1388 // resources could not be played back simultaneously due to one locking | |
1389 // the cache entry until the entire video was downloaded. | |
1390 // | |
1391 // Bypassing the cache is not ideal, as we are now ignoring the cache | |
1392 // entirely for all range requests to a resource beyond the first. This is | |
1393 // however a much more succinct solution than the alternatives, which | |
1394 // would require somewhat significant changes to the http caching logic. | |
1395 const int kTimeoutSeconds = (partial_ && new_entry_->writer && | |
rvargas (doing something else)
2014/08/22 22:19:24
nit:
int timeout_seconds = 20;
if (par
DaleCurtis
2014/08/22 22:33:03
Done.
| |
1396 new_entry_->writer->range_requested_) | |
1397 ? 0 | |
1398 : 20; | |
1386 base::MessageLoop::current()->PostDelayedTask( | 1399 base::MessageLoop::current()->PostDelayedTask( |
1387 FROM_HERE, | 1400 FROM_HERE, |
1388 base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout, | 1401 base::Bind(&HttpCache::Transaction::OnAddToEntryTimeout, |
1389 weak_factory_.GetWeakPtr(), entry_lock_waiting_since_), | 1402 weak_factory_.GetWeakPtr(), entry_lock_waiting_since_), |
1390 TimeDelta::FromSeconds(kTimeoutSeconds)); | 1403 TimeDelta::FromSeconds(kTimeoutSeconds)); |
1391 } | 1404 } |
1392 } | 1405 } |
1393 return rv; | 1406 return rv; |
1394 } | 1407 } |
1395 | 1408 |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2862 default: | 2875 default: |
2863 NOTREACHED(); | 2876 NOTREACHED(); |
2864 } | 2877 } |
2865 } | 2878 } |
2866 | 2879 |
2867 void HttpCache::Transaction::OnIOComplete(int result) { | 2880 void HttpCache::Transaction::OnIOComplete(int result) { |
2868 DoLoop(result); | 2881 DoLoop(result); |
2869 } | 2882 } |
2870 | 2883 |
2871 } // namespace net | 2884 } // namespace net |
OLD | NEW |