Skip to content

Commit

Permalink
Files.app: Fix the argument type of metadata observers.
Browse files Browse the repository at this point in the history
FileWatcher expects a map of entry URL and metadata as an third argument of observers, but MetadataCache passes array of metadata.
This make FileTable fail metadata update, and it causes flakiness of tests.

BUG=330549, 316918
TEST=browser_tests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242475 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
hirono@chromium.org committed Dec 25, 2013
1 parent 47695fc commit 59725c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ INSTANTIATE_TEST_CASE_P(
"galleryOpenDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "galleryOpenDrive")));

/* http://crbug.com/316918 Tests are flaky.
INSTANTIATE_TEST_CASE_P(
KeyboardOperations,
FileManagerBrowserTest,
Expand All @@ -649,7 +648,6 @@ INSTANTIATE_TEST_CASE_P(
TestParameter(IN_GUEST_MODE, "keyboardCopyDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDrive")));
*/

INSTANTIATE_TEST_CASE_P(
DriveSpecific,
Expand All @@ -661,7 +659,7 @@ INSTANTIATE_TEST_CASE_P(
TestParameter(NOT_IN_GUEST_MODE, "autocomplete")));

INSTANTIATE_TEST_CASE_P(
DISABLED_Transfer,
Transfer,
FileManagerBrowserTest,
::testing::Values(TestParameter(NOT_IN_GUEST_MODE,
"transferFromDriveToDownloads"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ FileTable.prototype.updateFileMetadata = function(item, entry) {
/**
* Updates list items 'in place' on metadata change.
* @param {string} type Type of metadata change.
* @param {Object.<sting, Object>} propsMap Map from entry URLs to metadata
* properties.
* @param {Object.<string, Object>} propsMap Map from entry URLs to metadata
* properties.
*/
FileTable.prototype.updateListItemsMetadata = function(type, propsMap) {
var forEachCell = function(selector, callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ MetadataCache.prototype.clearRecursively = function(entry, type) {
* @param {number} relation This defines, which items will trigger the observer.
* See comments to |MetadataCache.EXACT| and others.
* @param {string} type The metadata type.
* @param {function(Array.<Entry>, Array.<Object>)} observer List of entries
* and corresponding metadata values are passed to this callback.
* @param {function(Array.<Entry>, Object.<string, Object>)} observer Map of
* entries and corresponding metadata values are passed to this callback.
* @return {number} The observer id, which can be used to remove it.
*/
MetadataCache.prototype.addObserver = function(
Expand Down Expand Up @@ -462,14 +462,14 @@ MetadataCache.prototype.endBatchUpdates = function() {
for (var index = 0; index < this.observers_.length; index++) {
var observer = this.observers_[index];
var entries = [];
var properties = [];
var properties = {};
for (var entryURL in observer.pending) {
if (observer.pending.hasOwnProperty(entryURL) &&
entryURL in this.cache_) {
var entry = observer.pending[entryURL];
entries.push(entry);
properties.push(
this.cache_[entryURL].properties[observer.type] || null);
properties[entryURL] =
this.cache_[entryURL].properties[observer.type] || null;
}
}
observer.pending = {};
Expand All @@ -491,9 +491,11 @@ MetadataCache.prototype.notifyObservers_ = function(entry, type) {
var observer = this.observers_[index];
if (observer.type === type && observer.re.test(entryURL)) {
if (this.batchCount_ === 0) {
// Observer expects array of urls and array of properties.
// Observer expects array of urls and map of properties.
var property = {};
property[entryURL] = this.cache_[entryURL].properties[type] || null;
observer.callback(
[entry], [this.cache_[entryURL].properties[type] || null]);
[entry], property);
} else {
observer.pending[entryURL] = entry;
}
Expand Down

0 comments on commit 59725c6

Please sign in to comment.