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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 // Downgrade to UPDATE if the request has been externally conditionalized. | 836 // Downgrade to UPDATE if the request has been externally conditionalized. |
837 if (external_validation_.initialized) { | 837 if (external_validation_.initialized) { |
838 if (mode_ & WRITE) { | 838 if (mode_ & WRITE) { |
839 // Strip off the READ_DATA bit (and maybe add back a READ_META bit | 839 // Strip off the READ_DATA bit (and maybe add back a READ_META bit |
840 // in case READ was off). | 840 // in case READ was off). |
841 mode_ = UPDATE; | 841 mode_ = UPDATE; |
842 } else { | 842 } else { |
843 mode_ = NONE; | 843 mode_ = NONE; |
844 } | 844 } |
845 } | 845 } |
846 | |
847 // If we're already writing to an active entry with this key and it is | |
848 // a range request, we want to switch to pass-through mode. This | |
849 // eliminates a long-running issue (crbug.com/31014) where two of the same | |
850 // video resource could not be played back simultaneously due to one locking | |
851 // the cache entry until the entire video was downloaded. | |
852 // | |
853 // This is not an ideal solution, as we are now ignoring the cache entirely | |
854 // for all range requests to a resource beyond the first. This is however a | |
855 // much more succinct solution than the alternatives, which would require | |
856 // somewhat significant changes to the http caching logic. | |
857 // TODO(rileya): Support simultaneous transactions on sparse cache entries, | |
858 // and remove this hack. | |
scherkus (not reviewing)
2014/04/10 18:26:06
if the plan is to close the original bug, then I'd
rileya (GONE FROM CHROMIUM)
2014/04/10 19:24:51
Sounds good, filed crbug.com/362215.
| |
859 if (ActiveEntry* entry = cache_->FindActiveEntry(cache_key_)) { | |
860 if (partial_ && entry->writer && entry->writer->range_requested_) | |
861 mode_ = NONE; | |
862 } | |
846 } | 863 } |
847 | 864 |
848 // Use PUT and DELETE only to invalidate existing stored entries. | 865 // Use PUT and DELETE only to invalidate existing stored entries. |
849 if ((request_->method == "PUT" || request_->method == "DELETE") && | 866 if ((request_->method == "PUT" || request_->method == "DELETE") && |
850 mode_ != READ_WRITE && mode_ != WRITE) { | 867 mode_ != READ_WRITE && mode_ != WRITE) { |
851 mode_ = NONE; | 868 mode_ = NONE; |
852 } | 869 } |
853 | 870 |
854 // If must use cache, then we must fail. This can happen for back/forward | 871 // If must use cache, then we must fail. This can happen for back/forward |
855 // navigations to a page generated via a form post. | 872 // navigations to a page generated via a form post. |
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2520 default: | 2537 default: |
2521 NOTREACHED(); | 2538 NOTREACHED(); |
2522 } | 2539 } |
2523 } | 2540 } |
2524 | 2541 |
2525 void HttpCache::Transaction::OnIOComplete(int result) { | 2542 void HttpCache::Transaction::OnIOComplete(int result) { |
2526 DoLoop(result); | 2543 DoLoop(result); |
2527 } | 2544 } |
2528 | 2545 |
2529 } // namespace net | 2546 } // namespace net |
OLD | NEW |