summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 23:54:44 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 23:54:44 +0000
commita11968d750d1e9082f4353b628b981f82728192f (patch)
tree559088dc1d5d1e063cd4f3ea6619ec566611a10e /webkit
parent4b8bc42e1d5861dff89c2482b633c84fc9a30bea (diff)
downloadchromium_src-a11968d750d1e9082f4353b628b981f82728192f.zip
chromium_src-a11968d750d1e9082f4353b628b981f82728192f.tar.gz
chromium_src-a11968d750d1e9082f4353b628b981f82728192f.tar.bz2
Add special FS type for internal sync operation
This change deprecates sync_file_system::CreateFileSystemOperationForSync(), but adds a new special FS type for internal sync: kFileSystemTypeSyncableForInternalSync so that the existing FileSystemOperation factory method (i.e. FileSystemContext::CreateFileSystemOperation) can be used without hacky code for internal sync operations. This is a prerequisite cleanup for following further cleanups: - To eventually move all syncable code out of webkit/fileapi - To cleanup FileSystemOperatin related code BUG=242422, 176444 TEST=content_unittests:LocalFile*,Syncable* TEST=manual local/remote sync test with syncfs-editor Review URL: https://chromiumcodereview.appspot.com/16330002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/obfuscated_file_util.cc5
-rw-r--r--webkit/browser/fileapi/sandbox_mount_point_provider.cc14
-rw-r--r--webkit/browser/fileapi/sandbox_mount_point_provider.h5
-rw-r--r--webkit/browser/fileapi/syncable/local_file_sync_context.cc49
-rw-r--r--webkit/browser/fileapi/syncable/syncable_file_system_util.cc23
-rw-r--r--webkit/browser/fileapi/syncable/syncable_file_system_util.h15
-rw-r--r--webkit/common/fileapi/file_system_types.h7
-rw-r--r--webkit/common/fileapi/file_system_util.cc2
8 files changed, 69 insertions, 51 deletions
diff --git a/webkit/browser/fileapi/obfuscated_file_util.cc b/webkit/browser/fileapi/obfuscated_file_util.cc
index 00662f7..5346b93 100644
--- a/webkit/browser/fileapi/obfuscated_file_util.cc
+++ b/webkit/browser/fileapi/obfuscated_file_util.cc
@@ -343,7 +343,8 @@ PlatformFileError ObfuscatedFileUtil::CreateDirectory(
// TODO(kinuko): Remove this dirty hack when we fully support directory
// operations or clean up the code if we decided not to support directory
// operations. (http://crbug.com/161442)
- if (url.type() == kFileSystemTypeSyncable &&
+ if ((url.type() == kFileSystemTypeSyncable ||
+ url.type() == kFileSystemTypeSyncableForInternalSync) &&
!sync_file_system::IsSyncFSDirectoryOperationEnabled()) {
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
}
@@ -915,6 +916,7 @@ bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType(
other_types.push_back(kFileSystemTypePersistent);
if (type != kFileSystemTypeSyncable)
other_types.push_back(kFileSystemTypeSyncable);
+ DCHECK(type != kFileSystemTypeSyncableForInternalSync);
for (size_t i = 0; i < other_types.size(); ++i) {
if (file_util::DirectoryExists(
@@ -945,6 +947,7 @@ base::FilePath::StringType ObfuscatedFileUtil::GetDirectoryNameForType(
case kFileSystemTypePersistent:
return kPersistentDirectoryName;
case kFileSystemTypeSyncable:
+ case kFileSystemTypeSyncableForInternalSync:
return kSyncableDirectoryName;
case kFileSystemTypeUnknown:
default:
diff --git a/webkit/browser/fileapi/sandbox_mount_point_provider.cc b/webkit/browser/fileapi/sandbox_mount_point_provider.cc
index 3f3afaa..e4b4387 100644
--- a/webkit/browser/fileapi/sandbox_mount_point_provider.cc
+++ b/webkit/browser/fileapi/sandbox_mount_point_provider.cc
@@ -137,7 +137,8 @@ SandboxMountPointProvider::kFileSystemDirectory[] =
bool SandboxMountPointProvider::IsSandboxType(FileSystemType type) {
return type == kFileSystemTypeTemporary ||
type == kFileSystemTypePersistent ||
- type == kFileSystemTypeSyncable;
+ type == kFileSystemTypeSyncable ||
+ type == kFileSystemTypeSyncableForInternalSync;
}
SandboxMountPointProvider::SandboxMountPointProvider(
@@ -587,17 +588,6 @@ void SandboxMountPointProvider::AddSyncableFileChangeObserver(
syncable_change_observers_ = ChangeObserverList(observer_source);
}
-LocalFileSystemOperation*
-SandboxMountPointProvider::CreateFileSystemOperationForSync(
- FileSystemContext* file_system_context) {
- scoped_ptr<FileSystemOperationContext> operation_context(
- new FileSystemOperationContext(file_system_context));
- operation_context->set_update_observers(update_observers_);
- operation_context->set_access_observers(access_observers_);
- return new LocalFileSystemOperation(file_system_context,
- operation_context.Pass());
-}
-
base::FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType(
const GURL& origin_url,
FileSystemType type) {
diff --git a/webkit/browser/fileapi/sandbox_mount_point_provider.h b/webkit/browser/fileapi/sandbox_mount_point_provider.h
index d67afbb..e2050ee 100644
--- a/webkit/browser/fileapi/sandbox_mount_point_provider.h
+++ b/webkit/browser/fileapi/sandbox_mount_point_provider.h
@@ -167,11 +167,6 @@ class WEBKIT_STORAGE_EXPORT SandboxMountPointProvider
void AddSyncableFileChangeObserver(FileChangeObserver* observer,
base::SequencedTaskRunner* task_runner);
- // Returns a LocalFileSystemOperation that can be used to apply changes
- // to the syncable filesystem.
- LocalFileSystemOperation* CreateFileSystemOperationForSync(
- FileSystemContext* file_system_context);
-
void set_enable_temporary_file_system_in_incognito(bool enable) {
enable_temporary_file_system_in_incognito_ = enable;
}
diff --git a/webkit/browser/fileapi/syncable/local_file_sync_context.cc b/webkit/browser/fileapi/syncable/local_file_sync_context.cc
index c0a656a..4a0a176 100644
--- a/webkit/browser/fileapi/syncable/local_file_sync_context.cc
+++ b/webkit/browser/fileapi/syncable/local_file_sync_context.cc
@@ -33,9 +33,11 @@ using fileapi::LocalFileSystemOperation;
namespace sync_file_system {
namespace {
+
const int kMaxConcurrentSyncableOperation = 3;
const int kNotifyChangesDurationInSec = 1;
const int kMaxURLsToFetchForLocalSync = 5;
+
} // namespace
LocalFileSyncContext::LocalFileSyncContext(
@@ -199,8 +201,11 @@ void LocalFileSyncContext::ApplyRemoteChange(
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!sync_status()->IsWritable(url));
DCHECK(!sync_status()->IsWriting(url));
- LocalFileSystemOperation* operation = CreateFileSystemOperationForSync(
- file_system_context);
+
+ FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
+ file_system_context, url);
+ FileSystemOperation* operation =
+ file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
DCHECK(operation);
FileSystemOperation::StatusCallback operation_callback;
@@ -218,7 +223,7 @@ void LocalFileSyncContext::ApplyRemoteChange(
operation_callback = base::Bind(
&LocalFileSyncContext::DidApplyRemoteChange, this, url, callback);
}
- operation->Remove(url, true /* recursive */, operation_callback);
+ operation->Remove(url_for_sync, true /* recursive */, operation_callback);
}
void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
@@ -239,9 +244,13 @@ void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!sync_status()->IsWritable(url));
DCHECK(!sync_status()->IsWriting(url));
- LocalFileSystemOperation* operation =
- CreateFileSystemOperationForSync(file_system_context);
+
+ FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
+ file_system_context, url);
+ FileSystemOperation* operation =
+ file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
DCHECK(operation);
+
FileSystemOperation::StatusCallback operation_callback = base::Bind(
&LocalFileSyncContext::DidApplyRemoteChange, this, url, callback);
@@ -253,12 +262,13 @@ void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
if (dir_path.empty() ||
fileapi::VirtualPath::DirName(dir_path) == dir_path) {
// Copying into the root directory.
- operation->CopyInForeignFile(local_path, url, operation_callback);
+ operation->AsLocalFileSystemOperation()->CopyInForeignFile(
+ local_path, url_for_sync, operation_callback);
} else {
FileSystemURL dir_url = file_system_context->CreateCrackedFileSystemURL(
- url.origin(),
- url.mount_type(),
- fileapi::VirtualPath::DirName(url.virtual_path()));
+ url_for_sync.origin(),
+ url_for_sync.mount_type(),
+ fileapi::VirtualPath::DirName(url_for_sync.virtual_path()));
operation->CreateDirectory(
dir_url,
false /* exclusive */,
@@ -274,7 +284,8 @@ void LocalFileSyncContext::DidRemoveExistingEntryForApplyRemoteChange(
}
case SYNC_FILE_TYPE_DIRECTORY:
operation->CreateDirectory(
- url, false /* exclusive */, true /* recursive */, operation_callback);
+ url_for_sync, false /* exclusive */, true /* recursive */,
+ operation_callback);
break;
case SYNC_FILE_TYPE_UNKNOWN:
NOTREACHED() << "File type unknown for ADD_OR_UPDATE change";
@@ -323,11 +334,14 @@ void LocalFileSyncContext::GetFileMetadata(
return;
}
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
- LocalFileSystemOperation* operation = CreateFileSystemOperationForSync(
- file_system_context);
+
+ FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
+ file_system_context, url);
+ FileSystemOperation* operation =
+ file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
DCHECK(operation);
operation->GetMetadata(
- url, base::Bind(&LocalFileSyncContext::DidGetFileMetadata,
+ url_for_sync, base::Bind(&LocalFileSyncContext::DidGetFileMetadata,
this, callback));
}
@@ -732,10 +746,13 @@ void LocalFileSyncContext::DidCreateDirectoryForCopyIn(
return;
}
- LocalFileSystemOperation* operation = CreateFileSystemOperationForSync(
- file_system_context);
+ FileSystemURL url_for_sync = CreateSyncableFileSystemURLForSync(
+ file_system_context, dest_url);
+ FileSystemOperation* operation =
+ file_system_context->CreateFileSystemOperation(url_for_sync, NULL);
DCHECK(operation);
- operation->CopyInForeignFile(local_path, dest_url, callback);
+ operation->AsLocalFileSystemOperation()->CopyInForeignFile(
+ local_path, url_for_sync, callback);
}
} // namespace sync_file_system
diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_util.cc b/webkit/browser/fileapi/syncable/syncable_file_system_util.cc
index 6ad547e..9225312 100644
--- a/webkit/browser/fileapi/syncable/syncable_file_system_util.cc
+++ b/webkit/browser/fileapi/syncable/syncable_file_system_util.cc
@@ -27,6 +27,7 @@ const char kEnableSyncFSDirectoryOperation[] =
"enable-syncfs-directory-operation";
const char kSyncableMountName[] = "syncfs";
+const char kSyncableMountNameForInternalSync[] = "syncfs-internal";
bool is_directory_operation_enabled = false;
@@ -37,11 +38,17 @@ void RegisterSyncableFileSystem() {
kSyncableMountName,
fileapi::kFileSystemTypeSyncable,
base::FilePath());
+ ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
+ kSyncableMountNameForInternalSync,
+ fileapi::kFileSystemTypeSyncableForInternalSync,
+ base::FilePath());
}
void RevokeSyncableFileSystem() {
ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(
kSyncableMountName);
+ ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(
+ kSyncableMountNameForInternalSync);
}
GURL GetSyncableFileSystemRootURI(const GURL& origin) {
@@ -55,6 +62,15 @@ FileSystemURL CreateSyncableFileSystemURL(const GURL& origin,
origin, kSyncableMountName, path);
}
+FileSystemURL CreateSyncableFileSystemURLForSync(
+ fileapi::FileSystemContext* file_system_context,
+ const FileSystemURL& syncable_url) {
+ return ExternalMountPoints::GetSystemInstance()->CreateExternalFileSystemURL(
+ syncable_url.origin(),
+ kSyncableMountNameForInternalSync,
+ syncable_url.path());
+}
+
bool SerializeSyncableFileSystemURL(const FileSystemURL& url,
std::string* serialized_url) {
if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeSyncable)
@@ -82,13 +98,6 @@ bool DeserializeSyncableFileSystemURL(
return true;
}
-LocalFileSystemOperation* CreateFileSystemOperationForSync(
- FileSystemContext* file_system_context) {
- DCHECK(file_system_context);
- return file_system_context->sandbox_provider()->
- CreateFileSystemOperationForSync(file_system_context);
-}
-
void SetEnableSyncFSDirectoryOperation(bool flag) {
is_directory_operation_enabled = flag;
}
diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_util.h b/webkit/browser/fileapi/syncable/syncable_file_system_util.h
index e2750b0..c07e0cb 100644
--- a/webkit/browser/fileapi/syncable/syncable_file_system_util.h
+++ b/webkit/browser/fileapi/syncable/syncable_file_system_util.h
@@ -38,6 +38,11 @@ WEBKIT_STORAGE_EXPORT GURL GetSyncableFileSystemRootURI(const GURL& origin);
WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURL(
const GURL& origin, const base::FilePath& path);
+// Creates a special filesystem URL for synchronizing |syncable_url|.
+WEBKIT_STORAGE_EXPORT fileapi::FileSystemURL CreateSyncableFileSystemURLForSync(
+ fileapi::FileSystemContext* file_system_context,
+ const fileapi::FileSystemURL& syncable_url);
+
// Serializes a given FileSystemURL |url| and sets the serialized string to
// |serialized_url|. If the URL does not represent a syncable filesystem,
// |serialized_url| is not filled in, and returns false. Separators of the
@@ -69,16 +74,6 @@ WEBKIT_STORAGE_EXPORT bool SerializeSyncableFileSystemURL(
WEBKIT_STORAGE_EXPORT bool DeserializeSyncableFileSystemURL(
const std::string& serialized_url, fileapi::FileSystemURL* url);
-// Returns a new FileSystemOperation that can be used to apply changes
-// for sync. The operation returned by this method:
-// * does NOT notify the file change tracker, but
-// * notifies the regular sandboxed quota observer
-// therefore quota will be updated appropriately without bothering the
-// change tracker.
-WEBKIT_STORAGE_EXPORT fileapi::LocalFileSystemOperation*
- CreateFileSystemOperationForSync(
- fileapi::FileSystemContext* file_system_context);
-
// Enables or disables directory operations in Sync FileSystem API.
// TODO(nhiroki): This method should be used only for testing and should go
// away when we fully support directory operations. (http://crbug.com/161442)
diff --git a/webkit/common/fileapi/file_system_types.h b/webkit/common/fileapi/file_system_types.h
index 3726a30..22d1d07 100644
--- a/webkit/common/fileapi/file_system_types.h
+++ b/webkit/common/fileapi/file_system_types.h
@@ -89,6 +89,13 @@ enum FileSystemType {
// cloud storage service.
kFileSystemTypeSyncable,
+ // Indicates a special filesystem type for internal file sync operation
+ // for Syncable sandboxed filesystems. The file system is overlayed, i.e.
+ // points to the same sandboxed filesystem as that of kFileSystemTypeSyncable,
+ // but the changes made with this filesystem type are not recorded for
+ // further sync.
+ kFileSystemTypeSyncableForInternalSync,
+
// Indicates an external filesystem accessible by file paths from platform
// Apps. As of writing, on non Chrome OS platform, this is merely a
// kFileSystemTypeNativeLocal. On Chrome OS, the path is parsed by
diff --git a/webkit/common/fileapi/file_system_util.cc b/webkit/common/fileapi/file_system_util.cc
index ca656cc..2583d54 100644
--- a/webkit/common/fileapi/file_system_util.cc
+++ b/webkit/common/fileapi/file_system_util.cc
@@ -180,6 +180,7 @@ quota::StorageType FileSystemTypeToQuotaStorageType(FileSystemType type) {
case kFileSystemTypePersistent:
return quota::kStorageTypePersistent;
case kFileSystemTypeSyncable:
+ case kFileSystemTypeSyncableForInternalSync:
return quota::kStorageTypeSyncable;
default:
return quota::kStorageTypeUnknown;
@@ -215,6 +216,7 @@ std::string GetFileSystemTypeString(FileSystemType type) {
case kFileSystemTypeDrive:
return "Drive";
case kFileSystemTypeSyncable:
+ case kFileSystemTypeSyncableForInternalSync:
return "Syncable";
case kFileSystemTypeNativeForPlatformApp:
return "NativeForPlatformApp";