Chromium Code Reviews| 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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1193 return OK; | 1193 return OK; |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 int HttpCache::Transaction::DoAddToEntry() { | 1196 int HttpCache::Transaction::DoAddToEntry() { |
| 1197 DCHECK(new_entry_); | 1197 DCHECK(new_entry_); |
| 1198 cache_pending_ = true; | 1198 cache_pending_ = true; |
| 1199 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; | 1199 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; |
| 1200 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); | 1200 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); |
| 1201 DCHECK(entry_lock_waiting_since_.is_null()); | 1201 DCHECK(entry_lock_waiting_since_.is_null()); |
| 1202 entry_lock_waiting_since_ = TimeTicks::Now(); | 1202 entry_lock_waiting_since_ = TimeTicks::Now(); |
| 1203 return cache_->AddTransactionToEntry(new_entry_, this); | 1203 |
| 1204 int result = cache_->AddTransactionToEntry(new_entry_, this); | |
| 1205 | |
| 1206 // If we're a range request and we're blocked by the reader/writer lock, then | |
| 1207 // we'll switch to pass-through mode, this eliminates a long-running issue | |
| 1208 // (crbug.com/31014) where two of the same video resource could not be played | |
| 1209 // back simultaneously due to one locking the cache entry until the entire | |
| 1210 // video was downloaded. | |
| 1211 // | |
| 1212 // This is not an ideal solution, as we are now ignoring the cache entirely | |
| 1213 // for all range requests to a resource beyond the first. This is however a | |
| 1214 // much more succinct solution than the alternatives, which would require | |
| 1215 // somewhat significant changes to the http caching logic. | |
| 1216 // TODO(rileya): Support simultaneous transactions on sparse cache entries, | |
| 1217 // and remove this hack (crbug.com/362215). | |
| 1218 if (partial_ && result == net::ERR_IO_PENDING) { | |
|
rvargas (doing something else)
2014/04/22 00:44:31
Why giving up on trying to see if the lock owner i
rileya (GONE FROM CHROMIUM)
2014/04/23 17:45:05
I was thinking that we could be blocked by either
rvargas (doing something else)
2014/04/23 18:56:54
yeah, I've been going back and forth about this. I
| |
| 1219 entry_lock_waiting_since_ = TimeTicks(); | |
| 1220 net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); | |
| 1221 mode_ = NONE; | |
| 1222 partial_->RestoreHeaders(&custom_request_->extra_headers); | |
| 1223 partial_.reset(); | |
| 1224 next_state_ = STATE_SEND_REQUEST; | |
| 1225 cache_pending_ = false; | |
| 1226 new_entry_->pending_queue.pop_front(); | |
|
rvargas (doing something else)
2014/04/22 00:44:31
cache_->RemovePendingTransaction(this);
rileya (GONE FROM CHROMIUM)
2014/04/23 17:45:05
Done.
| |
| 1227 new_entry_ = entry_ = NULL; | |
|
rvargas (doing something else)
2014/04/22 00:44:31
entry_ should be NULL already.
rileya (GONE FROM CHROMIUM)
2014/04/23 17:45:05
Ahh, alright, removed setting it.
| |
| 1228 return OK; | |
| 1229 } | |
| 1230 return result; | |
| 1204 } | 1231 } |
| 1205 | 1232 |
| 1206 int HttpCache::Transaction::DoAddToEntryComplete(int result) { | 1233 int HttpCache::Transaction::DoAddToEntryComplete(int result) { |
| 1207 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, | 1234 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, |
| 1208 result); | 1235 result); |
| 1209 const TimeDelta entry_lock_wait = | 1236 const TimeDelta entry_lock_wait = |
| 1210 TimeTicks::Now() - entry_lock_waiting_since_; | 1237 TimeTicks::Now() - entry_lock_waiting_since_; |
| 1211 UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait); | 1238 UMA_HISTOGRAM_TIMES("HttpCache.EntryLockWait", entry_lock_wait); |
| 1212 | 1239 |
| 1213 entry_lock_waiting_since_ = TimeTicks(); | 1240 entry_lock_waiting_since_ = TimeTicks(); |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2520 default: | 2547 default: |
| 2521 NOTREACHED(); | 2548 NOTREACHED(); |
| 2522 } | 2549 } |
| 2523 } | 2550 } |
| 2524 | 2551 |
| 2525 void HttpCache::Transaction::OnIOComplete(int result) { | 2552 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2526 DoLoop(result); | 2553 DoLoop(result); |
| 2527 } | 2554 } |
| 2528 | 2555 |
| 2529 } // namespace net | 2556 } // namespace net |
| OLD | NEW |