diff options
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_cache.cc | 31 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 98 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 2 | ||||
-rw-r--r-- | net/http/http_response_info.cc | 2 | ||||
-rw-r--r-- | net/http/http_response_info.h | 5 |
5 files changed, 3 insertions, 135 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 1beb36f..48178a6 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -587,15 +587,6 @@ 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() == MEDIA_CACHE) { - 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 @@ -786,14 +777,6 @@ int HttpCache::Transaction::ReadResponseInfoFromEntry() { if (!HttpCache::ReadResponseInfo(entry_->disk_entry, &response_)) return ERR_CACHE_READ_FAILURE; - - // If the cache object is used for media file, we want the file handle of - // response data. - if (cache_->type() == MEDIA_CACHE) { - response_.response_data_file = - entry_->disk_entry->GetPlatformFile(kResponseContentIndex); - } - return OK; } @@ -854,20 +837,6 @@ void HttpCache::Transaction::TruncateResponseData() { if (!entry_) return; - // If the cache is for media files, we try to prepare the response data - // file as an external file and truncate it afterwards. - // Recipient of ResponseInfo should judge from |response_.response_data_file| - // to tell whether an external file of response data is available for reading - // or not. - // TODO(hclam): we should prepare the target stream as extern file only - // 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() == MEDIA_CACHE) { - response_.response_data_file = - entry_->disk_entry->UseExternalFile(kResponseContentIndex); - } - // Truncate the stream. WriteToEntry(kResponseContentIndex, 0, NULL, 0); } diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 7f84a36..ef127a2 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -6,7 +6,6 @@ #include "base/hash_tables.h" #include "base/message_loop.h" -#include "base/platform_file.h" #include "base/string_util.h" #include "net/base/net_errors.h" #include "net/base/load_flags.h" @@ -28,11 +27,11 @@ class MockDiskEntry : public disk_cache::Entry, public base::RefCounted<MockDiskEntry> { public: MockDiskEntry() - : test_mode_(0), doomed_(false), platform_file_(global_platform_file_) { + : test_mode_(0), doomed_(false) { } MockDiskEntry(const std::string& key) - : key_(key), doomed_(false), platform_file_(global_platform_file_) { + : key_(key), doomed_(false) { // // 'key' is prefixed with an identifier if it corresponds to a cached POST. // Skip past that to locate the actual URL. @@ -117,18 +116,6 @@ class MockDiskEntry : public disk_cache::Entry, return buf_len; } - base::PlatformFile UseExternalFile(int index) { - return platform_file_; - } - - base::PlatformFile GetPlatformFile(int index) { - return platform_file_; - } - - static void set_global_platform_file(base::PlatformFile platform_file) { - global_platform_file_ = platform_file; - } - private: // Unlike the callbacks for MockHttpTransaction, we want this one to run even // if the consumer called Close on the MockDiskEntry. We achieve that by @@ -145,13 +132,8 @@ class MockDiskEntry : public disk_cache::Entry, std::vector<char> data_[2]; int test_mode_; bool doomed_; - base::PlatformFile platform_file_; - static base::PlatformFile global_platform_file_; }; -base::PlatformFile MockDiskEntry::global_platform_file_ = - base::kInvalidPlatformFileValue; - class MockDiskCache : public disk_cache::Backend { public: MockDiskCache() : open_count_(0), create_count_(0), fail_requests_(0) { @@ -1257,79 +1239,3 @@ TEST(HttpCache, OutlivedTransactions) { delete cache; delete trans; } - -// Make sure Entry::UseExternalFile is called when a new entry is created in -// a HttpCache with MEDIA type. Also make sure Entry::GetPlatformFile is called -// when an entry is loaded from a HttpCache with MEDIA type. Also confirm we -// will receive a file handle in ResponseInfo from a media cache. -TEST(HttpCache, SimpleGET_MediaCache) { - // Initialize the HttpCache with MEDIA_CACHE type. - MockHttpCache cache; - cache.http_cache()->set_type(net::MEDIA_CACHE); - - // Define some fake file handles for testing. - base::PlatformFile kFakePlatformFile1, kFakePlatformFile2; -#if defined(OS_WIN) - kFakePlatformFile1 = reinterpret_cast<base::PlatformFile>(1); - kFakePlatformFile2 = reinterpret_cast<base::PlatformFile>(2); -#else - kFakePlatformFile1 = 1; - kFakePlatformFile2 = 2; -#endif - - ScopedMockTransaction trans_info(kSimpleGET_Transaction); - trans_info.load_flags |= net::LOAD_ENABLE_DOWNLOAD_FILE; - TestCompletionCallback callback; - - { - // Set the fake file handle to MockDiskEntry so cache is written with an - // entry created with our fake file handle. - MockDiskEntry::set_global_platform_file(kFakePlatformFile1); - - scoped_ptr<net::HttpTransaction> trans( - cache.http_cache()->CreateTransaction()); - ASSERT_TRUE(trans.get()); - - MockHttpRequest request(trans_info); - - int rv = trans->Start(&request, &callback); - if (rv == net::ERR_IO_PENDING) - rv = callback.WaitForResult(); - ASSERT_EQ(net::OK, rv); - - const net::HttpResponseInfo* response = trans->GetResponseInfo(); - ASSERT_TRUE(response); - - ASSERT_EQ(kFakePlatformFile1, response->response_data_file); - - ReadAndVerifyTransaction(trans.get(), trans_info); - } - - // Load only from cache so we would get the same file handle. - trans_info.load_flags |= net::LOAD_ONLY_FROM_CACHE; - - { - // Set a different file handle value to MockDiskEntry so any new entry - // created in the cache won't have the same file handle value. - MockDiskEntry::set_global_platform_file(kFakePlatformFile2); - - scoped_ptr<net::HttpTransaction> trans( - cache.http_cache()->CreateTransaction()); - ASSERT_TRUE(trans.get()); - - MockHttpRequest request(trans_info); - - int rv = trans->Start(&request, &callback); - if (rv == net::ERR_IO_PENDING) - rv = callback.WaitForResult(); - ASSERT_EQ(net::OK, rv); - - const net::HttpResponseInfo* response = trans->GetResponseInfo(); - ASSERT_TRUE(response); - - // Make sure we get the same file handle as in the first request. - ASSERT_EQ(kFakePlatformFile1, response->response_data_file); - - ReadAndVerifyTransaction(trans.get(), trans_info); - } -} diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 0dcb91e..c8435d2f 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -2598,8 +2598,6 @@ TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) { EXPECT_EQ(NULL, trans->response_.auth_challenge.get()); EXPECT_EQ(NULL, trans->response_.headers.get()); EXPECT_EQ(false, trans->response_.was_cached); - EXPECT_EQ(base::kInvalidPlatformFileValue, - trans->response_.response_data_file); EXPECT_EQ(0, trans->response_.ssl_info.cert_status); EXPECT_FALSE(trans->response_.vary_data.is_valid()); } diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc index a94aa91..bc2fbe3 100644 --- a/net/http/http_response_info.cc +++ b/net/http/http_response_info.cc @@ -8,7 +8,7 @@ namespace net { HttpResponseInfo::HttpResponseInfo() - : was_cached(false), response_data_file(base::kInvalidPlatformFileValue) { + : was_cached(false) { } HttpResponseInfo::~HttpResponseInfo() { diff --git a/net/http/http_response_info.h b/net/http/http_response_info.h index d2803d1..88f89e7 100644 --- a/net/http/http_response_info.h +++ b/net/http/http_response_info.h @@ -5,7 +5,6 @@ #ifndef NET_HTTP_HTTP_RESPONSE_INFO_H_ #define NET_HTTP_HTTP_RESPONSE_INFO_H_ -#include "base/platform_file.h" #include "base/time.h" #include "net/base/auth.h" #include "net/base/ssl_info.h" @@ -50,10 +49,6 @@ class HttpResponseInfo { // The "Vary" header data for this response. HttpVaryData vary_data; - - // Platform specific file handle to the response data, if response data is - // not in a standalone file, its value is base::kInvalidPlatformFileValue. - base::PlatformFile response_data_file; }; } // namespace net |