summaryrefslogtreecommitdiffstats
path: root/base/platform_file_win.cc
diff options
context:
space:
mode:
authorpaivanof@gmail.com <paivanof@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-06 00:29:51 +0000
committerpaivanof@gmail.com <paivanof@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-06 00:29:51 +0000
commitaab1b9ead19f21af4f752c4a52beed65009d96fb (patch)
tree3679bc3c3bd80678a9fb2ab383aa6834679506d0 /base/platform_file_win.cc
parent25524c044d4aefd6902d4245b66980c46669e145 (diff)
downloadchromium_src-aab1b9ead19f21af4f752c4a52beed65009d96fb.zip
chromium_src-aab1b9ead19f21af4f752c4a52beed65009d96fb.tar.gz
chromium_src-aab1b9ead19f21af4f752c4a52beed65009d96fb.tar.bz2
net: Implement canceling of all async operations in FileStream.
Canceling of async operations allows to not wait for their completion in FileStream's destructor. Other related changes include: - Got rid of FileStream::Close() and FileStream::CloseSync() methods because reuse of FileStream object doesn't make much sense, it should be destroyed instead. - Changed FileStream to always acquire ownership of the PlatformFile it was given. Fixed usages of FileStream where no ownership was assumed, introduced new helper functions in base/platform_file.h on the way. - FileStream's destructor now always closes the file. If file was opened with PLATFORM_FILE_ASYNC then actual closing is done asynchronously, destructor doesn't wait for that and returns immediately. When file was opened without PLATFORM_FILE_ASYNC closing is done synchronously and the thread doing that should be allowed to do IO operations. - Implementation of FileStream is refactored. FileStream is now just a wrapper around internal object that does all actual work and that can be easily orphaned in the destructor to not block on the actual file descriptor closing. All platform-independent code is extracted into a special file and amount of platform-dependent code is minimized. BUG=115067, 112474 TEST=net_unittests Review URL: https://chromiumcodereview.appspot.com/10701050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/platform_file_win.cc')
-rw-r--r--base/platform_file_win.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc
index b7861e6..92f1c1f 100644
--- a/base/platform_file_win.cc
+++ b/base/platform_file_win.cc
@@ -115,6 +115,21 @@ bool ClosePlatformFile(PlatformFile file) {
return (CloseHandle(file) != 0);
}
+int64 SeekPlatformFile(PlatformFile file,
+ PlatformFileWhence whence,
+ int64 offset) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (file < 0 || offset < 0)
+ return -1;
+
+ LARGE_INTEGER distance, res;
+ distance.QuadPart = offset;
+ DWORD move_method = static_cast<DWORD>(whence);
+ if (!SetFilePointerEx(file, distance, &res, move_method))
+ return -1;
+ return res.QuadPart;
+}
+
int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
if (file == kInvalidPlatformFileValue)
@@ -145,6 +160,11 @@ int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset, char* data,
return ReadPlatformFile(file, offset, data, size);
}
+int ReadPlatformFileCurPosNoBestEffort(PlatformFile file,
+ char* data, int size) {
+ return ReadPlatformFile(file, 0, data, size);
+}
+
int WritePlatformFile(PlatformFile file, int64 offset,
const char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
@@ -170,6 +190,11 @@ int WritePlatformFileAtCurrentPos(PlatformFile file, const char* data,
return WritePlatformFile(file, 0, data, size);
}
+int WritePlatformFileCurPosNoBestEffort(PlatformFile file,
+ const char* data, int size) {
+ return WritePlatformFile(file, 0, data, size);
+}
+
bool TruncatePlatformFile(PlatformFile file, int64 length) {
base::ThreadRestrictions::AssertIOAllowed();
if (file == kInvalidPlatformFileValue)