diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-21 00:47:09 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-21 00:47:09 +0000 |
commit | 4f08aaff2139d917b49acb6b019a7c5c217a95bb (patch) | |
tree | fef503c76a70de80dd2deb1f4c0b80daabe5d3d1 /net/disk_cache/disk_cache_test_util.cc | |
parent | 617e074ea15cb8c7378ce0eded572c39735223a6 (diff) | |
download | chromium_src-4f08aaff2139d917b49acb6b019a7c5c217a95bb.zip chromium_src-4f08aaff2139d917b49acb6b019a7c5c217a95bb.tar.gz chromium_src-4f08aaff2139d917b49acb6b019a7c5c217a95bb.tar.bz2 |
Make the disk cache unit tests use some common code from the disk cache.
In particular, this removes the last piece of code on the disk cache that
uses SHFileOperation.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/disk_cache_test_util.cc')
-rw-r--r-- | net/disk_cache/disk_cache_test_util.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc index 5ad5d9e..f2cbaa5 100644 --- a/net/disk_cache/disk_cache_test_util.cc +++ b/net/disk_cache/disk_cache_test_util.cc @@ -31,8 +31,9 @@ #include "base/file_util.h" #include "base/path_service.h" -#include "base/scoped_handle.h" #include "net/disk_cache/backend_impl.h" +#include "net/disk_cache/cache_util.h" +#include "net/disk_cache/file.h" std::string GenerateKey(bool same_length) { char key[200]; @@ -70,21 +71,21 @@ std::wstring GetCachePath() { } bool CreateCacheTestFile(const wchar_t* name) { - ScopedHandle file(CreateFile(name, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - CREATE_ALWAYS, 0, NULL)); - if (!file.IsValid()) + using namespace disk_cache; + int flags = OS_FILE_CREATE_ALWAYS | OS_FILE_READ | OS_FILE_WRITE | + OS_FILE_SHARE_READ | OS_FILE_SHARE_WRITE; + + scoped_refptr<File> file(new File(CreateOSFile(name, flags, NULL))); + if (!file->IsValid()) return false; - SetFilePointer(file, 4 * 1024 * 1024, 0, FILE_BEGIN); - SetEndOfFile(file); + file->SetLength(4 * 1024 * 1024); return true; } bool DeleteCache(const wchar_t* path) { - std::wstring my_path(path); - file_util::AppendToPath(&my_path, L"*.*"); - return file_util::Delete(my_path, false); + disk_cache::DeleteCache(path, false); + return true; } bool CheckCacheIntegrity(const std::wstring& path) { |