Index: webkit/fileapi/file_system_operation.cc |
diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc |
index 7c504a620eca62ff7a77451811b58882a68fd68a..f329cc18c304872f0a86a8d6b638da9f8a073bde 100644 |
--- a/webkit/fileapi/file_system_operation.cc |
+++ b/webkit/fileapi/file_system_operation.cc |
@@ -63,24 +63,29 @@ FileSystemOperation::FileSystemOperation( |
FileSystemContext* file_system_context) |
: proxy_(proxy), |
dispatcher_(dispatcher), |
- operation_context_(file_system_context, NULL), |
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
+ operation_context_(file_system_context, NULL) { |
#ifndef NDEBUG |
pending_operation_ = kOperationNone; |
#endif |
} |
FileSystemOperation::~FileSystemOperation() { |
- if (file_writer_delegate_.get()) |
- FileSystemFileUtilProxy::Close( |
- operation_context_, proxy_, file_writer_delegate_->file(), |
- FileSystemFileUtilProxy::StatusCallback()); |
+ if (file_writer_delegate_.get()) { |
+ FileSystemOperationContext* c = |
+ new FileSystemOperationContext(operation_context_); |
+ base::FileUtilProxy::RelayClose( |
+ proxy_, |
+ base::Bind(&FileSystemFileUtil::Close, |
+ base::Unretained(c->src_file_util()), |
+ base::Owned(c)), |
+ file_writer_delegate_->file(), |
+ base::FileUtilProxy::StatusCallback()); |
+ } |
} |
void FileSystemOperation::OpenFileSystem( |
const GURL& origin_url, fileapi::FileSystemType type, bool create) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = static_cast<FileSystemOperation::OperationType>( |
kOperationOpenFileSystem); |
@@ -98,13 +103,12 @@ void FileSystemOperation::OpenFileSystem( |
file_system_context()->path_manager()->ValidateFileSystemRootAndGetURL( |
origin_url, type, create, |
base::Bind(&FileSystemOperation::DidGetRootPath, |
- weak_factory_.GetWeakPtr())); |
+ base::Owned(this))); |
} |
void FileSystemOperation::CreateFile(const GURL& path, |
bool exclusive) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationCreateFile; |
#endif |
@@ -112,15 +116,14 @@ void FileSystemOperation::CreateFile(const GURL& path, |
delete this; |
return; |
} |
- exclusive_ = exclusive; |
- |
GetUsageAndQuotaThenCallback( |
operation_context_.src_origin_url(), |
base::Bind(&FileSystemOperation::DelayedCreateFileForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this), exclusive)); |
} |
void FileSystemOperation::DelayedCreateFileForQuota( |
+ bool exclusive, |
quota::QuotaStatusCode status, int64 usage, int64 quota) { |
operation_context_.set_allowed_bytes_growth(quota - usage); |
@@ -134,16 +137,15 @@ void FileSystemOperation::DelayedCreateFileForQuota( |
proxy_, |
src_virtual_path_, |
base::Bind( |
- exclusive_ ? &FileSystemOperation::DidEnsureFileExistsExclusive |
- : &FileSystemOperation::DidEnsureFileExistsNonExclusive, |
- weak_factory_.GetWeakPtr())); |
+ exclusive ? &FileSystemOperation::DidEnsureFileExistsExclusive |
+ : &FileSystemOperation::DidEnsureFileExistsNonExclusive, |
+ base::Owned(this))); |
} |
void FileSystemOperation::CreateDirectory(const GURL& path, |
bool exclusive, |
bool recursive) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationCreateDirectory; |
#endif |
@@ -151,16 +153,14 @@ void FileSystemOperation::CreateDirectory(const GURL& path, |
delete this; |
return; |
} |
- exclusive_ = exclusive; |
- recursive_ = recursive; |
- |
GetUsageAndQuotaThenCallback( |
operation_context_.src_origin_url(), |
base::Bind(&FileSystemOperation::DelayedCreateDirectoryForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this), exclusive, recursive)); |
} |
void FileSystemOperation::DelayedCreateDirectoryForQuota( |
+ bool exclusive, bool recursive, |
quota::QuotaStatusCode status, int64 usage, int64 quota) { |
operation_context_.set_allowed_bytes_growth(quota - usage); |
@@ -169,17 +169,19 @@ void FileSystemOperation::DelayedCreateDirectoryForQuota( |
operation_context_.src_origin_url(), |
operation_context_.src_type())); |
- FileSystemFileUtilProxy::CreateDirectory( |
- operation_context_, proxy_, src_virtual_path_, exclusive_, |
- recursive_, |
+ base::FileUtilProxy::RelayFileTask( |
+ proxy_, FROM_HERE, |
+ base::Bind(&FileSystemFileUtil::CreateDirectory, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, exclusive, recursive), |
base::Bind(&FileSystemOperation::DidFinishFileOperation, |
- weak_factory_.GetWeakPtr())); |
+ base::Owned(this))); |
} |
void FileSystemOperation::Copy(const GURL& src_path, |
const GURL& dest_path) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationCopy; |
#endif |
@@ -192,7 +194,7 @@ void FileSystemOperation::Copy(const GURL& src_path, |
GetUsageAndQuotaThenCallback( |
operation_context_.dest_origin_url(), |
base::Bind(&FileSystemOperation::DelayedCopyForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this))); |
} |
void FileSystemOperation::DelayedCopyForQuota(quota::QuotaStatusCode status, |
@@ -204,17 +206,19 @@ void FileSystemOperation::DelayedCopyForQuota(quota::QuotaStatusCode status, |
operation_context_.dest_origin_url(), |
operation_context_.dest_type())); |
- FileSystemFileUtilProxy::Copy( |
- operation_context_, proxy_, src_virtual_path_, |
- dest_virtual_path_, |
+ base::FileUtilProxy::RelayFileTask( |
+ proxy_, FROM_HERE, |
+ base::Bind(&FileSystemFileUtil::Copy, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, dest_virtual_path_), |
base::Bind(&FileSystemOperation::DidFinishFileOperation, |
- weak_factory_.GetWeakPtr())); |
+ base::Owned(this))); |
} |
void FileSystemOperation::Move(const GURL& src_path, |
const GURL& dest_path) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationMove; |
#endif |
@@ -227,7 +231,7 @@ void FileSystemOperation::Move(const GURL& src_path, |
GetUsageAndQuotaThenCallback( |
operation_context_.dest_origin_url(), |
base::Bind(&FileSystemOperation::DelayedMoveForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this))); |
} |
void FileSystemOperation::DelayedMoveForQuota(quota::QuotaStatusCode status, |
@@ -239,16 +243,18 @@ void FileSystemOperation::DelayedMoveForQuota(quota::QuotaStatusCode status, |
operation_context_.dest_origin_url(), |
operation_context_.dest_type())); |
- FileSystemFileUtilProxy::Move( |
- operation_context_, proxy_, src_virtual_path_, |
- dest_virtual_path_, |
+ base::FileUtilProxy::RelayFileTask( |
+ proxy_, FROM_HERE, |
+ base::Bind(&FileSystemFileUtil::Move, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, dest_virtual_path_), |
base::Bind(&FileSystemOperation::DidFinishFileOperation, |
- weak_factory_.GetWeakPtr())); |
+ base::Owned(this))); |
} |
void FileSystemOperation::DirectoryExists(const GURL& path) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationDirectoryExists; |
#endif |
@@ -259,13 +265,11 @@ void FileSystemOperation::DirectoryExists(const GURL& path) { |
FileSystemFileUtilProxy::GetFileInfo( |
operation_context_, proxy_, src_virtual_path_, |
- base::Bind(&FileSystemOperation::DidDirectoryExists, |
- weak_factory_.GetWeakPtr())); |
+ base::Bind(&FileSystemOperation::DidDirectoryExists, base::Owned(this))); |
} |
void FileSystemOperation::FileExists(const GURL& path) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationFileExists; |
#endif |
@@ -276,13 +280,11 @@ void FileSystemOperation::FileExists(const GURL& path) { |
FileSystemFileUtilProxy::GetFileInfo( |
operation_context_, proxy_, src_virtual_path_, |
- base::Bind(&FileSystemOperation::DidFileExists, |
- weak_factory_.GetWeakPtr())); |
+ base::Bind(&FileSystemOperation::DidFileExists, base::Owned(this))); |
} |
void FileSystemOperation::GetMetadata(const GURL& path) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationGetMetadata; |
#endif |
@@ -293,13 +295,11 @@ void FileSystemOperation::GetMetadata(const GURL& path) { |
FileSystemFileUtilProxy::GetFileInfo( |
operation_context_, proxy_, src_virtual_path_, |
- base::Bind(&FileSystemOperation::DidGetMetadata, |
- weak_factory_.GetWeakPtr())); |
+ base::Bind(&FileSystemOperation::DidGetMetadata, base::Owned(this))); |
} |
void FileSystemOperation::ReadDirectory(const GURL& path) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationReadDirectory; |
#endif |
@@ -310,13 +310,11 @@ void FileSystemOperation::ReadDirectory(const GURL& path) { |
FileSystemFileUtilProxy::ReadDirectory( |
operation_context_, proxy_, src_virtual_path_, |
- base::Bind(&FileSystemOperation::DidReadDirectory, |
- weak_factory_.GetWeakPtr())); |
+ base::Bind(&FileSystemOperation::DidReadDirectory, base::Owned(this))); |
} |
void FileSystemOperation::Remove(const GURL& path, bool recursive) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationRemove; |
#endif |
@@ -325,10 +323,14 @@ void FileSystemOperation::Remove(const GURL& path, bool recursive) { |
return; |
} |
- FileSystemFileUtilProxy::Delete( |
- operation_context_, proxy_, src_virtual_path_, recursive, |
+ base::FileUtilProxy::RelayFileTask( |
+ proxy_, FROM_HERE, |
+ base::Bind(&FileSystemFileUtil::Delete, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, recursive), |
base::Bind(&FileSystemOperation::DidFinishFileOperation, |
- weak_factory_.GetWeakPtr())); |
+ base::Owned(this))); |
} |
void FileSystemOperation::Write( |
@@ -337,7 +339,6 @@ void FileSystemOperation::Write( |
const GURL& blob_url, |
int64 offset) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationWrite; |
#endif |
@@ -354,7 +355,7 @@ void FileSystemOperation::Write( |
GetUsageAndQuotaThenCallback( |
operation_context_.src_origin_url(), |
base::Bind(&FileSystemOperation::DelayedWriteForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this))); |
} |
void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status, |
@@ -366,19 +367,25 @@ void FileSystemOperation::DelayedWriteForQuota(quota::QuotaStatusCode status, |
operation_context_.src_origin_url(), |
operation_context_.src_type())); |
- FileSystemFileUtilProxy::CreateOrOpen( |
- operation_context_, |
+ int file_flags = base::PLATFORM_FILE_OPEN | |
+ base::PLATFORM_FILE_WRITE | |
+ base::PLATFORM_FILE_ASYNC; |
+ |
+ base::FileUtilProxy::RelayCreateOrOpen( |
proxy_, |
- src_virtual_path_, |
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | |
- base::PLATFORM_FILE_ASYNC, |
+ base::Bind(&FileSystemFileUtil::CreateOrOpen, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, file_flags), |
+ base::Bind(&FileSystemFileUtil::Close, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_), |
base::Bind(&FileSystemOperation::OnFileOpenedForWrite, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this))); |
} |
void FileSystemOperation::Truncate(const GURL& path, int64 length) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationTruncate; |
#endif |
@@ -386,15 +393,14 @@ void FileSystemOperation::Truncate(const GURL& path, int64 length) { |
delete this; |
return; |
} |
- length_ = length; |
- |
GetUsageAndQuotaThenCallback( |
operation_context_.src_origin_url(), |
base::Bind(&FileSystemOperation::DelayedTruncateForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this), length)); |
} |
-void FileSystemOperation::DelayedTruncateForQuota(quota::QuotaStatusCode status, |
+void FileSystemOperation::DelayedTruncateForQuota(int64 length, |
+ quota::QuotaStatusCode status, |
int64 usage, int64 quota) { |
operation_context_.set_allowed_bytes_growth(quota - usage); |
@@ -403,17 +409,20 @@ void FileSystemOperation::DelayedTruncateForQuota(quota::QuotaStatusCode status, |
operation_context_.src_origin_url(), |
operation_context_.src_type())); |
- FileSystemFileUtilProxy::Truncate( |
- operation_context_, proxy_, src_virtual_path_, length_, |
+ base::FileUtilProxy::RelayFileTask( |
+ proxy_, FROM_HERE, |
+ base::Bind(&FileSystemFileUtil::Truncate, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, length), |
base::Bind(&FileSystemOperation::DidFinishFileOperation, |
- weak_factory_.GetWeakPtr())); |
+ base::Owned(this))); |
} |
void FileSystemOperation::TouchFile(const GURL& path, |
const base::Time& last_access_time, |
const base::Time& last_modified_time) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationTouchFile; |
#endif |
@@ -422,18 +431,19 @@ void FileSystemOperation::TouchFile(const GURL& path, |
return; |
} |
- FileSystemFileUtilProxy::Touch( |
- operation_context_, proxy_, src_virtual_path_, |
- last_access_time, last_modified_time, |
- base::Bind(&FileSystemOperation::DidTouchFile, |
- weak_factory_.GetWeakPtr())); |
+ base::FileUtilProxy::RelayFileTask( |
+ proxy_, FROM_HERE, |
+ base::Bind(&FileSystemFileUtil::Touch, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, last_access_time, last_modified_time), |
+ base::Bind(&FileSystemOperation::DidTouchFile, base::Owned(this))); |
} |
void FileSystemOperation::OpenFile(const GURL& path, |
int file_flags, |
base::ProcessHandle peer_handle) { |
#ifndef NDEBUG |
- DCHECK(dispatcher_.get()); |
DCHECK(kOperationNone == pending_operation_); |
pending_operation_ = kOperationOpenFile; |
#endif |
@@ -461,15 +471,14 @@ void FileSystemOperation::OpenFile(const GURL& path, |
return; |
} |
} |
- file_flags_ = file_flags; |
- |
GetUsageAndQuotaThenCallback( |
operation_context_.src_origin_url(), |
base::Bind(&FileSystemOperation::DelayedOpenFileForQuota, |
- weak_factory_.GetWeakPtr())); |
+ base::Unretained(this), file_flags)); |
} |
-void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status, |
+void FileSystemOperation::DelayedOpenFileForQuota(int file_flags, |
+ quota::QuotaStatusCode status, |
int64 usage, int64 quota) { |
operation_context_.set_allowed_bytes_growth(quota - usage); |
@@ -478,10 +487,16 @@ void FileSystemOperation::DelayedOpenFileForQuota(quota::QuotaStatusCode status, |
operation_context_.src_origin_url(), |
operation_context_.src_type())); |
- FileSystemFileUtilProxy::CreateOrOpen( |
- operation_context_, proxy_, src_virtual_path_, file_flags_, |
- base::Bind(&FileSystemOperation::DidOpenFile, |
- weak_factory_.GetWeakPtr())); |
+ base::FileUtilProxy::RelayCreateOrOpen( |
+ proxy_, |
+ base::Bind(&FileSystemFileUtil::CreateOrOpen, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_, |
+ src_virtual_path_, file_flags), |
+ base::Bind(&FileSystemFileUtil::Close, |
+ base::Unretained(operation_context_.src_file_util()), |
+ &operation_context_), |
+ base::Bind(&FileSystemOperation::DidOpenFile, base::Owned(this))); |
} |
void FileSystemOperation::SyncGetPlatformPath(const GURL& path, |
@@ -518,9 +533,10 @@ void FileSystemOperation::Cancel(FileSystemOperation* cancel_operation_ptr) { |
// This halts any calls to file_writer_delegate_ from blob_request_. |
blob_request_->Cancel(); |
- dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_ABORT); |
+ if (dispatcher_.get()) |
+ dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_ABORT); |
cancel_operation->dispatcher_->DidSucceed(); |
- delete this; |
+ dispatcher_.reset(); |
} else { |
#ifndef NDEBUG |
DCHECK(kOperationTruncate == pending_operation_); |
@@ -561,6 +577,8 @@ void FileSystemOperation::DidGetRootPath( |
const FilePath& path, const std::string& name) { |
DCHECK(success || path.empty()); |
GURL result; |
+ if (!dispatcher_.get()) |
+ return; |
// We ignore the path, and return a URL instead. The point was just to verify |
// that we could create/find the path. |
if (success) { |
@@ -569,14 +587,13 @@ void FileSystemOperation::DidGetRootPath( |
operation_context_.src_type()); |
} |
dispatcher_->DidOpenFileSystem(name, result); |
- delete this; |
} |
void FileSystemOperation::DidEnsureFileExistsExclusive( |
base::PlatformFileError rv, bool created) { |
if (rv == base::PLATFORM_FILE_OK && !created) { |
- dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_EXISTS); |
- delete this; |
+ if (dispatcher_.get()) |
+ dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_EXISTS); |
} else { |
DidFinishFileOperation(rv); |
} |
@@ -594,20 +611,23 @@ void FileSystemOperation::DidFinishFileOperation( |
DCHECK(kOperationTruncate == pending_operation_); |
#endif |
- dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_ABORT); |
+ if (dispatcher_.get()) |
+ dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_ABORT); |
cancel_operation_->dispatcher_->DidSucceed(); |
- } else if (rv == base::PLATFORM_FILE_OK) { |
- dispatcher_->DidSucceed(); |
- } else { |
- dispatcher_->DidFail(rv); |
+ } else if (dispatcher_.get()) { |
+ if (rv == base::PLATFORM_FILE_OK) |
+ dispatcher_->DidSucceed(); |
+ else |
+ dispatcher_->DidFail(rv); |
} |
- delete this; |
} |
void FileSystemOperation::DidDirectoryExists( |
base::PlatformFileError rv, |
const base::PlatformFileInfo& file_info, |
const FilePath& unused) { |
+ if (!dispatcher_.get()) |
+ return; |
if (rv == base::PLATFORM_FILE_OK) { |
if (file_info.is_directory) |
dispatcher_->DidSucceed(); |
@@ -616,13 +636,14 @@ void FileSystemOperation::DidDirectoryExists( |
} else { |
dispatcher_->DidFail(rv); |
} |
- delete this; |
} |
void FileSystemOperation::DidFileExists( |
base::PlatformFileError rv, |
const base::PlatformFileInfo& file_info, |
const FilePath& unused) { |
+ if (!dispatcher_.get()) |
+ return; |
if (rv == base::PLATFORM_FILE_OK) { |
if (file_info.is_directory) |
dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_NOT_A_FILE); |
@@ -631,35 +652,40 @@ void FileSystemOperation::DidFileExists( |
} else { |
dispatcher_->DidFail(rv); |
} |
- delete this; |
} |
void FileSystemOperation::DidGetMetadata( |
base::PlatformFileError rv, |
const base::PlatformFileInfo& file_info, |
const FilePath& platform_path) { |
+ if (!dispatcher_.get()) |
+ return; |
if (rv == base::PLATFORM_FILE_OK) |
dispatcher_->DidReadMetadata(file_info, platform_path); |
else |
dispatcher_->DidFail(rv); |
- delete this; |
} |
void FileSystemOperation::DidReadDirectory( |
base::PlatformFileError rv, |
const std::vector<base::FileUtilProxy::Entry>& entries) { |
+ if (!dispatcher_.get()) |
+ return; |
if (rv == base::PLATFORM_FILE_OK) |
dispatcher_->DidReadDirectory(entries, false /* has_more */); |
else |
dispatcher_->DidFail(rv); |
- delete this; |
} |
void FileSystemOperation::DidWrite( |
base::PlatformFileError rv, |
int64 bytes, |
bool complete) { |
+ if (!dispatcher_.get()) { |
+ delete this; |
+ return; |
+ } |
if (rv == base::PLATFORM_FILE_OK) |
dispatcher_->DidWrite(bytes, complete); |
else |
@@ -669,30 +695,33 @@ void FileSystemOperation::DidWrite( |
} |
void FileSystemOperation::DidTouchFile(base::PlatformFileError rv) { |
+ if (!dispatcher_.get()) |
+ return; |
if (rv == base::PLATFORM_FILE_OK) |
dispatcher_->DidSucceed(); |
else |
dispatcher_->DidFail(rv); |
- delete this; |
} |
void FileSystemOperation::DidOpenFile( |
base::PlatformFileError rv, |
base::PassPlatformFile file, |
bool unused) { |
+ if (!dispatcher_.get()) |
+ return; |
if (rv == base::PLATFORM_FILE_OK) |
dispatcher_->DidOpenFile(file.ReleaseValue(), peer_handle_); |
else |
dispatcher_->DidFail(rv); |
- delete this; |
} |
void FileSystemOperation::OnFileOpenedForWrite( |
base::PlatformFileError rv, |
base::PassPlatformFile file, |
bool created) { |
- if (base::PLATFORM_FILE_OK != rv) { |
- dispatcher_->DidFail(rv); |
+ if (base::PLATFORM_FILE_OK != rv || !dispatcher_.get()) { |
+ if (dispatcher_.get()) |
+ dispatcher_->DidFail(rv); |
delete this; |
return; |
} |