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

Unified Diff: net/http/http_cache.cc

Issue 27168: IPC messages and changes to ResourceLoaderBridge to support resource loading for media (Closed)
Patch Set: add mac/linux build and fixed unit test failures Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache.cc
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 75f02568654d3773be4893eaadd312b2d6839f7f..8637f2df221f72a5dff762d02462e01349935990 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -7,6 +7,11 @@
#include <algorithm>
#include "base/compiler_specific.h"
+
+#if defined(OS_POSIX)
+#include <unistd.h>
+#endif
+
#include "base/message_loop.h"
#include "base/pickle.h"
#include "base/ref_counted.h"
@@ -607,6 +612,15 @@ void HttpCache::Transaction::SetRequest(const HttpRequestInfo* request) {
if (cache_->mode() == RECORD)
effective_load_flags_ |= LOAD_BYPASS_CACHE;
+ // If HttpCache has type MEDIA make sure LOAD_ENABLE_DOWNLOAD_FILE is set,
+ // otherwise make sure LOAD_ENABLE_DOWNLOAD_FILE is not set when HttpCache
+ // has type other than MEDIA.
+ if (cache_->type() == HttpCache::MEDIA) {
+ DCHECK(effective_load_flags_ & LOAD_ENABLE_DOWNLOAD_FILE);
+ } else {
+ DCHECK(!(effective_load_flags_ & LOAD_ENABLE_DOWNLOAD_FILE));
+ }
+
// Some headers imply load flags. The order here is significant.
//
// LOAD_DISABLE_CACHE : no cache read or write
@@ -796,9 +810,10 @@ int HttpCache::Transaction::ReadResponseInfoFromEntry() {
// If the cache object is used for media file, we want the file handle of
// response data.
- if (cache_->type() == HttpCache::MEDIA)
+ if (cache_->type() == HttpCache::MEDIA) {
response_.response_data_file =
entry_->disk_entry->GetPlatformFile(kResponseContentIndex);
+ }
return OK;
}
@@ -869,9 +884,10 @@ void HttpCache::Transaction::TruncateResponseData() {
// if we get a valid response from server, i.e. 200. We don't want empty
// cache files for redirection or external files for erroneous requests.
response_.response_data_file = base::kInvalidPlatformFileValue;
- if (cache_->type() == HttpCache::MEDIA)
+ if (cache_->type() == HttpCache::MEDIA) {
response_.response_data_file =
entry_->disk_entry->UseExternalFile(kResponseContentIndex);
+ }
// Truncate the stream.
WriteToEntry(kResponseContentIndex, 0, NULL, 0);
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698