summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 09:09:53 +0000
committeryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 09:09:53 +0000
commit0659c8afb9f57ec232cc25944449b78591b43b0e (patch)
treea6c63f4afc967ef7a36a31d94fda7ffe1163d7b7
parentfa66ba04b6f9acaf9a2f55afa5d72b01160752e9 (diff)
downloadchromium_src-0659c8afb9f57ec232cc25944449b78591b43b0e.zip
chromium_src-0659c8afb9f57ec232cc25944449b78591b43b0e.tar.gz
chromium_src-0659c8afb9f57ec232cc25944449b78591b43b0e.tar.bz2
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
-rw-r--r--chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc5
-rw-r--r--chrome/common/extensions/api/file_browser_private.idl6
-rw-r--r--ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js13
3 files changed, 21 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
index 1965bf5..a903010 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
@@ -54,6 +54,11 @@ void FillDriveEntryPropertiesValue(const drive::ResourceEntry& entry_proto,
properties->shared_with_me.reset(new bool(shared_with_me));
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())
return;
diff --git a/chrome/common/extensions/api/file_browser_private.idl b/chrome/common/extensions/api/file_browser_private.idl
index 326f84b..dc3bca4 100644
--- a/chrome/common/extensions/api/file_browser_private.idl
+++ b/chrome/common/extensions/api/file_browser_private.idl
@@ -162,6 +162,12 @@ dictionary FileTask {
// Drive file properties.
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.
DOMString? thumbnailUrl;
diff --git a/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js b/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js
index a9ee9a4..cbe8f4a 100644
--- a/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js
+++ b/ui/file_manager/file_manager/foreground/js/metadata/metadata_cache.js
@@ -115,8 +115,10 @@ MetadataCache.EVICTION_THRESHOLD_MARGIN = 500;
*/
MetadataCache.createFull = function(volumeManager) {
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 FilesystemProvider());
cache.providers_.push(new ContentProvider());
return cache;
};
@@ -681,7 +683,7 @@ FilesystemProvider.prototype.fetch = function(
function onMetadata(entry, metadata) {
callback({
filesystem: {
- size: entry.isFile ? (metadata.size || 0) : -1,
+ size: (entry.isFile ? (metadata.size || 0) : -1),
modificationTime: metadata.modificationTime
}
});
@@ -735,7 +737,7 @@ DriveProvider.prototype.supportsEntry = function(entry) {
*/
DriveProvider.prototype.providesType = function(type) {
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) {
shared: data.shared
};
+ result.filesystem = {
+ size: (entry.isFile ? (data.fileSize || 0) : -1),
+ modificationTime: new Date(data.lastModifiedTime)
+ };
+
if ('thumbnailUrl' in data) {
result.thumbnail = {
url: data.thumbnailUrl,