Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Unified Diff: ui/file_manager/file_manager/background/js/mock_media_scanner.js

Issue 899943002: Rework update model to eliminate a "flicker" resulting from the brief update to zero results when a… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use drive icon in dialog for now, since this breaks funcitonal tests. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/background/js/mock_media_scanner.js
diff --git a/ui/file_manager/file_manager/background/js/mock_media_scanner.js b/ui/file_manager/file_manager/background/js/mock_media_scanner.js
index 59f21e9e958830536654ea032900a06e3b4f6f19..407c02f886273ed279fa0c4976f368ab1c35574c 100644
--- a/ui/file_manager/file_manager/background/js/mock_media_scanner.js
+++ b/ui/file_manager/file_manager/background/js/mock_media_scanner.js
@@ -47,11 +47,11 @@ TestMediaScanner.prototype.removeObserver = function(observer) {
/** @override */
TestMediaScanner.prototype.scan = function(entries) {
- var result = new TestScanResult(this.fileEntries);
- result.totalBytes = this.totalBytes;
- result.scanDuration = this.scanDuration;
- this.scans_.push(result);
- return result;
+ var scan = new TestScanResult(this.fileEntries);
+ scan.totalBytes = this.totalBytes;
+ scan.scanDuration = this.scanDuration;
+ this.scans_.push(scan);
+ return scan;
};
/**
@@ -62,6 +62,19 @@ TestMediaScanner.prototype.finalizeScans = function() {
};
/**
+ * Notifies observers that the most recently started scan has been updated.
+ * @param {!importer.ScanResult} result
+ */
+TestMediaScanner.prototype.update = function() {
+ assertTrue(this.scans_.length > 0);
+ var scan = this.scans_[this.scans_.length - 1];
+ this.observers.forEach(
+ function(observer) {
+ observer(importer.ScanEvent.UPDATED, scan);
+ });
+};
+
+/**
* Notifies observers that a scan has finished.
* @param {!importer.ScanResult} result
*/
« no previous file with comments | « ui/file_manager/file_manager/background/js/media_scanner.js ('k') | ui/file_manager/file_manager/common/js/importer_common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698