Commit 0659c8af authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

Reland of r266437: [Files.app] Use getDriveEntryProperties() to retrieve metadata

This is a reland of r260688, which is reverted due to last-minute rebase mistake. 

Previously, we used FileEntry.getMetadata() to retrieve filesystem metadata and getDriveEntryProperties() to get Drive metadata, so we need 2 calls for 1 file on Drive. 

With this patch, getDriveEntryProperties() returns not only Drive metadata but also filesystem metadata. It's enough to call only getDriveEntryProperties() and we can reduce a number of calls by half. 

BUG=345196
TEST=browser_test passes. 
R=asargent@chromium.org, hashimoto@chromium.org, hirono@chromium.org 
TBR=asargent@chromium.org, hashimoto@chromium.org, hirono@chromium.org 
NOTRY=True
# NOTRYing for buildbots already passes (see. crrev.com/256023002)

Review URL: https://codereview.chromium.org/256023002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266795 0039d316-1c4b-4281-b951-d872f2087c98
parent fa66ba04
...@@ -54,6 +54,11 @@ void FillDriveEntryPropertiesValue(const drive::ResourceEntry& entry_proto, ...@@ -54,6 +54,11 @@ void FillDriveEntryPropertiesValue(const drive::ResourceEntry& entry_proto,
properties->shared_with_me.reset(new bool(shared_with_me)); properties->shared_with_me.reset(new bool(shared_with_me));
properties->shared.reset(new bool(entry_proto.shared())); properties->shared.reset(new bool(entry_proto.shared()));
const drive::PlatformFileInfoProto& file_info = entry_proto.file_info();
properties->file_size.reset(new double(file_info.size()));
properties->last_modified_time.reset(new double(
base::Time::FromInternalValue(file_info.last_modified()).ToJsTime()));
if (!entry_proto.has_file_specific_info()) if (!entry_proto.has_file_specific_info())
return; return;
......
...@@ -162,6 +162,12 @@ dictionary FileTask { ...@@ -162,6 +162,12 @@ dictionary FileTask {
// Drive file properties. // Drive file properties.
dictionary DriveEntryProperties { dictionary DriveEntryProperties {
// Size of this file.
double? fileSize;
// Timestamp of entry update time, in milliseconds past the epoch.
double? lastModifiedTime;
// URL to the Drive thumbnail image for this file. // URL to the Drive thumbnail image for this file.
DOMString? thumbnailUrl; DOMString? thumbnailUrl;
......
...@@ -115,8 +115,10 @@ MetadataCache.EVICTION_THRESHOLD_MARGIN = 500; ...@@ -115,8 +115,10 @@ MetadataCache.EVICTION_THRESHOLD_MARGIN = 500;
*/ */
MetadataCache.createFull = function(volumeManager) { MetadataCache.createFull = function(volumeManager) {
var cache = new MetadataCache(); var cache = new MetadataCache();
cache.providers_.push(new FilesystemProvider()); // DriveProvider should be prior to FileSystemProvider, because it covers
// FileSystemProvider for files in Drive.
cache.providers_.push(new DriveProvider(volumeManager)); cache.providers_.push(new DriveProvider(volumeManager));
cache.providers_.push(new FilesystemProvider());
cache.providers_.push(new ContentProvider()); cache.providers_.push(new ContentProvider());
return cache; return cache;
}; };
...@@ -681,7 +683,7 @@ FilesystemProvider.prototype.fetch = function( ...@@ -681,7 +683,7 @@ FilesystemProvider.prototype.fetch = function(
function onMetadata(entry, metadata) { function onMetadata(entry, metadata) {
callback({ callback({
filesystem: { filesystem: {
size: entry.isFile ? (metadata.size || 0) : -1, size: (entry.isFile ? (metadata.size || 0) : -1),
modificationTime: metadata.modificationTime modificationTime: metadata.modificationTime
} }
}); });
...@@ -735,7 +737,7 @@ DriveProvider.prototype.supportsEntry = function(entry) { ...@@ -735,7 +737,7 @@ DriveProvider.prototype.supportsEntry = function(entry) {
*/ */
DriveProvider.prototype.providesType = function(type) { DriveProvider.prototype.providesType = function(type) {
return type === 'drive' || type === 'thumbnail' || return type === 'drive' || type === 'thumbnail' ||
type === 'streaming' || type === 'media'; type === 'streaming' || type === 'media' || type === 'filesystem';
}; };
/** /**
...@@ -838,6 +840,11 @@ DriveProvider.prototype.convert_ = function(data, entry) { ...@@ -838,6 +840,11 @@ DriveProvider.prototype.convert_ = function(data, entry) {
shared: data.shared shared: data.shared
}; };
result.filesystem = {
size: (entry.isFile ? (data.fileSize || 0) : -1),
modificationTime: new Date(data.lastModifiedTime)
};
if ('thumbnailUrl' in data) { if ('thumbnailUrl' in data) {
result.thumbnail = { result.thumbnail = {
url: data.thumbnailUrl, url: data.thumbnailUrl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment