summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 19:30:27 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 19:30:27 +0000
commited65fece343181e91b4d36e161434cc763475de7 (patch)
tree27af7d7cb8a12f65b24dba3ebd5ede3d592e2d8e
parent2d723bc66e60bedd617ebd464996ee2388c0c365 (diff)
downloadchromium_src-ed65fece343181e91b4d36e161434cc763475de7.zip
chromium_src-ed65fece343181e91b4d36e161434cc763475de7.tar.gz
chromium_src-ed65fece343181e91b4d36e161434cc763475de7.tar.bz2
Add an optional parameter to CreatePlatformFile() to report the type
of error that occured while trying to open/create a file. TEST=none BUG=none Review URL: http://codereview.chromium.org/3223007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58045 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/file_util.cc6
-rw-r--r--base/file_util_proxy.cc33
-rw-r--r--base/file_util_proxy.h11
-rw-r--r--base/platform_file.h22
-rw-r--r--base/platform_file_posix.cc48
-rw-r--r--base/platform_file_win.cc32
-rw-r--r--chrome/browser/renderer_host/redirect_to_file_resource_handler.cc2
-rw-r--r--chrome/browser/renderer_host/redirect_to_file_resource_handler.h2
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc2
-rw-r--r--chrome/browser/spellcheck_host.cc5
-rw-r--r--chrome/renderer/spellchecker/spellcheck_unittest.cc2
-rw-r--r--net/base/file_stream_posix.cc2
-rw-r--r--net/base/file_stream_unittest.cc5
-rw-r--r--net/base/file_stream_win.cc2
-rw-r--r--net/disk_cache/backend_impl.cc4
-rw-r--r--net/disk_cache/block_files.cc2
-rw-r--r--net/disk_cache/disk_cache_test_util.cc2
-rw-r--r--net/disk_cache/file_posix.cc2
-rw-r--r--webkit/blob/blob_url_request_job.cc15
-rw-r--r--webkit/blob/blob_url_request_job.h4
-rw-r--r--webkit/database/vfs_backend.cc4
-rw-r--r--webkit/glue/webfileutilities_impl.cc4
22 files changed, 150 insertions, 61 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index edf8e69..4dae03b 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -320,9 +320,9 @@ bool MemoryMappedFile::Initialize(const FilePath& file_name) {
}
bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
- file_ = base::CreatePlatformFile(file_name,
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
- NULL);
+ file_ = base::CreatePlatformFile(
+ file_name, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
+ NULL, NULL);
if (file_ == base::kInvalidPlatformFileValue) {
LOG(ERROR) << "Couldn't open " << file_name.value();
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index 3863b37..de16b10 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -37,11 +37,11 @@ class MessageLoopRelay
// Called to notify the callback on the origin thread.
virtual void RunCallback() = 0;
- void set_error_code(int error_code) {
+ void set_error_code(base::PlatformFileError error_code) {
error_code_ = error_code;
}
- int error_code() const {
+ base::PlatformFileError error_code() const {
return error_code_;
}
@@ -54,7 +54,7 @@ class MessageLoopRelay
}
scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
- int error_code_;
+ base::PlatformFileError error_code_;
};
class RelayCreateOrOpen : public MessageLoopRelay {
@@ -80,9 +80,10 @@ class RelayCreateOrOpen : public MessageLoopRelay {
}
virtual void RunWork() {
- file_handle_ = base::CreatePlatformFile(file_path_, file_flags_, &created_);
- if (file_handle_ == base::kInvalidPlatformFileValue)
- set_error_code(base::PLATFORM_FILE_ERROR);
+ base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
+ file_handle_ = base::CreatePlatformFile(file_path_, file_flags_,
+ &created_, &error_code);
+ set_error_code(error_code);
}
virtual void RunCallback() {
@@ -129,9 +130,10 @@ class RelayCreateTemporary : public MessageLoopRelay {
base::PLATFORM_FILE_WRITE |
base::PLATFORM_FILE_ASYNC |
base::PLATFORM_FILE_TEMPORARY;
- file_handle_ = base::CreatePlatformFile(file_path_, file_flags, NULL);
- if (file_handle_ == base::kInvalidPlatformFileValue)
- set_error_code(base::PLATFORM_FILE_ERROR);
+ base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
+ file_handle_ = base::CreatePlatformFile(file_path_, file_flags,
+ NULL, &error_code);
+ set_error_code(error_code);
}
virtual void RunCallback() {
@@ -179,7 +181,7 @@ class RelayClose : public RelayWithStatusCallback {
protected:
virtual void RunWork() {
if (!base::ClosePlatformFile(file_handle_))
- set_error_code(base::PLATFORM_FILE_ERROR);
+ set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
}
private:
@@ -199,7 +201,7 @@ class RelayDelete : public RelayWithStatusCallback {
protected:
virtual void RunWork() {
if (!file_util::Delete(file_path_, recursive_))
- set_error_code(base::PLATFORM_FILE_ERROR);
+ set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
}
private:
@@ -212,25 +214,24 @@ class RelayGetFileInfo : public MessageLoopRelay {
RelayGetFileInfo(const FilePath& file_path,
base::FileUtilProxy::GetFileInfoCallback* callback)
: callback_(callback),
- file_path_(file_path),
- exists_(false) {
+ file_path_(file_path) {
DCHECK(callback);
}
protected:
virtual void RunWork() {
- exists_ = file_util::GetFileInfo(file_path_, &file_info_);
+ if (!file_util::GetFileInfo(file_path_, &file_info_))
+ set_error_code(base::PLATFORM_FILE_ERROR_FAILED);
}
virtual void RunCallback() {
- callback_->Run(exists_, file_info_);
+ callback_->Run(error_code(), file_info_);
delete callback_;
}
private:
base::FileUtilProxy::GetFileInfoCallback* callback_;
FilePath file_path_;
- bool exists_;
file_util::FileInfo file_info_;
};
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h
index ff04e5b..9899c77 100644
--- a/base/file_util_proxy.h
+++ b/base/file_util_proxy.h
@@ -24,11 +24,13 @@ class FileUtilProxy {
// This callback is used by methods that report only an error code. It is
// valid to pass NULL as the callback parameter to any function that takes a
// StatusCallback, in which case the operation will complete silently.
- typedef Callback1<int /* error code */>::Type StatusCallback;
+ typedef Callback1<base::PlatformFileError /* error code */
+ >::Type StatusCallback;
// Creates or opens a file with the given flags. It is invalid to pass NULL
// for the callback.
- typedef Callback3<int /* error code */, base::PassPlatformFile,
+ typedef Callback3<base::PlatformFileError /* error code */,
+ base::PassPlatformFile,
bool /* created */>::Type CreateOrOpenCallback;
static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
@@ -37,7 +39,8 @@ class FileUtilProxy {
// Creates a temporary file for writing. The path and an open file handle
// are returned. It is invalid to pass NULL for the callback.
- typedef Callback3<int /* error code */, base::PassPlatformFile,
+ typedef Callback3<base::PlatformFileError /* error code */,
+ base::PassPlatformFile,
FilePath>::Type CreateTemporaryCallback;
static bool CreateTemporary(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
@@ -61,7 +64,7 @@ class FileUtilProxy {
// Retrieves the information about a file. It is invalid to pass NULL for the
// callback.
- typedef Callback2<bool /*exists*/,
+ typedef Callback2<base::PlatformFileError /* error code */,
const file_util::FileInfo& /*file_info*/
>::Type GetFileInfoCallback;
static bool GetFileInfo(
diff --git a/base/platform_file.h b/base/platform_file.h
index 0216c71..70ed0f1 100644
--- a/base/platform_file.h
+++ b/base/platform_file.h
@@ -37,22 +37,30 @@ enum PlatformFileFlags {
PLATFORM_FILE_ASYNC = 256,
PLATFORM_FILE_TEMPORARY = 512, // Used on Windows only
PLATFORM_FILE_HIDDEN = 1024, // Used on Windows only
- PLATFORM_FILE_DELETE_ON_CLOSE = 2048
+ PLATFORM_FILE_DELETE_ON_CLOSE = 2048,
+ PLATFORM_FILE_TRUNCATE = 4096
};
-// TODO(dumi): add more specific error codes for CreatePlatformFile().
-// TODO(dumi): add more error codes as we add new methods to FileUtilProxy.
-enum PlatformFileErrors {
+enum PlatformFileError {
PLATFORM_FILE_OK = 0,
- PLATFORM_FILE_ERROR = -1
+ PLATFORM_FILE_ERROR_FAILED = -1,
+ PLATFORM_FILE_ERROR_IN_USE = -2,
+ PLATFORM_FILE_ERROR_EXISTS = -3,
+ PLATFORM_FILE_ERROR_NOT_FOUND = -4,
+ PLATFORM_FILE_ERROR_ACCESS_DENIED = -5,
+ PLATFORM_FILE_ERROR_TOO_MANY_OPENED = -6,
+ PLATFORM_FILE_ERROR_NO_MEMORY = -7,
+ PLATFORM_FILE_ERROR_NO_SPACE = -7,
+ PLATFORM_FILE_ERROR_NOT_A_DIRECTORY = -9
};
// Creates or opens the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and
// |created| is provided, |created| will be set to true if the file was created
-// or to false in case the file was just opened.
+// or to false in case the file was just opened. |error_code| can be NULL.
PlatformFile CreatePlatformFile(const FilePath& name,
int flags,
- bool* created);
+ bool* created,
+ PlatformFileError* error_code);
// Deprecated.
PlatformFile CreatePlatformFile(const std::wstring& name,
int flags,
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
index 46039b9..1afb250 100644
--- a/base/platform_file_posix.cc
+++ b/base/platform_file_posix.cc
@@ -16,7 +16,7 @@ namespace base {
// TODO(erikkay): does it make sense to support PLATFORM_FILE_EXCLUSIVE_* here?
PlatformFile CreatePlatformFile(const FilePath& name, int flags,
- bool* created) {
+ bool* created, PlatformFileError* error_code) {
int open_flags = 0;
if (flags & PLATFORM_FILE_CREATE)
open_flags = O_CREAT | O_EXCL;
@@ -30,6 +30,8 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
!(flags & PLATFORM_FILE_OPEN_ALWAYS)) {
NOTREACHED();
errno = EOPNOTSUPP;
+ if (error_code)
+ *error_code = PLATFORM_FILE_ERROR_FAILED;
return kInvalidPlatformFileValue;
}
@@ -41,6 +43,11 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
NOTREACHED();
}
+ if (flags & PLATFORM_FILE_TRUNCATE) {
+ DCHECK(flags & PLATFORM_FILE_WRITE);
+ open_flags |= O_TRUNC;
+ }
+
DCHECK(O_RDONLY == 0);
int descriptor = open(name.value().c_str(), open_flags, S_IRUSR | S_IWUSR);
@@ -61,16 +68,51 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
}
}
- if ((descriptor > 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) {
+ if ((descriptor < 0) && (flags & PLATFORM_FILE_DELETE_ON_CLOSE)) {
unlink(name.value().c_str());
}
+ if ((descriptor < 0) && error_code) {
+ switch (errno) {
+ case EACCES:
+ case EISDIR:
+ case EROFS:
+ case EPERM:
+ *error_code = PLATFORM_FILE_ERROR_ACCESS_DENIED;
+ break;
+ case ETXTBSY:
+ *error_code = PLATFORM_FILE_ERROR_IN_USE;
+ break;
+ case EEXIST:
+ *error_code = PLATFORM_FILE_ERROR_EXISTS;
+ break;
+ case ENOENT:
+ *error_code = PLATFORM_FILE_ERROR_NOT_FOUND;
+ break;
+ case EMFILE:
+ *error_code = PLATFORM_FILE_ERROR_TOO_MANY_OPENED;
+ break;
+ case ENOMEM:
+ *error_code = PLATFORM_FILE_ERROR_NO_MEMORY;
+ break;
+ case ENOSPC:
+ *error_code = PLATFORM_FILE_ERROR_NO_SPACE;
+ break;
+ case ENOTDIR:
+ *error_code = PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ break;
+ default:
+ *error_code = PLATFORM_FILE_ERROR_FAILED;
+ }
+ }
+
return descriptor;
}
PlatformFile CreatePlatformFile(const std::wstring& name, int flags,
bool* created) {
- return CreatePlatformFile(FilePath::FromWStringHack(name), flags, created);
+ return CreatePlatformFile(FilePath::FromWStringHack(name), flags,
+ created, NULL);
}
bool ClosePlatformFile(PlatformFile file) {
diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc
index 1143487..c4b3c08 100644
--- a/base/platform_file_win.cc
+++ b/base/platform_file_win.cc
@@ -11,7 +11,8 @@ namespace base {
PlatformFile CreatePlatformFile(const FilePath& name,
int flags,
- bool* created) {
+ bool* created,
+ PlatformFileError* error_code) {
DWORD disposition = 0;
if (flags & PLATFORM_FILE_OPEN)
@@ -32,6 +33,12 @@ PlatformFile CreatePlatformFile(const FilePath& name,
disposition = CREATE_ALWAYS;
}
+ if (flags & PLATFORM_FILE_TRUNCATE) {
+ DCHECK(!disposition);
+ DCHECK(flags & PLATFORM_FILE_WRITE);
+ disposition = TRUNCATE_EXISTING;
+ }
+
if (!disposition) {
NOTREACHED();
return NULL;
@@ -63,12 +70,33 @@ PlatformFile CreatePlatformFile(const FilePath& name,
*created = (ERROR_ALREADY_EXISTS != GetLastError());
}
+ if ((file == kInvalidPlatformFileValue) && error_code) {
+ DWORD last_error = GetLastError();
+ switch (last_error) {
+ case ERROR_SHARING_VIOLATION:
+ *error_code = PLATFORM_FILE_ERROR_IN_USE;
+ break;
+ case ERROR_FILE_EXISTS:
+ *error_code = PLATFORM_FILE_ERROR_EXISTS;
+ break;
+ case ERROR_FILE_NOT_FOUND:
+ *error_code = PLATFORM_FILE_ERROR_NOT_FOUND;
+ break;
+ case ERROR_ACCESS_DENIED:
+ *error_code = PLATFORM_FILE_ERROR_ACCESS_DENIED;
+ break;
+ default:
+ *error_code = PLATFORM_FILE_ERROR_FAILED;
+ }
+ }
+
return file;
}
PlatformFile CreatePlatformFile(const std::wstring& name, int flags,
bool* created) {
- return CreatePlatformFile(FilePath::FromWStringHack(name), flags, created);
+ return CreatePlatformFile(FilePath::FromWStringHack(name), flags,
+ created, NULL);
}
bool ClosePlatformFile(PlatformFile file) {
diff --git a/chrome/browser/renderer_host/redirect_to_file_resource_handler.cc b/chrome/browser/renderer_host/redirect_to_file_resource_handler.cc
index cdab799..f45d2e8 100644
--- a/chrome/browser/renderer_host/redirect_to_file_resource_handler.cc
+++ b/chrome/browser/renderer_host/redirect_to_file_resource_handler.cc
@@ -153,7 +153,7 @@ RedirectToFileResourceHandler::~RedirectToFileResourceHandler() {
}
void RedirectToFileResourceHandler::DidCreateTemporaryFile(
- int /*error_code*/,
+ base::PlatformFileError /*error_code*/,
base::PassPlatformFile file_handle,
FilePath file_path) {
file_path_ = file_path;
diff --git a/chrome/browser/renderer_host/redirect_to_file_resource_handler.h b/chrome/browser/renderer_host/redirect_to_file_resource_handler.h
index 07008d84..0e82e3b 100644
--- a/chrome/browser/renderer_host/redirect_to_file_resource_handler.h
+++ b/chrome/browser/renderer_host/redirect_to_file_resource_handler.h
@@ -46,7 +46,7 @@ class RedirectToFileResourceHandler : public ResourceHandler {
private:
virtual ~RedirectToFileResourceHandler();
- void DidCreateTemporaryFile(int error_code,
+ void DidCreateTemporaryFile(base::PlatformFileError error_code,
base::PassPlatformFile file_handle,
FilePath file_path);
void DidWriteToFile(int result);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index caed317..ce3e601 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -1548,7 +1548,7 @@ void ResourceMessageFilter::OnOpenFileOnFileThread(const FilePath& path,
(mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ)
: (base::PLATFORM_FILE_CREATE_ALWAYS |
base::PLATFORM_FILE_WRITE),
- NULL);
+ NULL, NULL);
base::PlatformFile target_file_handle;
#if defined(OS_WIN)
diff --git a/chrome/browser/spellcheck_host.cc b/chrome/browser/spellcheck_host.cc
index 3c3d141..c8ab3ac 100644
--- a/chrome/browser/spellcheck_host.cc
+++ b/chrome/browser/spellcheck_host.cc
@@ -164,9 +164,10 @@ void SpellCheckHost::InitializeInternal() {
if (!observer_)
return;
- file_ = base::CreatePlatformFile(bdict_file_path_,
+ file_ = base::CreatePlatformFile(
+ bdict_file_path_,
base::PLATFORM_FILE_READ | base::PLATFORM_FILE_OPEN,
- NULL);
+ NULL, NULL);
// File didn't exist. Download it.
if (file_ == base::kInvalidPlatformFileValue && !tried_to_download_ &&
diff --git a/chrome/renderer/spellchecker/spellcheck_unittest.cc b/chrome/renderer/spellchecker/spellcheck_unittest.cc
index 2bcba27..2a55737 100644
--- a/chrome/renderer/spellchecker/spellcheck_unittest.cc
+++ b/chrome/renderer/spellchecker/spellcheck_unittest.cc
@@ -45,7 +45,7 @@ class SpellCheckTest : public testing::Test {
EXPECT_FALSE(hunspell_directory.empty());
base::PlatformFile file = base::CreatePlatformFile(
SpellCheckCommon::GetVersionedFileName(language, hunspell_directory),
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL);
+ base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, NULL, NULL);
spell_check_->Init(
file, std::vector<std::string>(), language);
}
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc
index ba91db2..d338c14 100644
--- a/net/base/file_stream_posix.cc
+++ b/net/base/file_stream_posix.cc
@@ -345,7 +345,7 @@ int FileStream::Open(const FilePath& path, int open_flags) {
}
open_flags_ = open_flags;
- file_ = base::CreatePlatformFile(path, open_flags_, NULL);
+ file_ = base::CreatePlatformFile(path, open_flags_, NULL, NULL);
if (file_ == base::kInvalidPlatformFileValue) {
LOG(WARNING) << "Failed to open file: " << errno
<< " (" << path.ToWStringHack() << ")";
diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc
index cf80699..b93d886 100644
--- a/net/base/file_stream_unittest.cc
+++ b/net/base/file_stream_unittest.cc
@@ -51,7 +51,7 @@ TEST_F(FileStreamTest, UseFileHandle) {
file_util::WriteFile(temp_file_path(), kTestData, kTestDataSize));
int flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_READ;
base::PlatformFile file = base::CreatePlatformFile(
- temp_file_path().ToWStringHack(), flags, &created);
+ temp_file_path(), flags, &created, NULL);
// Seek to the beginning of the file and read.
net::FileStream read_stream(file, flags);
@@ -66,8 +66,7 @@ TEST_F(FileStreamTest, UseFileHandle) {
// 2. Test writing with a file handle.
file_util::Delete(temp_file_path(), false);
flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE;
- file = base::CreatePlatformFile(temp_file_path().ToWStringHack(),
- flags, &created);
+ file = base::CreatePlatformFile(temp_file_path(), flags, &created, NULL);
net::FileStream write_stream(file, flags);
ASSERT_EQ(0, write_stream.Seek(net::FROM_BEGIN, 0));
diff --git a/net/base/file_stream_win.cc b/net/base/file_stream_win.cc
index 0460b3d..234ddf9 100644
--- a/net/base/file_stream_win.cc
+++ b/net/base/file_stream_win.cc
@@ -159,7 +159,7 @@ int FileStream::Open(const FilePath& path, int open_flags) {
}
open_flags_ = open_flags;
- file_ = base::CreatePlatformFile(path.value(), open_flags_, NULL);
+ file_ = base::CreatePlatformFile(path, open_flags_, NULL, NULL);
if (file_ == INVALID_HANDLE_VALUE) {
DWORD error = GetLastError();
LOG(WARNING) << "Failed to open file: " << error;
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index f518834..6b415b8 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -847,7 +847,7 @@ bool BackendImpl::CreateExternalFile(Addr* address) {
base::PLATFORM_FILE_CREATE |
base::PLATFORM_FILE_EXCLUSIVE_WRITE;
scoped_refptr<disk_cache::File> file(new disk_cache::File(
- base::CreatePlatformFile(name, flags, NULL)));
+ base::CreatePlatformFile(name, flags, NULL, NULL)));
if (!file->IsValid())
continue;
@@ -1240,7 +1240,7 @@ bool BackendImpl::InitBackingStore(bool* file_created) {
base::PLATFORM_FILE_OPEN_ALWAYS |
base::PLATFORM_FILE_EXCLUSIVE_WRITE;
scoped_refptr<disk_cache::File> file(new disk_cache::File(
- base::CreatePlatformFile(index_name, flags, file_created)));
+ base::CreatePlatformFile(index_name, flags, file_created, NULL)));
if (!file->IsValid())
return false;
diff --git a/net/disk_cache/block_files.cc b/net/disk_cache/block_files.cc
index 9f6c489..5461b7e 100644
--- a/net/disk_cache/block_files.cc
+++ b/net/disk_cache/block_files.cc
@@ -224,7 +224,7 @@ bool BlockFiles::CreateBlockFile(int index, FileType file_type, bool force) {
flags |= base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE;
scoped_refptr<File> file(new File(
- base::CreatePlatformFile(name, flags, NULL)));
+ base::CreatePlatformFile(name, flags, NULL, NULL)));
if (!file->IsValid())
return false;
diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc
index 46e33db..f84b8b2 100644
--- a/net/disk_cache/disk_cache_test_util.cc
+++ b/net/disk_cache/disk_cache_test_util.cc
@@ -65,7 +65,7 @@ bool CreateCacheTestFile(const FilePath& name) {
base::PLATFORM_FILE_WRITE;
scoped_refptr<disk_cache::File> file(new disk_cache::File(
- base::CreatePlatformFile(name, flags, NULL)));
+ base::CreatePlatformFile(name, flags, NULL, NULL)));
if (!file->IsValid())
return false;
diff --git a/net/disk_cache/file_posix.cc b/net/disk_cache/file_posix.cc
index 1d842ed..44d74e7 100644
--- a/net/disk_cache/file_posix.cc
+++ b/net/disk_cache/file_posix.cc
@@ -260,7 +260,7 @@ bool File::Init(const FilePath& name) {
int flags = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_WRITE;
- platform_file_ = base::CreatePlatformFile(name, flags, NULL);
+ platform_file_ = base::CreatePlatformFile(name, flags, NULL, NULL);
if (platform_file_ < 0) {
platform_file_ = 0;
return false;
diff --git a/webkit/blob/blob_url_request_job.cc b/webkit/blob/blob_url_request_job.cc
index ef2fcc6..5103458 100644
--- a/webkit/blob/blob_url_request_job.cc
+++ b/webkit/blob/blob_url_request_job.cc
@@ -106,19 +106,24 @@ void BlobURLRequestJob::ResolveFile(const FilePath& file_path) {
// Continue asynchronously.
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &BlobURLRequestJob::DidResolve, exists, file_info));
+ this, &BlobURLRequestJob::DidResolve,
+ (exists ? base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_NOT_FOUND),
+ file_info));
}
-void BlobURLRequestJob::DidResolve(
- bool exists, const file_util::FileInfo& file_info) {
+void BlobURLRequestJob::DidResolve(base::PlatformFileError rv,
+ const file_util::FileInfo& file_info) {
// We may have been orphaned...
if (!request_)
return;
- // If the file does not exist, bail out.
- if (!exists) {
+ // If an error occured, bail out.
+ if (rv == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
NotifyFailure(net::ERR_FILE_NOT_FOUND);
return;
+ } else if (rv != base::PLATFORM_FILE_OK) {
+ NotifyFailure(net::ERR_FAILED);
+ return;
}
// Validate the expected modification time.
diff --git a/webkit/blob/blob_url_request_job.h b/webkit/blob/blob_url_request_job.h
index 9d24839..5445774 100644
--- a/webkit/blob/blob_url_request_job.h
+++ b/webkit/blob/blob_url_request_job.h
@@ -5,6 +5,7 @@
#ifndef WEBKIT_BLOB_BLOB_URL_REQUEST_JOB_H_
#define WEBKIT_BLOB_BLOB_URL_REQUEST_JOB_H_
+#include "base/platform_file.h"
#include "base/ref_counted.h"
#include "base/scoped_callback_factory.h"
#include "base/scoped_ptr.h"
@@ -56,7 +57,8 @@ class BlobURLRequestJob : public URLRequestJob {
void NotifySuccess();
void NotifyFailure(int);
- void DidResolve(bool exists, const file_util::FileInfo& file_info);
+ void DidResolve(base::PlatformFileError rv,
+ const file_util::FileInfo& file_info);
void DidRead(int result);
base::ScopedCallbackFactory<BlobURLRequestJob> callback_factory_;
diff --git a/webkit/database/vfs_backend.cc b/webkit/database/vfs_backend.cc
index 6e54f1b..e734a7e 100644
--- a/webkit/database/vfs_backend.cc
+++ b/webkit/database/vfs_backend.cc
@@ -129,7 +129,7 @@ void VfsBackend::OpenFile(const FilePath& file_path,
// Try to open/create the DB file.
*file_handle =
- base::CreatePlatformFile(file_path.ToWStringHack(), flags, NULL);
+ base::CreatePlatformFile(file_path, flags, NULL, NULL);
}
// static
@@ -163,7 +163,7 @@ int VfsBackend::DeleteFile(const FilePath& file_path, bool sync_dir) {
#if defined(OS_POSIX)
if (sync_dir) {
base::PlatformFile dir_fd = base::CreatePlatformFile(
- file_path.DirName().ToWStringHack(), base::PLATFORM_FILE_READ, NULL);
+ file_path.DirName(), base::PLATFORM_FILE_READ, NULL, NULL);
if (dir_fd == base::kInvalidPlatformFileValue) {
error_code = SQLITE_CANTOPEN;
} else {
diff --git a/webkit/glue/webfileutilities_impl.cc b/webkit/glue/webfileutilities_impl.cc
index 9764145..a5b8fcc 100644
--- a/webkit/glue/webfileutilities_impl.cc
+++ b/webkit/glue/webfileutilities_impl.cc
@@ -107,8 +107,8 @@ base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path,
WebStringToFilePath(path),
(mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ)
: (base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_WRITE),
- NULL);
+ base::PLATFORM_FILE_WRITE),
+ NULL, NULL);
}
void WebFileUtilitiesImpl::closeFile(base::PlatformFile& handle) {