Commit 95dc7bfd authored by mtomasz's avatar mtomasz Committed by Commit bot

[fsp] Generalize fileBrowserPrivate.getEntryProperties().

This patch makes the method providing additional metadata for entries available
for provided file systems too.

NOTRY=True
TEST=Tested manually. Files app works as before.
BUG=408017

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

Cr-Commit-Position: refs/heads/master@{#292851}
parent af2ddaa0
......@@ -7,6 +7,8 @@
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
#include "base/files/file.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/drive/file_errors.h"
#include "chrome/browser/chromeos/drive/file_system_interface.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
......@@ -26,32 +28,35 @@ namespace extensions {
namespace api {
namespace file_browser_private {
struct DriveEntryProperties;
struct EntryProperties;
} // namespace file_browser_private
} // namespace api
// Retrieves property information for an entry and returns it as a dictionary.
// On error, returns a dictionary with the key "error" set to the error number
// (drive::FileError).
class FileBrowserPrivateGetDriveEntryPropertiesFunction
// (base::File::Error).
class FileBrowserPrivateGetEntryPropertiesFunction
: public LoggedAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveEntryProperties",
FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES)
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getEntryProperties",
FILEBROWSERPRIVATE_GETENTRYPROPERTIES)
FileBrowserPrivateGetDriveEntryPropertiesFunction();
FileBrowserPrivateGetEntryPropertiesFunction();
protected:
virtual ~FileBrowserPrivateGetDriveEntryPropertiesFunction();
virtual ~FileBrowserPrivateGetEntryPropertiesFunction();
// AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE;
private:
void CompleteGetFileProperties(drive::FileError error);
void CompleteGetEntryProperties(
size_t index,
scoped_ptr<api::file_browser_private::EntryProperties> properties,
base::File::Error error);
size_t processed_count_;
std::vector<linked_ptr<api::file_browser_private::DriveEntryProperties> >
std::vector<linked_ptr<api::file_browser_private::EntryProperties> >
properties_list_;
};
......
......@@ -173,8 +173,8 @@ dictionary FileTask {
boolean isDefault;
};
// Drive file properties.
dictionary DriveEntryProperties {
// Additional entry properties.
dictionary EntryProperties {
// Size of this file.
double? fileSize;
......@@ -477,12 +477,13 @@ callback AddFileWatchCallback = void(optional boolean success);
callback RemoveFileWatchCallback = void(optional boolean success);
// |fileSystem| A DOMFileSystem instance for local file system access. null if
// |the caller has no appropriate permissions.
// the caller has no appropriate permissions.
callback RequestFileSystemCallback = void(optional object fileSystem);
// |fileProperties| A dictionary containing properties of the requested entries.
callback GetDriveEntryPropertiesCallback =
void(DriveEntryProperties[] entryProperties);
// |entryProperties| A dictionary containing properties of the requested
// entries.
callback GetEntryPropertiesCallback =
void(EntryProperties[] entryProperties);
// |localFilePaths| An array of the local file paths for the requested files,
// one entry for each file in fileUrls.
......@@ -628,12 +629,12 @@ interface Functions {
boolean shouldReturnLocalPath,
SimpleCallback callback);
// Requests Drive file properties for files.
// Requests additional properties for files.
// |fileUrls| list of URLs of files
// |callback|
static void getDriveEntryProperties(
static void getEntryProperties(
DOMString[] fileUrls,
GetDriveEntryPropertiesCallback callback);
GetEntryPropertiesCallback callback);
// Pins/unpins a Drive file in the cache.
// |fileUrl| URL of a file to pin/unpin.
......
......@@ -135,7 +135,7 @@ enum HistogramValue {
DELETED_FILEBROWSERPRIVATE_CLEARDRIVECACHE,
SERIAL_GETCONTROLSIGNALS,
DEVELOPERPRIVATE_ENABLE,
FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES,
FILEBROWSERPRIVATE_GETENTRYPROPERTIES,
USB_FINDDEVICES,
BOOKMARKMANAGERPRIVATE_DROP,
DELETED_FILEBROWSERPRIVATE_GETFILETRANSFERS,
......
......@@ -40356,7 +40356,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="74" label="DELETED_FILEBROWSERPRIVATE_CLEARDRIVECACHE"/>
<int value="75" label="SERIAL_GETCONTROLSIGNALS"/>
<int value="76" label="DEVELOPERPRIVATE_ENABLE"/>
<int value="77" label="FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES"/>
<int value="77" label="FILEBROWSERPRIVATE_GETENTRYPROPERTIES"/>
<int value="78" label="USB_FINDDEVICES"/>
<int value="79" label="BOOKMARKMANAGERPRIVATE_DROP"/>
<int value="80" label="DELETED_FILEBROWSERPRIVATE_GETFILETRANSFERS"/>
......@@ -263,7 +263,7 @@ FileTransferController.prototype = {
var processFileEntries = function(entries) {
return new Promise(function(callback) {
var urls = util.entriesToURLs(entries);
chrome.fileBrowserPrivate.getDriveEntryProperties(urls, callback);
chrome.fileBrowserPrivate.getEntryProperties(urls, callback);
}).
then(function(metadatas) {
return entries.filter(function(entry, i) {
......
......@@ -838,9 +838,9 @@ DriveProvider.prototype.callApi_ = function() {
this.callbacks_ = [];
var self = this;
// TODO(mtomasz): Make getDriveEntryProperties accept Entry instead of URL.
// TODO(mtomasz): Make getEntryProperties accept Entry instead of URL.
var entryURLs = util.entriesToURLs(entries);
chrome.fileBrowserPrivate.getDriveEntryProperties(
chrome.fileBrowserPrivate.getEntryProperties(
entryURLs,
function(propertiesList) {
console.assert(propertiesList.length === callbacks.length);
......
......@@ -105,7 +105,7 @@ MediaManager.prototype.getMime = function() {
return Promise.resolve(this.cachedDriveProp_.thumbnailUrl);
return new Promise(function(fulfill, reject) {
chrome.fileBrowserPrivate.getDriveEntryProperties(
chrome.fileBrowserPrivate.getEntryProperties(
[this.entry_.toURL()], fulfill);
}.bind(this)).then(function(props) {
if (!props || !props[0] || !props[0].contentMimeType) {
......@@ -128,7 +128,7 @@ MediaManager.prototype.getThumbnail = function() {
return Promise.resolve(this.cachedDriveProp_.thumbnailUrl);
return new Promise(function(fulfill, reject) {
chrome.fileBrowserPrivate.getDriveEntryProperties(
chrome.fileBrowserPrivate.getEntryProperties(
[this.entry_.toURL()], fulfill);
}.bind(this)).then(function(props) {
if (!props || !props[0] || !props[0].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