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

Unified Diff: webkit/browser/fileapi/sandbox_file_system_backend.cc

Issue 18668003: SyncFS: Introduce SyncFileSystemBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lazy initialization Created 7 years, 5 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: webkit/browser/fileapi/sandbox_file_system_backend.cc
diff --git a/webkit/browser/fileapi/sandbox_file_system_backend.cc b/webkit/browser/fileapi/sandbox_file_system_backend.cc
index 1c034c9021c5725b7ae89a5201f3897673ce36f2..6fbc43ffaf8ea6660d126eb44833cda248723355 100644
--- a/webkit/browser/fileapi/sandbox_file_system_backend.cc
+++ b/webkit/browser/fileapi/sandbox_file_system_backend.cc
@@ -64,7 +64,6 @@ enum FileSystemError {
const char kTemporaryOriginsCountLabel[] = "FileSystem.TemporaryOriginsCount";
const char kPersistentOriginsCountLabel[] = "FileSystem.PersistentOriginsCount";
-const char kSyncableOriginsCountLabel[] = "FileSystem.SyncableOriginsCount";
// Restricted names.
// http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions
@@ -98,11 +97,11 @@ class ObfuscatedOriginEnumerator
};
void DidOpenFileSystem(
- base::WeakPtr<SandboxFileSystemBackend> mount_point_provider,
+ base::WeakPtr<SandboxFileSystemBackend> file_system_backend,
const base::Callback<void(base::PlatformFileError error)>& callback,
base::PlatformFileError* error) {
- if (mount_point_provider.get())
- mount_point_provider.get()->CollectOpenFileSystemMetrics(*error);
+ if (file_system_backend.get())
+ file_system_backend.get()->CollectOpenFileSystemMetrics(*error);
callback.Run(*error);
}
@@ -134,29 +133,32 @@ void OpenFileSystemOnFileThread(
SandboxFileSystemBackend::SandboxFileSystemBackend(
SandboxContext* sandbox_context,
+ base::SequencedTaskRunner* file_task_runner,
const FileSystemOptions& file_system_options)
- : file_system_options_(file_system_options),
+ : file_task_runner_(file_task_runner),
kinuko 2013/07/17 15:01:30 Why does this need to be passed separately in this
kinuko 2013/07/17 15:02:59 I mean, it used to be passed via sandbox_context b
nhiroki 2013/07/22 04:34:14 This is because that SyncFileSystemBackend::set_ch
nhiroki 2013/07/22 06:33:38 Pushed file_task_runner into SandboxContext again.
+ file_system_options_(file_system_options),
sandbox_context_(sandbox_context),
enable_temporary_file_system_in_incognito_(false),
enable_usage_tracking_(
!CommandLine::ForCurrentProcess()->HasSwitch(
kDisableUsageTracking)),
weak_factory_(this) {
+ // SyncFileSystemBackend is instantiated with null context.
+ if (!sandbox_context)
+ return;
+
// Set quota observers.
if (enable_usage_tracking_) {
update_observers_ = update_observers_.AddObserver(
- sandbox_context_->quota_observer(),
- sandbox_context_->file_task_runner());
+ sandbox_context_->quota_observer(), file_task_runner_.get());
access_observers_ = access_observers_.AddObserver(
sandbox_context_->quota_observer(), NULL);
}
- syncable_update_observers_ = update_observers_;
-
- if (!sandbox_context_->file_task_runner()->RunsTasksOnCurrentThread()) {
+ if (!file_task_runner->RunsTasksOnCurrentThread()) {
// Post prepopulate task only if it's not already running on
// file_task_runner (which implies running in tests).
- sandbox_context_->file_task_runner()->PostTask(
+ file_task_runner->PostTask(
FROM_HERE,
base::Bind(&ObfuscatedFileUtil::MaybePrepopulateDatabase,
base::Unretained(sandbox_sync_file_util())));
@@ -168,9 +170,7 @@ SandboxFileSystemBackend::~SandboxFileSystemBackend() {
bool SandboxFileSystemBackend::CanHandleType(FileSystemType type) const {
return type == kFileSystemTypeTemporary ||
- type == kFileSystemTypePersistent ||
- type == kFileSystemTypeSyncable ||
- type == kFileSystemTypeSyncableForInternalSync;
+ type == kFileSystemTypePersistent;
}
void SandboxFileSystemBackend::InitializeFileSystem(
@@ -206,7 +206,7 @@ void SandboxFileSystemBackend::InitializeFileSystem(
std::string name = GetFileSystemName(origin_url, type);
base::PlatformFileError* error_ptr = new base::PlatformFileError;
- sandbox_context_->file_task_runner()->PostTaskAndReply(
+ file_task_runner_->PostTaskAndReply(
FROM_HERE,
base::Bind(&OpenFileSystemOnFileThread,
sandbox_sync_file_util(),
@@ -222,20 +222,22 @@ void SandboxFileSystemBackend::InitializeFileSystem(
// Schedule full usage recalculation on the next launch without
// --disable-file-system-usage-tracking.
- sandbox_context_->file_task_runner()->PostTask(
+ file_task_runner_->PostTask(
FROM_HERE,
base::Bind(&SandboxFileSystemBackend::InvalidateUsageCacheOnFileThread,
sandbox_sync_file_util(), origin_url, type, usage_cache()));
};
FileSystemFileUtil* SandboxFileSystemBackend::GetFileUtil(
- FileSystemType type) {
+ FileSystemType type,
+ const FileSystemContext* context) {
DCHECK(sandbox_context_);
return sandbox_context_->sync_file_util();
}
AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil(
- FileSystemType type) {
+ FileSystemType type,
+ const FileSystemContext* context) {
DCHECK(sandbox_context_);
return sandbox_context_->file_util();
}
@@ -260,16 +262,6 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation(
scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(context));
-
- // Copy the observer lists (assuming we only have small number of observers).
- if (url.type() == kFileSystemTypeSyncable) {
- operation_context->set_update_observers(syncable_update_observers_);
- operation_context->set_change_observers(syncable_change_observers_);
- return new sync_file_system::SyncableFileSystemOperation(
- url, context, operation_context.Pass());
- }
-
- // For regular sandboxed types.
operation_context->set_update_observers(update_observers_);
operation_context->set_change_observers(change_observers_);
@@ -367,9 +359,6 @@ void SandboxFileSystemBackend::GetOriginsForTypeOnFileThread(
case kFileSystemTypePersistent:
UMA_HISTOGRAM_COUNTS(kPersistentOriginsCountLabel, origins->size());
break;
- case kFileSystemTypeSyncable:
- UMA_HISTOGRAM_COUNTS(kSyncableOriginsCountLabel, origins->size());
- break;
default:
break;
}
@@ -458,8 +447,6 @@ void SandboxFileSystemBackend::AddFileUpdateObserver(
base::SequencedTaskRunner* task_runner) {
DCHECK(CanHandleType(type));
UpdateObserverList* list = &update_observers_;
- if (type == kFileSystemTypeSyncable)
- list = &syncable_update_observers_;
*list = list->AddObserver(observer, task_runner);
}
@@ -469,8 +456,6 @@ void SandboxFileSystemBackend::AddFileChangeObserver(
base::SequencedTaskRunner* task_runner) {
DCHECK(CanHandleType(type));
ChangeObserverList* list = &change_observers_;
- if (type == kFileSystemTypeSyncable)
- list = &syncable_change_observers_;
*list = list->AddObserver(observer, task_runner);
}
@@ -485,16 +470,12 @@ void SandboxFileSystemBackend::AddFileAccessObserver(
const UpdateObserverList* SandboxFileSystemBackend::GetUpdateObservers(
FileSystemType type) const {
DCHECK(CanHandleType(type));
- if (type == kFileSystemTypeSyncable)
- return &syncable_update_observers_;
return &update_observers_;
}
const ChangeObserverList* SandboxFileSystemBackend::GetChangeObservers(
FileSystemType type) const {
DCHECK(CanHandleType(type));
- if (type == kFileSystemTypeSyncable)
- return &syncable_change_observers_;
return &change_observers_;
}

Powered by Google App Engine
This is Rietveld 408576698