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

Unified Diff: base/platform_file_posix.cc

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Index: base/platform_file_posix.cc
===================================================================
--- base/platform_file_posix.cc (revision 147715)
+++ base/platform_file_posix.cc (working copy)
@@ -21,6 +21,11 @@
namespace base {
+// Make sure our Whence mappings match the system headers.
+COMPILE_ASSERT(PLATFORM_FILE_FROM_BEGIN == SEEK_SET &&
+ PLATFORM_FILE_FROM_CURRENT == SEEK_CUR &&
+ PLATFORM_FILE_FROM_END == SEEK_END, whence_matches_system);
+
#if defined(OS_BSD) || defined(OS_MACOSX)
typedef struct stat stat_wrapper_t;
static int CallFstat(int fd, stat_wrapper_t *sb) {
@@ -158,6 +163,16 @@
return !HANDLE_EINTR(close(file));
}
+int64 SeekPlatformFile(PlatformFile file,
+ PlatformFileWhence whence,
+ int64 offset) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (file < 0 || offset < 0)
+ return -1;
+
+ return lseek(file, static_cast<off_t>(offset), static_cast<int>(whence));
+}
+
int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
if (file < 0 || size < 0)
@@ -204,6 +219,15 @@
return HANDLE_EINTR(pread(file, data, size, offset));
}
+int ReadPlatformFileCurPosNoBestEffort(PlatformFile file,
+ char* data, int size) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (file < 0 || size < 0)
+ return -1;
+
+ return HANDLE_EINTR(read(file, data, size));
+}
+
int WritePlatformFile(PlatformFile file, int64 offset,
const char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
@@ -243,6 +267,15 @@
return bytes_written ? bytes_written : rv;
}
+int WritePlatformFileCurPosNoBestEffort(PlatformFile file,
+ const char* data, int size) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (file < 0 || size < 0)
+ return -1;
+
+ return HANDLE_EINTR(write(file, data, size));
+}
+
bool TruncatePlatformFile(PlatformFile file, int64 length) {
base::ThreadRestrictions::AssertIOAllowed();
return ((file >= 0) && !HANDLE_EINTR(ftruncate(file, length)));
« no previous file with comments | « base/platform_file.h ('k') | base/platform_file_win.cc » ('j') | net/base/file_stream.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698