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

Unified Diff: net/disk_cache/file_win.cc

Issue 8843: Add write and read/write support to FileStream (renamed from FileInputStream)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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/file_posix.cc ('k') | net/disk_cache/mapped_file_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/file_win.cc
===================================================================
--- net/disk_cache/file_win.cc (revision 4450)
+++ net/disk_cache/file_win.cc (working copy)
@@ -88,9 +88,9 @@
}
}
-File::File(OSFile file)
- : init_(true), mixed_(true), os_file_(INVALID_HANDLE_VALUE),
- sync_os_file_(file) {
+File::File(base::PlatformFile file)
+ : init_(true), mixed_(true), platform_file_(INVALID_HANDLE_VALUE),
+ sync_platform_file_(file) {
}
bool File::Init(const std::wstring& name) {
@@ -98,23 +98,23 @@
if (init_)
return false;
- os_file_ = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE,
+ platform_file_ = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, NULL);
- if (INVALID_HANDLE_VALUE == os_file_)
+ if (INVALID_HANDLE_VALUE == platform_file_)
return false;
init_ = true;
if (mixed_) {
- sync_os_file_ = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE,
+ sync_platform_file_ = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
- if (INVALID_HANDLE_VALUE == sync_os_file_)
+ if (INVALID_HANDLE_VALUE == sync_platform_file_)
return false;
} else {
- sync_os_file_ = INVALID_HANDLE_VALUE;
+ sync_platform_file_ = INVALID_HANDLE_VALUE;
}
return true;
@@ -124,22 +124,23 @@
if (!init_)
return;
- if (INVALID_HANDLE_VALUE != os_file_)
- CloseHandle(os_file_);
- if (mixed_ && INVALID_HANDLE_VALUE != sync_os_file_)
- CloseHandle(sync_os_file_);
+ if (INVALID_HANDLE_VALUE != platform_file_)
+ CloseHandle(platform_file_);
+ if (mixed_ && INVALID_HANDLE_VALUE != sync_platform_file_)
+ CloseHandle(sync_platform_file_);
}
-OSFile File::os_file() const {
+base::PlatformFile File::platform_file() const {
DCHECK(init_);
- return (INVALID_HANDLE_VALUE == os_file_) ? sync_os_file_ : os_file_;
+ return (INVALID_HANDLE_VALUE == platform_file_) ? sync_platform_file_ :
+ platform_file_;
}
bool File::IsValid() const {
if (!init_)
return false;
- return (INVALID_HANDLE_VALUE != os_file_ ||
- INVALID_HANDLE_VALUE != sync_os_file_);
+ return (INVALID_HANDLE_VALUE != platform_file_ ||
+ INVALID_HANDLE_VALUE != sync_platform_file_);
}
bool File::Read(void* buffer, size_t buffer_len, size_t offset) {
@@ -147,14 +148,16 @@
if (!mixed_ || buffer_len > ULONG_MAX || offset > LONG_MAX)
return false;
- DWORD ret = SetFilePointer(sync_os_file_, static_cast<LONG>(offset), NULL,
+ DWORD ret = SetFilePointer(sync_platform_file_,
+ static_cast<LONG>(offset),
+ NULL,
FILE_BEGIN);
if (INVALID_SET_FILE_POINTER == ret)
return false;
DWORD actual;
DWORD size = static_cast<DWORD>(buffer_len);
- if (!ReadFile(sync_os_file_, buffer, size, &actual, NULL))
+ if (!ReadFile(sync_platform_file_, buffer, size, &actual, NULL))
return false;
return actual == size;
}
@@ -164,14 +167,16 @@
if (!mixed_ || buffer_len > ULONG_MAX || offset > ULONG_MAX)
return false;
- DWORD ret = SetFilePointer(sync_os_file_, static_cast<LONG>(offset), NULL,
+ DWORD ret = SetFilePointer(sync_platform_file_,
+ static_cast<LONG>(offset),
+ NULL,
FILE_BEGIN);
if (INVALID_SET_FILE_POINTER == ret)
return false;
DWORD actual;
DWORD size = static_cast<DWORD>(buffer_len);
- if (!WriteFile(sync_os_file_, buffer, size, &actual, NULL))
+ if (!WriteFile(sync_platform_file_, buffer, size, &actual, NULL))
return false;
return actual == size;
}
@@ -196,7 +201,8 @@
DWORD size = static_cast<DWORD>(buffer_len);
AddRef();
- if (!ReadFileEx(os_file_, buffer, size, &data->overlapped, &IoCompletion)) {
+ if (!ReadFileEx(platform_file_, buffer, size, &data->overlapped,
+ &IoCompletion)) {
Release();
delete data;
return false;
@@ -260,7 +266,8 @@
DWORD size = static_cast<DWORD>(buffer_len);
AddRef();
- if (!WriteFileEx(os_file_, buffer, size, &data->overlapped, &IoCompletion)) {
+ if (!WriteFileEx(platform_file_, buffer, size, &data->overlapped,
+ &IoCompletion)) {
Release();
delete data;
return false;
@@ -295,7 +302,7 @@
return false;
DWORD size = static_cast<DWORD>(length);
- HANDLE file = os_file();
+ HANDLE file = platform_file();
if (INVALID_SET_FILE_POINTER == SetFilePointer(file, size, NULL, FILE_BEGIN))
return false;
@@ -305,7 +312,7 @@
size_t File::GetLength() {
DCHECK(init_);
LARGE_INTEGER size;
- HANDLE file = os_file();
+ HANDLE file = platform_file();
if (!GetFileSizeEx(file, &size))
return 0;
if (size.HighPart)
« no previous file with comments | « net/disk_cache/file_posix.cc ('k') | net/disk_cache/mapped_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698