if (!async_in_progress_) {
CloseAndDelete();
} else if (file_.IsValid()) {
+#if defined(OS_WIN)
CancelIo(file_.GetPlatformFile());
+#endif
}
}
-void FileStream::Context::OpenAsync(const base::FilePath& path,
- int open_flags,
- const CompletionCallback& callback) {
+void FileStream::Context::Open(const base::FilePath& path,
+ int open_flags,
+ const CompletionCallback& callback) {
DCHECK(!async_in_progress_);
bool posted = base::PostTaskAndReplyWithResult(
async_in_progress_ = true;
}
-void FileStream::Context::CloseAsync(const CompletionCallback& callback) {
+void FileStream::Context::Close(const CompletionCallback& callback) {
DCHECK(!async_in_progress_);
bool posted = base::PostTaskAndReplyWithResult(
task_runner_.get(),
async_in_progress_ = true;
}
-void FileStream::Context::SeekAsync(Whence whence,
- int64 offset,
- const Int64CompletionCallback& callback) {
+void FileStream::Context::Seek(base::File::Whence whence,
+ int64 offset,
+ const Int64CompletionCallback& callback) {
DCHECK(!async_in_progress_);
bool posted = base::PostTaskAndReplyWithResult(
async_in_progress_ = true;
}
-void FileStream::Context::FlushAsync(const CompletionCallback& callback) {
+void FileStream::Context::Flush(const CompletionCallback& callback) {
DCHECK(!async_in_progress_);
bool posted = base::PostTaskAndReplyWithResult(
}
#endif // defined(OS_ANDROID)
if (!file.IsValid())
- return OpenResult(base::File(), IOResult::FromOSError(GetLastErrno()));
+ return OpenResult(base::File(),
+ IOResult::FromOSError(logging::GetLastSystemErrorCode()));
return OpenResult(file.Pass(), IOResult(OK, 0));
}
return IOResult(OK, 0);
}
+FileStream::Context::IOResult FileStream::Context::FlushFileImpl() {
+ if (file_.Flush())
+ return IOResult(OK, 0);
+
+ return IOResult::FromOSError(logging::GetLastSystemErrorCode());
+}
+
void FileStream::Context::OnOpenCompleted(const CompletionCallback& callback,
OpenResult open_result) {
file_ = open_result.file.Pass();
if (file_.IsValid() && !orphaned_)
- OnAsyncFileOpened();
+ OnFileOpened();
OnAsyncCompleted(IntToInt64(callback), open_result.error_code);
}
const Int64CompletionCallback& callback,
const IOResult& result) {
// Reset this before Run() as Run() may issue a new async operation. Also it
- // should be reset before CloseAsync() because it shouldn't run if any async
+ // should be reset before Close() because it shouldn't run if any async
// operation is in progress.
async_in_progress_ = false;
if (orphaned_)