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

Unified Diff: net/http/http_cache_unittest.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, 7 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/http/http_cache.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
===================================================================
--- net/http/http_cache_unittest.cc (revision 17048)
+++ net/http/http_cache_unittest.cc (working copy)
@@ -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 @@
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 @@
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 @@
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 @@
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);
- }
-}
« no previous file with comments | « net/http/http_cache.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698