diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 04:52:36 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 04:52:36 +0000 |
commit | afef1535ab089b0b3e4e26a0de7dc588b5b372de (patch) | |
tree | 7ae407275f1c8223fb8696c8dd16d4432f8d0cef /webkit/fileapi | |
parent | 1aa5f6a6733fd7840f579849e28b9c79f188f629 (diff) | |
download | chromium_src-afef1535ab089b0b3e4e26a0de7dc588b5b372de.zip chromium_src-afef1535ab089b0b3e4e26a0de7dc588b5b372de.tar.gz chromium_src-afef1535ab089b0b3e4e26a0de7dc588b5b372de.tar.bz2 |
Implement SyncFileSystemService::GetFileSyncStatus method
- The method takes FileSystemURL and returns a new enum: fileapi::SyncFileStatus, which takes one of either: UNKNOWN, SYNCED, HAS_PENDING_CHANGES or CONFLICTING
BUG=163860
TEST=SyncFileSystemService.GetFileSyncStatus
Review URL: https://codereview.chromium.org/11421197
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/syncable/local_file_sync_context.cc | 25 | ||||
-rw-r--r-- | webkit/fileapi/syncable/local_file_sync_context.h | 10 | ||||
-rw-r--r-- | webkit/fileapi/syncable/sync_callbacks.h | 5 | ||||
-rw-r--r-- | webkit/fileapi/syncable/sync_file_status.h | 29 | ||||
-rw-r--r-- | webkit/fileapi/webkit_fileapi.gypi | 1 |
5 files changed, 70 insertions, 0 deletions
diff --git a/webkit/fileapi/syncable/local_file_sync_context.cc b/webkit/fileapi/syncable/local_file_sync_context.cc index 889078f..ec8f0e5 100644 --- a/webkit/fileapi/syncable/local_file_sync_context.cc +++ b/webkit/fileapi/syncable/local_file_sync_context.cc @@ -232,6 +232,31 @@ void LocalFileSyncContext::GetFileMetadata( this, callback)); } +void LocalFileSyncContext::HasPendingLocalChanges( + FileSystemContext* file_system_context, + const FileSystemURL& url, + const HasPendingLocalChangeCallback& callback) { + // This gets called on UI thread and relays the task on FILE thread. + DCHECK(file_system_context); + if (!file_system_context->task_runners()->file_task_runner()-> + RunsTasksOnCurrentThread()) { + DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + file_system_context->task_runners()->file_task_runner()->PostTask( + FROM_HERE, + base::Bind(&LocalFileSyncContext::HasPendingLocalChanges, + this, make_scoped_refptr(file_system_context), + url, callback)); + return; + } + + DCHECK(file_system_context->change_tracker()); + FileChangeList changes; + file_system_context->change_tracker()->GetChangesForURL(url, &changes); + + // Fire the callback on UI thread. + ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, !changes.empty())); +} + void LocalFileSyncContext::AddOriginChangeObserver( LocalOriginChangeObserver* observer) { origin_change_observers_.AddObserver(observer); diff --git a/webkit/fileapi/syncable/local_file_sync_context.h b/webkit/fileapi/syncable/local_file_sync_context.h index 0ab03eb..05cf6c7 100644 --- a/webkit/fileapi/syncable/local_file_sync_context.h +++ b/webkit/fileapi/syncable/local_file_sync_context.h @@ -51,6 +51,9 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext const LocalFileSyncInfo& sync_file_info)> LocalFileSyncInfoCallback; + typedef base::Callback<void(bool has_pending_changes)> + HasPendingLocalChangeCallback; + LocalFileSyncContext(base::SingleThreadTaskRunner* ui_task_runner, base::SingleThreadTaskRunner* io_task_runner); @@ -116,6 +119,13 @@ class WEBKIT_STORAGE_EXPORT LocalFileSyncContext const FileSystemURL& url, const SyncFileMetadataCallback& callback); + // Returns true via |callback| if the given file |url| has local pending + // changes. + void HasPendingLocalChanges( + FileSystemContext* file_system_context, + const FileSystemURL& url, + const HasPendingLocalChangeCallback& callback); + // They must be called on UI thread. void AddOriginChangeObserver(LocalOriginChangeObserver* observer); void RemoveOriginChangeObserver(LocalOriginChangeObserver* observer); diff --git a/webkit/fileapi/syncable/sync_callbacks.h b/webkit/fileapi/syncable/sync_callbacks.h index 2677e42..02ebed7 100644 --- a/webkit/fileapi/syncable/sync_callbacks.h +++ b/webkit/fileapi/syncable/sync_callbacks.h @@ -7,6 +7,7 @@ #include "base/callback_forward.h" #include "webkit/fileapi/file_system_url.h" +#include "webkit/fileapi/syncable/sync_file_status.h" #include "webkit/fileapi/syncable/sync_operation_type.h" #include "webkit/fileapi/syncable/sync_status_code.h" @@ -40,6 +41,10 @@ typedef base::Callback<void(SyncStatusCode status, SyncOperationType operation_type)> SyncOperationCallback; +typedef base::Callback<void(SyncStatusCode status, + SyncFileStatus sync_file_status)> + SyncFileStatusCallback; + } // namespace fileapi #endif // WEBKIT_FILEAPI_SYNCABLE_SYNC_CALLBACKS_H_ diff --git a/webkit/fileapi/syncable/sync_file_status.h b/webkit/fileapi/syncable/sync_file_status.h new file mode 100644 index 0000000..d00b63c --- /dev/null +++ b/webkit/fileapi/syncable/sync_file_status.h @@ -0,0 +1,29 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_FILEAPI_SYNCABLE_SYNC_FILE_STATUS_H_ +#define WEBKIT_FILEAPI_SYNCABLE_SYNC_FILE_STATUS_H_ + +namespace fileapi { + +enum SyncFileStatus { + // The file has unknown sync status (e.g. the file is missing or there + // was an error while retrieving the sync status for the file). + SYNC_FILE_STATUS_UNKNOWN, + + // The file has no pending local changes (may have pending remote changes + // though). + SYNC_FILE_STATUS_SYNCED, + + // The file has pending local changes that haven't been reflected to the + // remote side. + SYNC_FILE_STATUS_HAS_PENDING_CHANGES, + + // The file is in conflicting state. + SYNC_FILE_STATUS_CONFLICTING, +}; + +} // namespace fileapi + +#endif // WEBKIT_FILEAPI_SYNCABLE_SYNC_FILE_STATUS_H_ diff --git a/webkit/fileapi/webkit_fileapi.gypi b/webkit/fileapi/webkit_fileapi.gypi index b669109..b6ad75d 100644 --- a/webkit/fileapi/webkit_fileapi.gypi +++ b/webkit/fileapi/webkit_fileapi.gypi @@ -90,6 +90,7 @@ '../fileapi/syncable/sync_callbacks.h', '../fileapi/syncable/sync_file_metadata.cc', '../fileapi/syncable/sync_file_metadata.h', + '../fileapi/syncable/sync_file_status.h', '../fileapi/syncable/sync_file_type.h', '../fileapi/syncable/sync_operation_type.h', '../fileapi/syncable/sync_status_code.cc', |