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

Unified Diff: storage/browser/fileapi/file_system_context.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months 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
Index: storage/browser/fileapi/file_system_context.cc
diff --git a/webkit/browser/fileapi/file_system_context.cc b/storage/browser/fileapi/file_system_context.cc
similarity index 76%
rename from webkit/browser/fileapi/file_system_context.cc
rename to storage/browser/fileapi/file_system_context.cc
index 0df0a1dfced0ce0301d6cd098540311e0f717675..6423e20188311bdfb534396192685aadde581ca5 100644
--- a/webkit/browser/fileapi/file_system_context.cc
+++ b/storage/browser/fileapi/file_system_context.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/file_system_context.h"
+#include "storage/browser/fileapi/file_system_context.h"
#include "base/bind.h"
#include "base/single_thread_task_runner.h"
@@ -10,40 +10,37 @@
#include "base/task_runner_util.h"
#include "net/url_request/url_request.h"
#include "url/gurl.h"
-#include "webkit/browser/blob/file_stream_reader.h"
-#include "webkit/browser/fileapi/copy_or_move_file_validator.h"
-#include "webkit/browser/fileapi/external_mount_points.h"
-#include "webkit/browser/fileapi/file_permission_policy.h"
-#include "webkit/browser/fileapi/file_stream_writer.h"
-#include "webkit/browser/fileapi/file_system_file_util.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
-#include "webkit/browser/fileapi/file_system_operation_runner.h"
-#include "webkit/browser/fileapi/file_system_options.h"
-#include "webkit/browser/fileapi/file_system_quota_client.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/browser/fileapi/isolated_context.h"
-#include "webkit/browser/fileapi/isolated_file_system_backend.h"
-#include "webkit/browser/fileapi/mount_points.h"
-#include "webkit/browser/fileapi/quota/quota_reservation.h"
-#include "webkit/browser/fileapi/sandbox_file_system_backend.h"
-#include "webkit/browser/quota/quota_manager_proxy.h"
-#include "webkit/browser/quota/special_storage_policy.h"
-#include "webkit/common/fileapi/file_system_info.h"
-#include "webkit/common/fileapi/file_system_util.h"
+#include "storage/browser/blob/file_stream_reader.h"
+#include "storage/browser/fileapi/copy_or_move_file_validator.h"
+#include "storage/browser/fileapi/external_mount_points.h"
+#include "storage/browser/fileapi/file_permission_policy.h"
+#include "storage/browser/fileapi/file_stream_writer.h"
+#include "storage/browser/fileapi/file_system_file_util.h"
+#include "storage/browser/fileapi/file_system_operation.h"
+#include "storage/browser/fileapi/file_system_operation_runner.h"
+#include "storage/browser/fileapi/file_system_options.h"
+#include "storage/browser/fileapi/file_system_quota_client.h"
+#include "storage/browser/fileapi/file_system_url.h"
+#include "storage/browser/fileapi/isolated_context.h"
+#include "storage/browser/fileapi/isolated_file_system_backend.h"
+#include "storage/browser/fileapi/mount_points.h"
+#include "storage/browser/fileapi/quota/quota_reservation.h"
+#include "storage/browser/fileapi/sandbox_file_system_backend.h"
+#include "storage/browser/quota/quota_manager_proxy.h"
+#include "storage/browser/quota/special_storage_policy.h"
+#include "storage/common/fileapi/file_system_info.h"
+#include "storage/common/fileapi/file_system_util.h"
using quota::QuotaClient;
-namespace fileapi {
+namespace storage {
namespace {
-QuotaClient* CreateQuotaClient(
- FileSystemContext* context,
- bool is_incognito) {
+QuotaClient* CreateQuotaClient(FileSystemContext* context, bool is_incognito) {
return new FileSystemQuotaClient(context, is_incognito);
}
-
void DidGetMetadataForResolveURL(
const base::FilePath& path,
const FileSystemContext::ResolveURLCallback& callback,
@@ -52,17 +49,24 @@ void DidGetMetadataForResolveURL(
const base::File::Info& file_info) {
if (error != base::File::FILE_OK) {
if (error == base::File::FILE_ERROR_NOT_FOUND) {
- callback.Run(base::File::FILE_OK, info, path,
+ callback.Run(base::File::FILE_OK,
+ info,
+ path,
FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
} else {
- callback.Run(error, FileSystemInfo(), base::FilePath(),
+ callback.Run(error,
+ FileSystemInfo(),
+ base::FilePath(),
FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
}
return;
}
- callback.Run(error, info, path, file_info.is_directory ?
- FileSystemContext::RESOLVED_ENTRY_DIRECTORY :
- FileSystemContext::RESOLVED_ENTRY_FILE);
+ callback.Run(error,
+ info,
+ path,
+ file_info.is_directory
+ ? FileSystemContext::RESOLVED_ENTRY_DIRECTORY
+ : FileSystemContext::RESOLVED_ENTRY_FILE);
}
void RelayResolveURLCallback(
@@ -72,8 +76,8 @@ void RelayResolveURLCallback(
const FileSystemInfo& info,
const base::FilePath& file_path,
FileSystemContext::ResolvedEntryType type) {
- message_loop->PostTask(
- FROM_HERE, base::Bind(callback, result, info, file_path, type));
+ message_loop->PostTask(FROM_HERE,
+ base::Bind(callback, result, info, file_path, type));
}
} // namespace
@@ -95,8 +99,7 @@ int FileSystemContext::GetPermissionPolicy(FileSystemType type) {
return FILE_PERMISSION_USE_FILE_PERMISSION;
case kFileSystemTypeRestrictedNativeLocal:
- return FILE_PERMISSION_READ_ONLY |
- FILE_PERMISSION_USE_FILE_PERMISSION;
+ return FILE_PERMISSION_READ_ONLY | FILE_PERMISSION_USE_FILE_PERMISSION;
case kFileSystemTypeDeviceMedia:
case kFileSystemTypeIphoto:
@@ -143,20 +146,19 @@ FileSystemContext::FileSystemContext(
: io_task_runner_(io_task_runner),
default_file_task_runner_(file_task_runner),
quota_manager_proxy_(quota_manager_proxy),
- sandbox_delegate_(new SandboxFileSystemBackendDelegate(
- quota_manager_proxy,
- file_task_runner,
- partition_path,
- special_storage_policy,
- options)),
- sandbox_backend_(new SandboxFileSystemBackend(
- sandbox_delegate_.get())),
+ sandbox_delegate_(
+ new SandboxFileSystemBackendDelegate(quota_manager_proxy,
+ file_task_runner,
+ partition_path,
+ special_storage_policy,
+ options)),
+ sandbox_backend_(new SandboxFileSystemBackend(sandbox_delegate_.get())),
isolated_backend_(new IsolatedFileSystemBackend()),
- plugin_private_backend_(new PluginPrivateFileSystemBackend(
- file_task_runner,
- partition_path,
- special_storage_policy,
- options)),
+ plugin_private_backend_(
+ new PluginPrivateFileSystemBackend(file_task_runner,
+ partition_path,
+ special_storage_policy,
+ options)),
additional_backends_(additional_backends.Pass()),
auto_mount_handlers_(auto_mount_handlers),
external_mount_points_(external_mount_points),
@@ -168,23 +170,25 @@ FileSystemContext::FileSystemContext(
RegisterBackend(plugin_private_backend_.get());
for (ScopedVector<FileSystemBackend>::const_iterator iter =
- additional_backends_.begin();
- iter != additional_backends_.end(); ++iter) {
+ additional_backends_.begin();
+ iter != additional_backends_.end();
+ ++iter) {
RegisterBackend(*iter);
}
if (quota_manager_proxy) {
// Quota client assumes all backends have registered.
- quota_manager_proxy->RegisterClient(CreateQuotaClient(
- this, options.is_incognito()));
+ quota_manager_proxy->RegisterClient(
+ CreateQuotaClient(this, options.is_incognito()));
}
sandbox_backend_->Initialize(this);
isolated_backend_->Initialize(this);
plugin_private_backend_->Initialize(this);
for (ScopedVector<FileSystemBackend>::const_iterator iter =
- additional_backends_.begin();
- iter != additional_backends_.end(); ++iter) {
+ additional_backends_.begin();
+ iter != additional_backends_.end();
+ ++iter) {
(*iter)->Initialize(this);
}
@@ -209,8 +213,8 @@ bool FileSystemContext::DeleteDataForOriginOnFileTaskRunner(
if (!backend->GetQuotaUtil())
continue;
if (backend->GetQuotaUtil()->DeleteOriginDataOnFileTaskRunner(
- this, quota_manager_proxy(), origin_url, iter->first)
- != base::File::FILE_OK) {
+ this, quota_manager_proxy(), origin_url, iter->first) !=
+ base::File::FILE_OK) {
// Continue the loop, but record the failure.
success = false;
}
@@ -234,23 +238,22 @@ FileSystemContext::CreateQuotaReservationOnFileTaskRunner(
void FileSystemContext::Shutdown() {
if (!io_task_runner_->RunsTasksOnCurrentThread()) {
io_task_runner_->PostTask(
- FROM_HERE, base::Bind(&FileSystemContext::Shutdown,
- make_scoped_refptr(this)));
+ FROM_HERE,
+ base::Bind(&FileSystemContext::Shutdown, make_scoped_refptr(this)));
return;
}
operation_runner_->Shutdown();
}
-FileSystemQuotaUtil*
-FileSystemContext::GetQuotaUtil(FileSystemType type) const {
+FileSystemQuotaUtil* FileSystemContext::GetQuotaUtil(
+ FileSystemType type) const {
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend)
return NULL;
return backend->GetQuotaUtil();
}
-AsyncFileUtil* FileSystemContext::GetAsyncFileUtil(
- FileSystemType type) const {
+AsyncFileUtil* FileSystemContext::GetAsyncFileUtil(FileSystemType type) const {
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend)
return NULL;
@@ -259,14 +262,14 @@ AsyncFileUtil* FileSystemContext::GetAsyncFileUtil(
CopyOrMoveFileValidatorFactory*
FileSystemContext::GetCopyOrMoveFileValidatorFactory(
- FileSystemType type, base::File::Error* error_code) const {
+ FileSystemType type,
+ base::File::Error* error_code) const {
DCHECK(error_code);
*error_code = base::File::FILE_OK;
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend)
return NULL;
- return backend->GetCopyOrMoveFileValidatorFactory(
- type, error_code);
+ return backend->GetCopyOrMoveFileValidatorFactory(type, error_code);
}
FileSystemBackend* FileSystemContext::GetFileSystemBackend(
@@ -303,21 +306,20 @@ void FileSystemContext::GetFileSystemTypes(
std::vector<FileSystemType>* types) const {
types->clear();
for (FileSystemBackendMap::const_iterator iter = backend_map_.begin();
- iter != backend_map_.end(); ++iter)
+ iter != backend_map_.end();
+ ++iter)
types->push_back(iter->first);
}
-ExternalFileSystemBackend*
-FileSystemContext::external_backend() const {
+ExternalFileSystemBackend* FileSystemContext::external_backend() const {
return static_cast<ExternalFileSystemBackend*>(
GetFileSystemBackend(kFileSystemTypeExternal));
}
-void FileSystemContext::OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
- OpenFileSystemMode mode,
- const OpenFileSystemCallback& callback) {
+void FileSystemContext::OpenFileSystem(const GURL& origin_url,
+ FileSystemType type,
+ OpenFileSystemMode mode,
+ const OpenFileSystemCallback& callback) {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!callback.is_null());
@@ -339,16 +341,14 @@ void FileSystemContext::OpenFileSystem(
callback);
}
-void FileSystemContext::ResolveURL(
- const FileSystemURL& url,
- const ResolveURLCallback& callback) {
+void FileSystemContext::ResolveURL(const FileSystemURL& url,
+ const ResolveURLCallback& callback) {
DCHECK(!callback.is_null());
// If not on IO thread, forward before passing the task to the backend.
if (!io_task_runner_->RunsTasksOnCurrentThread()) {
- ResolveURLCallback relay_callback =
- base::Bind(&RelayResolveURLCallback,
- base::MessageLoopProxy::current(), callback);
+ ResolveURLCallback relay_callback = base::Bind(
+ &RelayResolveURLCallback, base::MessageLoopProxy::current(), callback);
io_task_runner_->PostTask(
FROM_HERE,
base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback));
@@ -358,7 +358,8 @@ void FileSystemContext::ResolveURL(
FileSystemBackend* backend = GetFileSystemBackend(url.type());
if (!backend) {
callback.Run(base::File::FILE_ERROR_SECURITY,
- FileSystemInfo(), base::FilePath(),
+ FileSystemInfo(),
+ base::FilePath(),
FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
return;
}
@@ -379,8 +380,8 @@ void FileSystemContext::AttemptAutoMountForURLRequest(
FileSystemURL filesystem_url(url_request->url());
if (filesystem_url.type() == kFileSystemTypeExternal) {
for (size_t i = 0; i < auto_mount_handlers_.size(); i++) {
- if (auto_mount_handlers_[i].Run(url_request, filesystem_url,
- storage_domain, callback)) {
+ if (auto_mount_handlers_[i].Run(
+ url_request, filesystem_url, storage_domain, callback)) {
return;
}
}
@@ -388,10 +389,9 @@ void FileSystemContext::AttemptAutoMountForURLRequest(
callback.Run(base::File::FILE_ERROR_NOT_FOUND);
}
-void FileSystemContext::DeleteFileSystem(
- const GURL& origin_url,
- FileSystemType type,
- const StatusCallback& callback) {
+void FileSystemContext::DeleteFileSystem(const GURL& origin_url,
+ FileSystemType type,
+ const StatusCallback& callback) {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin_url == origin_url.GetOrigin());
DCHECK(!callback.is_null());
@@ -419,16 +419,15 @@ void FileSystemContext::DeleteFileSystem(
callback);
}
-scoped_ptr<webkit_blob::FileStreamReader>
-FileSystemContext::CreateFileStreamReader(
+scoped_ptr<storage::FileStreamReader> FileSystemContext::CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
const base::Time& expected_modification_time) {
if (!url.is_valid())
- return scoped_ptr<webkit_blob::FileStreamReader>();
+ return scoped_ptr<storage::FileStreamReader>();
FileSystemBackend* backend = GetFileSystemBackend(url.type());
if (!backend)
- return scoped_ptr<webkit_blob::FileStreamReader>();
+ return scoped_ptr<storage::FileStreamReader>();
return backend->CreateFileStreamReader(
url, offset, expected_modification_time, this);
}
@@ -517,7 +516,8 @@ void FileSystemContext::DeleteOnCorrectThread() const {
}
FileSystemOperation* FileSystemContext::CreateFileSystemOperation(
- const FileSystemURL& url, base::File::Error* error_code) {
+ const FileSystemURL& url,
+ base::File::Error* error_code) {
if (!url.is_valid()) {
if (error_code)
*error_code = base::File::FILE_ERROR_INVALID_URL;
@@ -569,26 +569,25 @@ FileSystemURL FileSystemContext::CrackFileSystemURL(
void FileSystemContext::RegisterBackend(FileSystemBackend* backend) {
const FileSystemType mount_types[] = {
- kFileSystemTypeTemporary,
- kFileSystemTypePersistent,
- kFileSystemTypeIsolated,
- kFileSystemTypeExternal,
+ kFileSystemTypeTemporary, kFileSystemTypePersistent,
+ kFileSystemTypeIsolated, kFileSystemTypeExternal,
};
// Register file system backends for public mount types.
for (size_t j = 0; j < ARRAYSIZE_UNSAFE(mount_types); ++j) {
if (backend->CanHandleType(mount_types[j])) {
- const bool inserted = backend_map_.insert(
- std::make_pair(mount_types[j], backend)).second;
+ const bool inserted =
+ backend_map_.insert(std::make_pair(mount_types[j], backend)).second;
DCHECK(inserted);
}
}
// Register file system backends for internal types.
for (int t = kFileSystemInternalTypeEnumStart + 1;
- t < kFileSystemInternalTypeEnumEnd; ++t) {
+ t < kFileSystemInternalTypeEnumEnd;
+ ++t) {
FileSystemType type = static_cast<FileSystemType>(t);
if (backend->CanHandleType(type)) {
- const bool inserted = backend_map_.insert(
- std::make_pair(type, backend)).second;
+ const bool inserted =
+ backend_map_.insert(std::make_pair(type, backend)).second;
DCHECK(inserted);
}
}
@@ -603,12 +602,14 @@ void FileSystemContext::DidOpenFileSystemForResolveURL(
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
if (error != base::File::FILE_OK) {
- callback.Run(error, FileSystemInfo(), base::FilePath(),
+ callback.Run(error,
+ FileSystemInfo(),
+ base::FilePath(),
FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
return;
}
- fileapi::FileSystemInfo info(
+ storage::FileSystemInfo info(
filesystem_name, filesystem_root, url.mount_type());
// Extract the virtual path not containing a filesystem type part from |url|.
@@ -627,4 +628,4 @@ void FileSystemContext::DidOpenFileSystemForResolveURL(
url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info));
}
-} // namespace fileapi
+} // namespace storage
« no previous file with comments | « storage/browser/fileapi/file_system_context.h ('k') | storage/browser/fileapi/file_system_dir_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698