diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-22 09:10:02 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-22 09:10:02 +0000 |
commit | 5583e9cdbad385e95c1616849225fa8e10c1859c (patch) | |
tree | d1c08608b48b7ebe511951516fa9cefad4073ae5 /webkit/fileapi | |
parent | 292cdc751c17c6bd61c677d9da6bacf6f10a5bcb (diff) | |
download | chromium_src-5583e9cdbad385e95c1616849225fa8e10c1859c.zip chromium_src-5583e9cdbad385e95c1616849225fa8e10c1859c.tar.gz chromium_src-5583e9cdbad385e95c1616849225fa8e10c1859c.tar.bz2 |
Add metadata paramter to ApplyLocalChange
Since we need the file size for uploading the newly created/updated file
to the remote service.
BUG=162215
TEST=LocalFileSyncServiceTest.*
Review URL: https://codereview.chromium.org/11414111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
4 files changed, 50 insertions, 0 deletions
diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.cc b/webkit/fileapi/syncable/canned_syncable_file_system.cc index 0b993d2..81dac66 100644 --- a/webkit/fileapi/syncable/canned_syncable_file_system.cc +++ b/webkit/fileapi/syncable/canned_syncable_file_system.cc @@ -101,6 +101,20 @@ void OnGetMetadataAndVerifyData( callback.Run(result); } +void OnGetMetadata( + base::PlatformFileInfo* file_info_out, + FilePath* platform_path_out, + const CannedSyncableFileSystem::StatusCallback& callback, + base::PlatformFileError result, + const base::PlatformFileInfo& file_info, + const FilePath& platform_path) { + DCHECK(file_info_out); + DCHECK(platform_path_out); + *file_info_out = file_info; + *platform_path_out = platform_path; + callback.Run(result); +} + class WriteHelper { public: WriteHelper() : bytes_written_(0) {} @@ -347,6 +361,17 @@ PlatformFileError CannedSyncableFileSystem::VerifyFile( base::Unretained(this), url, expected_data)); } +PlatformFileError CannedSyncableFileSystem::GetMetadata( + const FileSystemURL& url, + base::PlatformFileInfo* info, + FilePath* platform_path) { + return RunOnThread<PlatformFileError>( + io_task_runner_, + FROM_HERE, + base::Bind(&CannedSyncableFileSystem::DoGetMetadata, + base::Unretained(this), url, info, platform_path)); +} + int64 CannedSyncableFileSystem::Write( net::URLRequestContext* url_request_context, const FileSystemURL& url, const GURL& blob_url) { @@ -501,6 +526,16 @@ void CannedSyncableFileSystem::DoVerifyFile( expected_data, callback)); } +void CannedSyncableFileSystem::DoGetMetadata( + const FileSystemURL& url, + base::PlatformFileInfo* info, + FilePath* platform_path, + const StatusCallback& callback) { + EXPECT_TRUE(is_filesystem_opened_); + NewOperation()->GetMetadata( + url, base::Bind(&OnGetMetadata, info, platform_path, callback)); +} + void CannedSyncableFileSystem::DoWrite( net::URLRequestContext* url_request_context, const FileSystemURL& url, const GURL& blob_url, diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.h b/webkit/fileapi/syncable/canned_syncable_file_system.h index da396c6..0c19628 100644 --- a/webkit/fileapi/syncable/canned_syncable_file_system.h +++ b/webkit/fileapi/syncable/canned_syncable_file_system.h @@ -108,6 +108,9 @@ class CannedSyncableFileSystem base::PlatformFileError DirectoryExists(const FileSystemURL& url); base::PlatformFileError VerifyFile(const FileSystemURL& url, const std::string& expected_data); + base::PlatformFileError GetMetadata(const FileSystemURL& url, + base::PlatformFileInfo* info, + FilePath* platform_path); // Returns the # of bytes written (>=0) or an error code (<0). int64 Write(net::URLRequestContext* url_request_context, @@ -169,6 +172,10 @@ class CannedSyncableFileSystem void DoVerifyFile(const FileSystemURL& url, const std::string& expected_data, const StatusCallback& callback); + void DoGetMetadata(const FileSystemURL& url, + base::PlatformFileInfo* info, + FilePath* platform_path, + const StatusCallback& callback); void DoWrite(net::URLRequestContext* url_request_context, const FileSystemURL& url, const GURL& blob_url, diff --git a/webkit/fileapi/syncable/sync_file_metadata.cc b/webkit/fileapi/syncable/sync_file_metadata.cc index a402d7a..b5ccf33 100644 --- a/webkit/fileapi/syncable/sync_file_metadata.cc +++ b/webkit/fileapi/syncable/sync_file_metadata.cc @@ -22,6 +22,12 @@ SyncFileMetadata::SyncFileMetadata( SyncFileMetadata::~SyncFileMetadata() {} +bool SyncFileMetadata::operator==(const SyncFileMetadata& that) const { + return file_type == that.file_type && + size == that.size && + last_modified == that.last_modified; +} + ConflictFileInfo::ConflictFileInfo() {} ConflictFileInfo::~ConflictFileInfo() {} diff --git a/webkit/fileapi/syncable/sync_file_metadata.h b/webkit/fileapi/syncable/sync_file_metadata.h index 26f1345..266241f 100644 --- a/webkit/fileapi/syncable/sync_file_metadata.h +++ b/webkit/fileapi/syncable/sync_file_metadata.h @@ -24,6 +24,8 @@ class WEBKIT_STORAGE_EXPORT SyncFileMetadata { SyncFileType file_type; int64 size; base::Time last_modified; + + bool operator==(const SyncFileMetadata& that) const; }; class WEBKIT_STORAGE_EXPORT ConflictFileInfo { |