| Index: storage/browser/fileapi/async_file_util_adapter.cc
|
| diff --git a/webkit/browser/fileapi/async_file_util_adapter.cc b/storage/browser/fileapi/async_file_util_adapter.cc
|
| similarity index 61%
|
| rename from webkit/browser/fileapi/async_file_util_adapter.cc
|
| rename to storage/browser/fileapi/async_file_util_adapter.cc
|
| index 5a99effbd6f1735328d9320f00bb034d68aaaf7d..13e58632ef86b804a2b0e7ecfaca7cb71a369680 100644
|
| --- a/webkit/browser/fileapi/async_file_util_adapter.cc
|
| +++ b/storage/browser/fileapi/async_file_util_adapter.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/browser/fileapi/async_file_util_adapter.h"
|
| +#include "storage/browser/fileapi/async_file_util_adapter.h"
|
|
|
| #include <vector>
|
|
|
| @@ -10,20 +10,20 @@
|
| #include "base/sequenced_task_runner.h"
|
| #include "base/task_runner_util.h"
|
| #include "base/thread_task_runner_handle.h"
|
| -#include "webkit/browser/fileapi/file_system_context.h"
|
| -#include "webkit/browser/fileapi/file_system_file_util.h"
|
| -#include "webkit/browser/fileapi/file_system_operation_context.h"
|
| -#include "webkit/browser/fileapi/file_system_url.h"
|
| -#include "webkit/common/blob/shareable_file_reference.h"
|
| -#include "webkit/common/fileapi/file_system_util.h"
|
| +#include "storage/browser/fileapi/file_system_context.h"
|
| +#include "storage/browser/fileapi/file_system_file_util.h"
|
| +#include "storage/browser/fileapi/file_system_operation_context.h"
|
| +#include "storage/browser/fileapi/file_system_url.h"
|
| +#include "storage/common/blob/shareable_file_reference.h"
|
| +#include "storage/common/fileapi/file_system_util.h"
|
|
|
| using base::Bind;
|
| using base::Callback;
|
| using base::Owned;
|
| using base::Unretained;
|
| -using webkit_blob::ShareableFileReference;
|
| +using storage::ShareableFileReference;
|
|
|
| -namespace fileapi {
|
| +namespace storage {
|
|
|
| namespace {
|
|
|
| @@ -49,8 +49,7 @@ class EnsureFileExistsHelper {
|
|
|
| class GetFileInfoHelper {
|
| public:
|
| - GetFileInfoHelper()
|
| - : error_(base::File::FILE_OK) {}
|
| + GetFileInfoHelper() : error_(base::File::FILE_OK) {}
|
|
|
| void GetFileInfo(FileSystemFileUtil* file_util,
|
| FileSystemOperationContext* context,
|
| @@ -71,15 +70,17 @@ class GetFileInfoHelper {
|
|
|
| void ReplySnapshotFile(
|
| const AsyncFileUtil::CreateSnapshotFileCallback& callback) {
|
| - callback.Run(error_, file_info_, platform_path_,
|
| - ShareableFileReference::GetOrCreate(scoped_file_.Pass()));
|
| + callback.Run(error_,
|
| + file_info_,
|
| + platform_path_,
|
| + ShareableFileReference::GetOrCreate(scoped_file_.Pass()));
|
| }
|
|
|
| private:
|
| base::File::Error error_;
|
| base::File::Info file_info_;
|
| base::FilePath platform_path_;
|
| - webkit_blob::ScopedFile scoped_file_;
|
| + storage::ScopedFile scoped_file_;
|
| DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper);
|
| };
|
|
|
| @@ -90,8 +91,8 @@ void ReadDirectoryHelper(FileSystemFileUtil* file_util,
|
| const AsyncFileUtil::ReadDirectoryCallback& callback) {
|
| base::File::Info file_info;
|
| base::FilePath platform_path;
|
| - base::File::Error error = file_util->GetFileInfo(
|
| - context, url, &file_info, &platform_path);
|
| + base::File::Error error =
|
| + file_util->GetFileInfo(context, url, &file_info, &platform_path);
|
|
|
| if (error == base::File::FILE_OK && !file_info.is_directory)
|
| error = base::File::FILE_ERROR_NOT_A_DIRECTORY;
|
| @@ -122,14 +123,15 @@ void ReadDirectoryHelper(FileSystemFileUtil* file_util,
|
|
|
| if (entries.size() == kResultChunkSize) {
|
| origin_loop->PostTask(
|
| - FROM_HERE, base::Bind(callback, base::File::FILE_OK, entries,
|
| - true /* has_more */));
|
| + FROM_HERE,
|
| + base::Bind(
|
| + callback, base::File::FILE_OK, entries, true /* has_more */));
|
| entries.clear();
|
| }
|
| }
|
| origin_loop->PostTask(
|
| - FROM_HERE, base::Bind(callback, base::File::FILE_OK, entries,
|
| - false /* has_more */));
|
| + FROM_HERE,
|
| + base::Bind(callback, base::File::FILE_OK, entries, false /* has_more */));
|
| }
|
|
|
| void RunCreateOrOpenCallback(
|
| @@ -141,8 +143,7 @@ void RunCreateOrOpenCallback(
|
|
|
| } // namespace
|
|
|
| -AsyncFileUtilAdapter::AsyncFileUtilAdapter(
|
| - FileSystemFileUtil* sync_file_util)
|
| +AsyncFileUtilAdapter::AsyncFileUtilAdapter(FileSystemFileUtil* sync_file_util)
|
| : sync_file_util_(sync_file_util) {
|
| DCHECK(sync_file_util_.get());
|
| }
|
| @@ -159,8 +160,11 @@ void AsyncFileUtilAdapter::CreateOrOpen(
|
| base::PostTaskAndReplyWithResult(
|
| context_ptr->task_runner(),
|
| FROM_HERE,
|
| - Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(sync_file_util_.get()),
|
| - context_ptr, url, file_flags),
|
| + Bind(&FileSystemFileUtil::CreateOrOpen,
|
| + Unretained(sync_file_util_.get()),
|
| + context_ptr,
|
| + url,
|
| + file_flags),
|
| Bind(&RunCreateOrOpenCallback, base::Owned(context_ptr), callback));
|
| }
|
|
|
| @@ -172,8 +176,11 @@ void AsyncFileUtilAdapter::EnsureFileExists(
|
| FileSystemOperationContext* context_ptr = context.release();
|
| const bool success = context_ptr->task_runner()->PostTaskAndReply(
|
| FROM_HERE,
|
| - Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper),
|
| - sync_file_util_.get(), base::Owned(context_ptr), url),
|
| + Bind(&EnsureFileExistsHelper::RunWork,
|
| + Unretained(helper),
|
| + sync_file_util_.get(),
|
| + base::Owned(context_ptr),
|
| + url),
|
| Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback));
|
| DCHECK(success);
|
| }
|
| @@ -186,10 +193,14 @@ void AsyncFileUtilAdapter::CreateDirectory(
|
| const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| + context_ptr->task_runner(),
|
| + FROM_HERE,
|
| Bind(&FileSystemFileUtil::CreateDirectory,
|
| Unretained(sync_file_util_.get()),
|
| - base::Owned(context_ptr), url, exclusive, recursive),
|
| + base::Owned(context_ptr),
|
| + url,
|
| + exclusive,
|
| + recursive),
|
| callback);
|
| DCHECK(success);
|
| }
|
| @@ -202,8 +213,11 @@ void AsyncFileUtilAdapter::GetFileInfo(
|
| GetFileInfoHelper* helper = new GetFileInfoHelper;
|
| const bool success = context_ptr->task_runner()->PostTaskAndReply(
|
| FROM_HERE,
|
| - Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper),
|
| - sync_file_util_.get(), base::Owned(context_ptr), url),
|
| + Bind(&GetFileInfoHelper::GetFileInfo,
|
| + Unretained(helper),
|
| + sync_file_util_.get(),
|
| + base::Owned(context_ptr),
|
| + url),
|
| Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback));
|
| DCHECK(success);
|
| }
|
| @@ -216,24 +230,30 @@ void AsyncFileUtilAdapter::ReadDirectory(
|
| const bool success = context_ptr->task_runner()->PostTask(
|
| FROM_HERE,
|
| Bind(&ReadDirectoryHelper,
|
| - sync_file_util_.get(), base::Owned(context_ptr), url,
|
| - base::ThreadTaskRunnerHandle::Get(), callback));
|
| + sync_file_util_.get(),
|
| + base::Owned(context_ptr),
|
| + url,
|
| + base::ThreadTaskRunnerHandle::Get(),
|
| + callback));
|
| DCHECK(success);
|
| }
|
|
|
| -void AsyncFileUtilAdapter::Touch(
|
| - scoped_ptr<FileSystemOperationContext> context,
|
| - const FileSystemURL& url,
|
| - const base::Time& last_access_time,
|
| - const base::Time& last_modified_time,
|
| - const StatusCallback& callback) {
|
| +void AsyncFileUtilAdapter::Touch(scoped_ptr<FileSystemOperationContext> context,
|
| + const FileSystemURL& url,
|
| + const base::Time& last_access_time,
|
| + const base::Time& last_modified_time,
|
| + const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| - const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| - Bind(&FileSystemFileUtil::Touch, Unretained(sync_file_util_.get()),
|
| - base::Owned(context_ptr), url,
|
| - last_access_time, last_modified_time),
|
| - callback);
|
| + const bool success =
|
| + base::PostTaskAndReplyWithResult(context_ptr->task_runner(),
|
| + FROM_HERE,
|
| + Bind(&FileSystemFileUtil::Touch,
|
| + Unretained(sync_file_util_.get()),
|
| + base::Owned(context_ptr),
|
| + url,
|
| + last_access_time,
|
| + last_modified_time),
|
| + callback);
|
| DCHECK(success);
|
| }
|
|
|
| @@ -243,11 +263,15 @@ void AsyncFileUtilAdapter::Truncate(
|
| int64 length,
|
| const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| - const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| - Bind(&FileSystemFileUtil::Truncate, Unretained(sync_file_util_.get()),
|
| - base::Owned(context_ptr), url, length),
|
| - callback);
|
| + const bool success =
|
| + base::PostTaskAndReplyWithResult(context_ptr->task_runner(),
|
| + FROM_HERE,
|
| + Bind(&FileSystemFileUtil::Truncate,
|
| + Unretained(sync_file_util_.get()),
|
| + base::Owned(context_ptr),
|
| + url,
|
| + length),
|
| + callback);
|
| DCHECK(success);
|
| }
|
|
|
| @@ -260,12 +284,17 @@ void AsyncFileUtilAdapter::CopyFileLocal(
|
| const StatusCallback& callback) {
|
| // TODO(hidehiko): Support progress_callback.
|
| FileSystemOperationContext* context_ptr = context.release();
|
| - const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| - Bind(&FileSystemFileUtil::CopyOrMoveFile,
|
| - Unretained(sync_file_util_.get()), base::Owned(context_ptr),
|
| - src_url, dest_url, option, true /* copy */),
|
| - callback);
|
| + const bool success =
|
| + base::PostTaskAndReplyWithResult(context_ptr->task_runner(),
|
| + FROM_HERE,
|
| + Bind(&FileSystemFileUtil::CopyOrMoveFile,
|
| + Unretained(sync_file_util_.get()),
|
| + base::Owned(context_ptr),
|
| + src_url,
|
| + dest_url,
|
| + option,
|
| + true /* copy */),
|
| + callback);
|
| DCHECK(success);
|
| }
|
|
|
| @@ -276,26 +305,34 @@ void AsyncFileUtilAdapter::MoveFileLocal(
|
| CopyOrMoveOption option,
|
| const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| - const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| - Bind(&FileSystemFileUtil::CopyOrMoveFile,
|
| - Unretained(sync_file_util_.get()), base::Owned(context_ptr),
|
| - src_url, dest_url, option, false /* copy */),
|
| - callback);
|
| + const bool success =
|
| + base::PostTaskAndReplyWithResult(context_ptr->task_runner(),
|
| + FROM_HERE,
|
| + Bind(&FileSystemFileUtil::CopyOrMoveFile,
|
| + Unretained(sync_file_util_.get()),
|
| + base::Owned(context_ptr),
|
| + src_url,
|
| + dest_url,
|
| + option,
|
| + false /* copy */),
|
| + callback);
|
| DCHECK(success);
|
| }
|
|
|
| void AsyncFileUtilAdapter::CopyInForeignFile(
|
| - scoped_ptr<FileSystemOperationContext> context,
|
| - const base::FilePath& src_file_path,
|
| - const FileSystemURL& dest_url,
|
| - const StatusCallback& callback) {
|
| + scoped_ptr<FileSystemOperationContext> context,
|
| + const base::FilePath& src_file_path,
|
| + const FileSystemURL& dest_url,
|
| + const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| + context_ptr->task_runner(),
|
| + FROM_HERE,
|
| Bind(&FileSystemFileUtil::CopyInForeignFile,
|
| Unretained(sync_file_util_.get()),
|
| - base::Owned(context_ptr), src_file_path, dest_url),
|
| + base::Owned(context_ptr),
|
| + src_file_path,
|
| + dest_url),
|
| callback);
|
| DCHECK(success);
|
| }
|
| @@ -305,12 +342,14 @@ void AsyncFileUtilAdapter::DeleteFile(
|
| const FileSystemURL& url,
|
| const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| - const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| - Bind(&FileSystemFileUtil::DeleteFile,
|
| - Unretained(sync_file_util_.get()),
|
| - base::Owned(context_ptr), url),
|
| - callback);
|
| + const bool success =
|
| + base::PostTaskAndReplyWithResult(context_ptr->task_runner(),
|
| + FROM_HERE,
|
| + Bind(&FileSystemFileUtil::DeleteFile,
|
| + Unretained(sync_file_util_.get()),
|
| + base::Owned(context_ptr),
|
| + url),
|
| + callback);
|
| DCHECK(success);
|
| }
|
|
|
| @@ -320,10 +359,12 @@ void AsyncFileUtilAdapter::DeleteDirectory(
|
| const StatusCallback& callback) {
|
| FileSystemOperationContext* context_ptr = context.release();
|
| const bool success = base::PostTaskAndReplyWithResult(
|
| - context_ptr->task_runner(), FROM_HERE,
|
| + context_ptr->task_runner(),
|
| + FROM_HERE,
|
| Bind(&FileSystemFileUtil::DeleteDirectory,
|
| Unretained(sync_file_util_.get()),
|
| - base::Owned(context_ptr), url),
|
| + base::Owned(context_ptr),
|
| + url),
|
| callback);
|
| DCHECK(success);
|
| }
|
| @@ -343,10 +384,13 @@ void AsyncFileUtilAdapter::CreateSnapshotFile(
|
| GetFileInfoHelper* helper = new GetFileInfoHelper;
|
| const bool success = context_ptr->task_runner()->PostTaskAndReply(
|
| FROM_HERE,
|
| - Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper),
|
| - sync_file_util_.get(), base::Owned(context_ptr), url),
|
| + Bind(&GetFileInfoHelper::CreateSnapshotFile,
|
| + Unretained(helper),
|
| + sync_file_util_.get(),
|
| + base::Owned(context_ptr),
|
| + url),
|
| Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback));
|
| DCHECK(success);
|
| }
|
|
|
| -} // namespace fileapi
|
| +} // namespace storage
|
|
|