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

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

Issue 113931: Remove code path that passes a file handle to the renderer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « net/disk_cache/mem_entry_impl.h ('k') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 10
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 if (cache_->mode() == PLAYBACK) 580 if (cache_->mode() == PLAYBACK)
581 effective_load_flags_ |= LOAD_ONLY_FROM_CACHE; 581 effective_load_flags_ |= LOAD_ONLY_FROM_CACHE;
582 582
583 // When in record mode, we want to NEVER load from the cache. 583 // When in record mode, we want to NEVER load from the cache.
584 // The reason for this is beacuse we save the Set-Cookie headers 584 // The reason for this is beacuse we save the Set-Cookie headers
585 // (intentionally). If we read from the cache, we replay them 585 // (intentionally). If we read from the cache, we replay them
586 // prematurely. 586 // prematurely.
587 if (cache_->mode() == RECORD) 587 if (cache_->mode() == RECORD)
588 effective_load_flags_ |= LOAD_BYPASS_CACHE; 588 effective_load_flags_ |= LOAD_BYPASS_CACHE;
589 589
590 // If HttpCache has type MEDIA make sure LOAD_ENABLE_DOWNLOAD_FILE is set,
591 // otherwise make sure LOAD_ENABLE_DOWNLOAD_FILE is not set when HttpCache
592 // has type other than MEDIA.
593 if (cache_->type() == MEDIA_CACHE) {
594 DCHECK(effective_load_flags_ & LOAD_ENABLE_DOWNLOAD_FILE);
595 } else {
596 DCHECK(!(effective_load_flags_ & LOAD_ENABLE_DOWNLOAD_FILE));
597 }
598
599 // Some headers imply load flags. The order here is significant. 590 // Some headers imply load flags. The order here is significant.
600 // 591 //
601 // LOAD_DISABLE_CACHE : no cache read or write 592 // LOAD_DISABLE_CACHE : no cache read or write
602 // LOAD_BYPASS_CACHE : no cache read 593 // LOAD_BYPASS_CACHE : no cache read
603 // LOAD_VALIDATE_CACHE : no cache read unless validation 594 // LOAD_VALIDATE_CACHE : no cache read unless validation
604 // 595 //
605 // The former modes trump latter modes, so if we find a matching header we 596 // The former modes trump latter modes, so if we find a matching header we
606 // can stop iterating kSpecialHeaders. 597 // can stop iterating kSpecialHeaders.
607 // 598 //
608 static const struct { 599 static const struct {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 770 }
780 771
781 return true; 772 return true;
782 } 773 }
783 774
784 int HttpCache::Transaction::ReadResponseInfoFromEntry() { 775 int HttpCache::Transaction::ReadResponseInfoFromEntry() {
785 DCHECK(entry_); 776 DCHECK(entry_);
786 777
787 if (!HttpCache::ReadResponseInfo(entry_->disk_entry, &response_)) 778 if (!HttpCache::ReadResponseInfo(entry_->disk_entry, &response_))
788 return ERR_CACHE_READ_FAILURE; 779 return ERR_CACHE_READ_FAILURE;
789
790 // If the cache object is used for media file, we want the file handle of
791 // response data.
792 if (cache_->type() == MEDIA_CACHE) {
793 response_.response_data_file =
794 entry_->disk_entry->GetPlatformFile(kResponseContentIndex);
795 }
796
797 return OK; 780 return OK;
798 } 781 }
799 782
800 void HttpCache::Transaction::WriteToEntry(int index, int offset, 783 void HttpCache::Transaction::WriteToEntry(int index, int offset,
801 IOBuffer* data, int data_len) { 784 IOBuffer* data, int data_len) {
802 if (!entry_) 785 if (!entry_)
803 return; 786 return;
804 787
805 int rv = entry_->disk_entry->WriteData(index, offset, data, data_len, NULL, 788 int rv = entry_->disk_entry->WriteData(index, offset, data, data_len, NULL,
806 true); 789 true);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 return; 830 return;
848 831
849 int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex); 832 int current_size = entry_->disk_entry->GetDataSize(kResponseContentIndex);
850 WriteToEntry(kResponseContentIndex, current_size, data, data_len); 833 WriteToEntry(kResponseContentIndex, current_size, data, data_len);
851 } 834 }
852 835
853 void HttpCache::Transaction::TruncateResponseData() { 836 void HttpCache::Transaction::TruncateResponseData() {
854 if (!entry_) 837 if (!entry_)
855 return; 838 return;
856 839
857 // If the cache is for media files, we try to prepare the response data
858 // file as an external file and truncate it afterwards.
859 // Recipient of ResponseInfo should judge from |response_.response_data_file|
860 // to tell whether an external file of response data is available for reading
861 // or not.
862 // TODO(hclam): we should prepare the target stream as extern file only
863 // if we get a valid response from server, i.e. 200. We don't want empty
864 // cache files for redirection or external files for erroneous requests.
865 response_.response_data_file = base::kInvalidPlatformFileValue;
866 if (cache_->type() == MEDIA_CACHE) {
867 response_.response_data_file =
868 entry_->disk_entry->UseExternalFile(kResponseContentIndex);
869 }
870
871 // Truncate the stream. 840 // Truncate the stream.
872 WriteToEntry(kResponseContentIndex, 0, NULL, 0); 841 WriteToEntry(kResponseContentIndex, 0, NULL, 0);
873 } 842 }
874 843
875 void HttpCache::Transaction::DoneWritingToEntry(bool success) { 844 void HttpCache::Transaction::DoneWritingToEntry(bool success) {
876 if (!entry_) 845 if (!entry_)
877 return; 846 return;
878 847
879 if (cache_->mode() == RECORD) 848 if (cache_->mode() == RECORD)
880 DLOG(INFO) << "Recorded: " << request_->method << request_->url 849 DLOG(INFO) << "Recorded: " << request_->method << request_->url
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 return; // have to wait 1457 return; // have to wait
1489 1458
1490 entry->pending_queue.erase(entry->pending_queue.begin()); 1459 entry->pending_queue.erase(entry->pending_queue.begin());
1491 1460
1492 AddTransactionToEntry(entry, next); 1461 AddTransactionToEntry(entry, next);
1493 } 1462 }
1494 1463
1495 //----------------------------------------------------------------------------- 1464 //-----------------------------------------------------------------------------
1496 1465
1497 } // namespace net 1466 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/mem_entry_impl.h ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698