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

Unified Diff: webkit/fileapi/sandboxed_file_system_operation.cc

Issue 4821005: Make FileSystemOperation's lifetime more explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simple_file_writer fix Created 10 years, 1 month 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
« no previous file with comments | « webkit/fileapi/sandboxed_file_system_operation.h ('k') | webkit/tools/test_shell/simple_file_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/sandboxed_file_system_operation.cc
diff --git a/webkit/fileapi/sandboxed_file_system_operation.cc b/webkit/fileapi/sandboxed_file_system_operation.cc
index dfc2884f677e1745c9fd9dda54de14dfa5d02c4f..7f9dd38db0a30ce4438482056a940fe12a57a49b 100644
--- a/webkit/fileapi/sandboxed_file_system_operation.cc
+++ b/webkit/fileapi/sandboxed_file_system_operation.cc
@@ -38,15 +38,19 @@ void SandboxedFileSystemOperation::OpenFileSystem(
void SandboxedFileSystemOperation::CreateFile(
const FilePath& path, bool exclusive) {
- if (!VerifyFileSystemPathForWrite(path, true /* create */, 0))
+ if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) {
+ delete this;
return;
+ }
FileSystemOperation::CreateFile(path, exclusive);
}
void SandboxedFileSystemOperation::CreateDirectory(
const FilePath& path, bool exclusive, bool recursive) {
- if (!VerifyFileSystemPathForWrite(path, true /* create */, 0))
+ if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) {
+ delete this;
return;
+ }
FileSystemOperation::CreateDirectory(path, exclusive, recursive);
}
@@ -54,8 +58,10 @@ void SandboxedFileSystemOperation::Copy(
const FilePath& src_path, const FilePath& dest_path) {
if (!VerifyFileSystemPathForRead(src_path) ||
!VerifyFileSystemPathForWrite(dest_path, true /* create */,
- FileSystemQuotaManager::kUnknownSize))
+ FileSystemQuotaManager::kUnknownSize)) {
+ delete this;
return;
+ }
FileSystemOperation::Copy(src_path, dest_path);
}
@@ -63,39 +69,51 @@ void SandboxedFileSystemOperation::Move(
const FilePath& src_path, const FilePath& dest_path) {
if (!VerifyFileSystemPathForRead(src_path) ||
!VerifyFileSystemPathForWrite(dest_path, true /* create */,
- FileSystemQuotaManager::kUnknownSize))
+ FileSystemQuotaManager::kUnknownSize)) {
+ delete this;
return;
+ }
FileSystemOperation::Move(src_path, dest_path);
}
void SandboxedFileSystemOperation::DirectoryExists(const FilePath& path) {
- if (!VerifyFileSystemPathForRead(path))
+ if (!VerifyFileSystemPathForRead(path)) {
+ delete this;
return;
+ }
FileSystemOperation::DirectoryExists(path);
}
void SandboxedFileSystemOperation::FileExists(const FilePath& path) {
- if (!VerifyFileSystemPathForRead(path))
+ if (!VerifyFileSystemPathForRead(path)) {
+ delete this;
return;
+ }
FileSystemOperation::FileExists(path);
}
void SandboxedFileSystemOperation::GetMetadata(const FilePath& path) {
- if (!VerifyFileSystemPathForRead(path))
+ if (!VerifyFileSystemPathForRead(path)) {
+ delete this;
return;
+ }
FileSystemOperation::GetMetadata(path);
}
void SandboxedFileSystemOperation::ReadDirectory(const FilePath& path) {
- if (!VerifyFileSystemPathForRead(path))
+ if (!VerifyFileSystemPathForRead(path)) {
+ delete this;
return;
+ }
FileSystemOperation::ReadDirectory(path);
}
void SandboxedFileSystemOperation::Remove(
const FilePath& path, bool recursive) {
- if (!VerifyFileSystemPathForWrite(path, false /* create */, 0))
+ if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) {
+ delete this;
return;
+ }
FileSystemOperation::Remove(path, recursive);
}
@@ -103,15 +121,19 @@ void SandboxedFileSystemOperation::Write(
scoped_refptr<URLRequestContext> url_request_context,
const FilePath& path, const GURL& blob_url, int64 offset) {
if (!VerifyFileSystemPathForWrite(path, true /* create */,
- FileSystemQuotaManager::kUnknownSize))
+ FileSystemQuotaManager::kUnknownSize)) {
+ delete this;
return;
+ }
FileSystemOperation::Write(url_request_context, path, blob_url, offset);
}
void SandboxedFileSystemOperation::Truncate(
const FilePath& path, int64 length) {
- if (!VerifyFileSystemPathForWrite(path, false /* create */, 0))
+ if (!VerifyFileSystemPathForWrite(path, false /* create */, 0)) {
+ delete this;
return;
+ }
FileSystemOperation::Truncate(path, length);
}
@@ -119,8 +141,10 @@ void SandboxedFileSystemOperation::TouchFile(
const FilePath& path,
const base::Time& last_access_time,
const base::Time& last_modified_time) {
- if (!VerifyFileSystemPathForWrite(path, true /* create */, 0))
+ if (!VerifyFileSystemPathForWrite(path, true /* create */, 0)) {
+ delete this;
return;
+ }
FileSystemOperation::TouchFile(path, last_access_time, last_modified_time);
}
@@ -128,6 +152,7 @@ void SandboxedFileSystemOperation::DidGetRootPath(
bool success, const FilePath& path, const std::string& name) {
DCHECK(success || path.empty());
dispatcher()->DidOpenFileSystem(name, path);
+ delete this;
}
bool SandboxedFileSystemOperation::VerifyFileSystemPathForRead(
« no previous file with comments | « webkit/fileapi/sandboxed_file_system_operation.h ('k') | webkit/tools/test_shell/simple_file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698