From 20d064e9c08f1d421d66b2955f3230a43c840d77 Mon Sep 17 00:00:00 2001 From: "hashimoto@chromium.org" Date: Mon, 24 Mar 2014 10:02:09 +0000 Subject: Stop using net::FileStream synchronously in native_file_util.cc Use base::File instead. BUG=351823 TEST=content_unittests Review URL: https://codereview.chromium.org/196103012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258903 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/browser/fileapi/native_file_util.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'webkit/browser') diff --git a/webkit/browser/fileapi/native_file_util.cc b/webkit/browser/fileapi/native_file_util.cc index e99e297..8f4560b 100644 --- a/webkit/browser/fileapi/native_file_util.cc +++ b/webkit/browser/fileapi/native_file_util.cc @@ -5,9 +5,9 @@ #include "webkit/browser/fileapi/native_file_util.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_enumerator.h" #include "base/memory/scoped_ptr.h" -#include "net/base/file_stream.h" #include "webkit/browser/fileapi/file_system_operation_context.h" #include "webkit/browser/fileapi/file_system_url.h" @@ -37,15 +37,14 @@ bool SetPlatformSpecificDirectoryPermissions(const base::FilePath& dir_path) { // Copies a file |from| to |to|, and ensure the written content is synced to // the disk. This is essentially base::CopyFile followed by fsync(). bool CopyFileAndSync(const base::FilePath& from, const base::FilePath& to) { - net::FileStream infile(NULL); - if (infile.OpenSync(from, - base::PLATFORM_FILE_OPEN | base:: PLATFORM_FILE_READ) < 0) { + base::File infile(from, base::File::FLAG_OPEN | base::File::FLAG_READ); + if (!infile.IsValid()) { return false; } - net::FileStream outfile(NULL); - if (outfile.OpenSync(to, - base::PLATFORM_FILE_CREATE_ALWAYS | base:: PLATFORM_FILE_WRITE) < 0) { + base::File outfile(to, + base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); + if (!outfile.IsValid()) { return false; } @@ -53,21 +52,21 @@ bool CopyFileAndSync(const base::FilePath& from, const base::FilePath& to) { std::vector buffer(kBufferSize); for (;;) { - int bytes_read = infile.ReadSync(&buffer[0], kBufferSize); + int bytes_read = infile.ReadAtCurrentPos(&buffer[0], kBufferSize); if (bytes_read < 0) return false; if (bytes_read == 0) break; for (int bytes_written = 0; bytes_written < bytes_read; ) { - int bytes_written_partial = outfile.WriteSync(&buffer[bytes_written], - bytes_read - bytes_written); + int bytes_written_partial = outfile.WriteAtCurrentPos( + &buffer[bytes_written], bytes_read - bytes_written); if (bytes_written_partial < 0) return false; bytes_written += bytes_written_partial; } } - return outfile.FlushSync() >= 0; + return outfile.Flush(); } } // namespace -- cgit v1.1