Commit 75af1a4f authored by tzik@chromium.org's avatar tzik@chromium.org

Outsource FileSystemOperationContext from LocalFileSystemOperation


BUG=None
TEST=existing test


Review URL: https://chromiumcodereview.appspot.com/10834021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148512 0039d316-1c4b-4281-b951-d872f2087c98
parent 19de1d79
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "webkit/chromeos/fileapi/remote_file_stream_writer.h" #include "webkit/chromeos/fileapi/remote_file_stream_writer.h"
#include "webkit/chromeos/fileapi/remote_file_system_operation.h" #include "webkit/chromeos/fileapi/remote_file_system_operation.h"
#include "webkit/fileapi/file_system_file_stream_reader.h" #include "webkit/fileapi/file_system_file_stream_reader.h"
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_url.h" #include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/local_file_stream_writer.h" #include "webkit/fileapi/local_file_stream_writer.h"
...@@ -253,7 +254,10 @@ CrosMountPointProvider::CreateFileSystemOperation( ...@@ -253,7 +254,10 @@ CrosMountPointProvider::CreateFileSystemOperation(
if (mount_point && mount_point->location == REMOTE) if (mount_point && mount_point->location == REMOTE)
return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy); return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy);
return new fileapi::LocalFileSystemOperation(context); scoped_ptr<fileapi::FileSystemOperationContext> operation_context(
new fileapi::FileSystemOperationContext(context));
return new fileapi::LocalFileSystemOperation(context,
operation_context.Pass());
} }
webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader( webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader(
......
...@@ -93,7 +93,9 @@ FileSystemOperationInterface* ...@@ -93,7 +93,9 @@ FileSystemOperationInterface*
IsolatedMountPointProvider::CreateFileSystemOperation( IsolatedMountPointProvider::CreateFileSystemOperation(
const FileSystemURL& url, const FileSystemURL& url,
FileSystemContext* context) const { FileSystemContext* context) const {
return new LocalFileSystemOperation(context); scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(context));
return new LocalFileSystemOperation(context, operation_context.Pass());
} }
webkit_blob::FileStreamReader* webkit_blob::FileStreamReader*
......
...@@ -174,7 +174,7 @@ void LocalFileSystemOperation::DirectoryExists(const FileSystemURL& url, ...@@ -174,7 +174,7 @@ void LocalFileSystemOperation::DirectoryExists(const FileSystemURL& url,
} }
FileSystemFileUtilProxy::GetFileInfo( FileSystemFileUtilProxy::GetFileInfo(
&operation_context_, src_util_, url, operation_context_.get(), src_util_, url,
base::Bind(&LocalFileSystemOperation::DidDirectoryExists, base::Bind(&LocalFileSystemOperation::DidDirectoryExists,
base::Owned(this), callback)); base::Owned(this), callback));
} }
...@@ -191,7 +191,7 @@ void LocalFileSystemOperation::FileExists(const FileSystemURL& url, ...@@ -191,7 +191,7 @@ void LocalFileSystemOperation::FileExists(const FileSystemURL& url,
} }
FileSystemFileUtilProxy::GetFileInfo( FileSystemFileUtilProxy::GetFileInfo(
&operation_context_, src_util_, url, operation_context_.get(), src_util_, url,
base::Bind(&LocalFileSystemOperation::DidFileExists, base::Bind(&LocalFileSystemOperation::DidFileExists,
base::Owned(this), callback)); base::Owned(this), callback));
} }
...@@ -208,7 +208,7 @@ void LocalFileSystemOperation::GetMetadata( ...@@ -208,7 +208,7 @@ void LocalFileSystemOperation::GetMetadata(
} }
FileSystemFileUtilProxy::GetFileInfo( FileSystemFileUtilProxy::GetFileInfo(
&operation_context_, src_util_, url, operation_context_.get(), src_util_, url,
base::Bind(&LocalFileSystemOperation::DidGetMetadata, base::Bind(&LocalFileSystemOperation::DidGetMetadata,
base::Owned(this), callback)); base::Owned(this), callback));
} }
...@@ -225,7 +225,7 @@ void LocalFileSystemOperation::ReadDirectory( ...@@ -225,7 +225,7 @@ void LocalFileSystemOperation::ReadDirectory(
} }
FileSystemFileUtilProxy::ReadDirectory( FileSystemFileUtilProxy::ReadDirectory(
&operation_context_, src_util_, url, operation_context_.get(), src_util_, url,
base::Bind(&LocalFileSystemOperation::DidReadDirectory, base::Bind(&LocalFileSystemOperation::DidReadDirectory,
base::Owned(this), callback)); base::Owned(this), callback));
} }
...@@ -246,7 +246,7 @@ void LocalFileSystemOperation::Remove(const FileSystemURL& url, ...@@ -246,7 +246,7 @@ void LocalFileSystemOperation::Remove(const FileSystemURL& url,
file_system_context(), url.origin(), url.type())); file_system_context(), url.origin(), url.type()));
FileSystemFileUtilProxy::Delete( FileSystemFileUtilProxy::Delete(
&operation_context_, src_util_, url, recursive, operation_context_.get(), src_util_, url, recursive,
base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, base::Bind(&LocalFileSystemOperation::DidFinishFileOperation,
base::Owned(this), callback)); base::Owned(this), callback));
} }
...@@ -325,7 +325,7 @@ void LocalFileSystemOperation::TouchFile(const FileSystemURL& url, ...@@ -325,7 +325,7 @@ void LocalFileSystemOperation::TouchFile(const FileSystemURL& url,
} }
FileSystemFileUtilProxy::Touch( FileSystemFileUtilProxy::Touch(
&operation_context_, src_util_, url, operation_context_.get(), src_util_, url,
last_access_time, last_modified_time, last_access_time, last_modified_time,
base::Bind(&LocalFileSystemOperation::DidTouchFile, base::Bind(&LocalFileSystemOperation::DidTouchFile,
base::Owned(this), callback)); base::Owned(this), callback));
...@@ -429,7 +429,7 @@ void LocalFileSystemOperation::SyncGetPlatformPath(const FileSystemURL& url, ...@@ -429,7 +429,7 @@ void LocalFileSystemOperation::SyncGetPlatformPath(const FileSystemURL& url,
return; return;
} }
src_util_->GetLocalFilePath(&operation_context_, url, platform_path); src_util_->GetLocalFilePath(operation_context_.get(), url, platform_path);
delete this; delete this;
} }
...@@ -447,19 +447,21 @@ void LocalFileSystemOperation::CreateSnapshotFile( ...@@ -447,19 +447,21 @@ void LocalFileSystemOperation::CreateSnapshotFile(
} }
FileSystemFileUtilProxy::CreateSnapshotFile( FileSystemFileUtilProxy::CreateSnapshotFile(
&operation_context_, src_util_, url, operation_context_.get(), src_util_, url,
base::Bind(&LocalFileSystemOperation::DidCreateSnapshotFile, base::Bind(&LocalFileSystemOperation::DidCreateSnapshotFile,
base::Owned(this), callback)); base::Owned(this), callback));
} }
LocalFileSystemOperation::LocalFileSystemOperation( LocalFileSystemOperation::LocalFileSystemOperation(
FileSystemContext* file_system_context) FileSystemContext* file_system_context,
: operation_context_(file_system_context), scoped_ptr<FileSystemOperationContext> operation_context)
: operation_context_(operation_context.Pass()),
src_util_(NULL), src_util_(NULL),
dest_util_(NULL), dest_util_(NULL),
peer_handle_(base::kNullProcessHandle), peer_handle_(base::kNullProcessHandle),
pending_operation_(kOperationNone), pending_operation_(kOperationNone),
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK(operation_context_.get());
} }
void LocalFileSystemOperation::GetUsageAndQuotaThenRunTask( void LocalFileSystemOperation::GetUsageAndQuotaThenRunTask(
...@@ -472,7 +474,7 @@ void LocalFileSystemOperation::GetUsageAndQuotaThenRunTask( ...@@ -472,7 +474,7 @@ void LocalFileSystemOperation::GetUsageAndQuotaThenRunTask(
!file_system_context()->GetQuotaUtil(url.type())) { !file_system_context()->GetQuotaUtil(url.type())) {
// If we don't have the quota manager or the requested filesystem type // If we don't have the quota manager or the requested filesystem type
// does not support quota, we should be able to let it go. // does not support quota, we should be able to let it go.
operation_context_.set_allowed_bytes_growth(kint64max); operation_context_->set_allowed_bytes_growth(kint64max);
task.Run(); task.Run();
return; return;
} }
...@@ -501,7 +503,7 @@ void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask( ...@@ -501,7 +503,7 @@ void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask(
return; return;
} }
operation_context_.set_allowed_bytes_growth(quota - usage); operation_context_->set_allowed_bytes_growth(quota - usage);
scoped_quota_notifier_.reset(new ScopedQuotaNotifier( scoped_quota_notifier_.reset(new ScopedQuotaNotifier(
file_system_context(), params.url.origin(), params.url.type())); file_system_context(), params.url.origin(), params.url.type()));
...@@ -513,7 +515,7 @@ void LocalFileSystemOperation::DoCreateFile( ...@@ -513,7 +515,7 @@ void LocalFileSystemOperation::DoCreateFile(
const StatusCallback& callback, const StatusCallback& callback,
bool exclusive) { bool exclusive) {
FileSystemFileUtilProxy::EnsureFileExists( FileSystemFileUtilProxy::EnsureFileExists(
&operation_context_, operation_context_.get(),
src_util_, url, src_util_, url,
base::Bind( base::Bind(
exclusive ? exclusive ?
...@@ -527,7 +529,7 @@ void LocalFileSystemOperation::DoCreateDirectory( ...@@ -527,7 +529,7 @@ void LocalFileSystemOperation::DoCreateDirectory(
const StatusCallback& callback, const StatusCallback& callback,
bool exclusive, bool recursive) { bool exclusive, bool recursive) {
FileSystemFileUtilProxy::CreateDirectory( FileSystemFileUtilProxy::CreateDirectory(
&operation_context_, operation_context_.get(),
src_util_, url, exclusive, recursive, src_util_, url, exclusive, recursive,
base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, base::Bind(&LocalFileSystemOperation::DidFinishFileOperation,
base::Owned(this), callback)); base::Owned(this), callback));
...@@ -537,7 +539,7 @@ void LocalFileSystemOperation::DoCopy(const FileSystemURL& src_url, ...@@ -537,7 +539,7 @@ void LocalFileSystemOperation::DoCopy(const FileSystemURL& src_url,
const FileSystemURL& dest_url, const FileSystemURL& dest_url,
const StatusCallback& callback) { const StatusCallback& callback) {
FileSystemFileUtilProxy::Copy( FileSystemFileUtilProxy::Copy(
&operation_context_, operation_context_.get(),
src_util_, dest_util_, src_util_, dest_util_,
src_url, dest_url, src_url, dest_url,
base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, base::Bind(&LocalFileSystemOperation::DidFinishFileOperation,
...@@ -548,7 +550,7 @@ void LocalFileSystemOperation::DoMove(const FileSystemURL& src_url, ...@@ -548,7 +550,7 @@ void LocalFileSystemOperation::DoMove(const FileSystemURL& src_url,
const FileSystemURL& dest_url, const FileSystemURL& dest_url,
const StatusCallback& callback) { const StatusCallback& callback) {
FileSystemFileUtilProxy::Move( FileSystemFileUtilProxy::Move(
&operation_context_, operation_context_.get(),
src_util_, dest_util_, src_util_, dest_util_,
src_url, dest_url, src_url, dest_url,
base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, base::Bind(&LocalFileSystemOperation::DidFinishFileOperation,
...@@ -559,7 +561,7 @@ void LocalFileSystemOperation::DoTruncate(const FileSystemURL& url, ...@@ -559,7 +561,7 @@ void LocalFileSystemOperation::DoTruncate(const FileSystemURL& url,
const StatusCallback& callback, const StatusCallback& callback,
int64 length) { int64 length) {
FileSystemFileUtilProxy::Truncate( FileSystemFileUtilProxy::Truncate(
&operation_context_, src_util_, url, length, operation_context_.get(), src_util_, url, length,
base::Bind(&LocalFileSystemOperation::DidFinishFileOperation, base::Bind(&LocalFileSystemOperation::DidFinishFileOperation,
base::Owned(this), callback)); base::Owned(this), callback));
} }
...@@ -568,7 +570,7 @@ void LocalFileSystemOperation::DoOpenFile(const FileSystemURL& url, ...@@ -568,7 +570,7 @@ void LocalFileSystemOperation::DoOpenFile(const FileSystemURL& url,
const OpenFileCallback& callback, const OpenFileCallback& callback,
int file_flags) { int file_flags) {
FileSystemFileUtilProxy::CreateOrOpen( FileSystemFileUtilProxy::CreateOrOpen(
&operation_context_, src_util_, url, file_flags, operation_context_.get(), src_util_, url, file_flags,
base::Bind(&LocalFileSystemOperation::DidOpenFile, base::Bind(&LocalFileSystemOperation::DidOpenFile,
base::Owned(this), callback)); base::Owned(this), callback));
} }
......
...@@ -130,14 +130,12 @@ class FILEAPI_EXPORT LocalFileSystemOperation ...@@ -130,14 +130,12 @@ class FILEAPI_EXPORT LocalFileSystemOperation
friend class FileSystemQuotaTest; friend class FileSystemQuotaTest;
friend class LocalFileSystemTestOriginHelper; friend class LocalFileSystemTestOriginHelper;
explicit LocalFileSystemOperation(FileSystemContext* file_system_context); LocalFileSystemOperation(
FileSystemContext* file_system_context,
scoped_ptr<FileSystemOperationContext> operation_context);
FileSystemContext* file_system_context() const { FileSystemContext* file_system_context() const {
return operation_context_.file_system_context(); return operation_context_->file_system_context();
}
FileSystemOperationContext* file_system_operation_context() {
return &operation_context_;
} }
// The unit tests that need to specify and control the lifetime of the // The unit tests that need to specify and control the lifetime of the
...@@ -240,7 +238,7 @@ class FILEAPI_EXPORT LocalFileSystemOperation ...@@ -240,7 +238,7 @@ class FILEAPI_EXPORT LocalFileSystemOperation
// Returns false if there's another inflight pending operation. // Returns false if there's another inflight pending operation.
bool SetPendingOperationType(OperationType type); bool SetPendingOperationType(OperationType type);
FileSystemOperationContext operation_context_; scoped_ptr<FileSystemOperationContext> operation_context_;
FileSystemFileUtil* src_util_; // Not owned. FileSystemFileUtil* src_util_; // Not owned.
FileSystemFileUtil* dest_util_; // Not owned. FileSystemFileUtil* dest_util_; // Not owned.
......
...@@ -173,8 +173,11 @@ LocalFileSystemTestOriginHelper::ComputeCurrentDirectoryDatabaseUsage() const { ...@@ -173,8 +173,11 @@ LocalFileSystemTestOriginHelper::ComputeCurrentDirectoryDatabaseUsage() const {
LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() { LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() {
DCHECK(file_system_context_.get()); DCHECK(file_system_context_.get());
DCHECK(file_util_); DCHECK(file_util_);
scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(file_system_context_.get()));
LocalFileSystemOperation* operation = LocalFileSystemOperation* operation =
new LocalFileSystemOperation(file_system_context_.get()); new LocalFileSystemOperation(file_system_context_.get(),
operation_context.Pass());
operation->set_override_file_util(file_util_); operation->set_override_file_util(file_util_);
return operation; return operation;
} }
......
...@@ -435,7 +435,9 @@ FileSystemOperationInterface* ...@@ -435,7 +435,9 @@ FileSystemOperationInterface*
SandboxMountPointProvider::CreateFileSystemOperation( SandboxMountPointProvider::CreateFileSystemOperation(
const FileSystemURL& url, const FileSystemURL& url,
FileSystemContext* context) const { FileSystemContext* context) const {
return new LocalFileSystemOperation(context); scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(context));
return new LocalFileSystemOperation(context, operation_context.Pass());
} }
webkit_blob::FileStreamReader* webkit_blob::FileStreamReader*
......
...@@ -137,7 +137,9 @@ FileSystemOperationInterface* ...@@ -137,7 +137,9 @@ FileSystemOperationInterface*
TestMountPointProvider::CreateFileSystemOperation( TestMountPointProvider::CreateFileSystemOperation(
const FileSystemURL& url, const FileSystemURL& url,
FileSystemContext* context) const { FileSystemContext* context) const {
return new LocalFileSystemOperation(context); scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(context));
return new LocalFileSystemOperation(context, operation_context.Pass());
} }
webkit_blob::FileStreamReader* TestMountPointProvider::CreateFileStreamReader( webkit_blob::FileStreamReader* TestMountPointProvider::CreateFileStreamReader(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment