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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/directory_contents.js

Issue 486783006: Files.app: Update the list partially when changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the test filure & rebase Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_model.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Scanner of the entries. 8 * Scanner of the entries.
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 // TODO(hidehiko,mtomasz): this scan method must be called at most once. 657 // TODO(hidehiko,mtomasz): this scan method must be called at most once.
658 // Remove such a limitation. 658 // Remove such a limitation.
659 this.scanner_ = this.scannerFactory_(); 659 this.scanner_ = this.scannerFactory_();
660 this.scanner_.scan(this.onNewEntries_.bind(this, refresh), 660 this.scanner_.scan(this.onNewEntries_.bind(this, refresh),
661 completionCallback.bind(this), 661 completionCallback.bind(this),
662 errorCallback.bind(this)); 662 errorCallback.bind(this));
663 }; 663 };
664 664
665 /** 665 /**
666 * Adds/removes/updates items of file list.
667 * @param {Array.<Entry>} updatedEntries Entries of updated/added files.
668 * @param {Array.<string>} removedUrls URLs of removed files.
669 */
670 DirectoryContents.prototype.update = function(updatedEntries, removedUrls) {
671 var removedMap = {};
672 for (var i = 0; i < removedUrls.length; i++) {
673 removedMap[removedUrls[i]] = true;
674 }
675
676 var updatedMap = {};
677 for (var i = 0; i < updatedEntries.length; i++) {
678 updatedMap[updatedEntries[i].toURL()] = updatedEntries[i];
679 }
680
681 var updatedList = [];
682 for (var i = 0; i < this.fileList_.length; i++) {
683 var url = this.fileList_.item(i).toURL();
684
685 if (url in removedMap) {
686 this.fileList_.splice(i, 1);
687 i--;
688 continue;
689 }
690
691 if (url in updatedMap) {
692 updatedList.push(updatedMap[url]);
693 delete updatedMap[url];
694 }
695 }
696
697 var addedList = [];
698 for (var url in updatedMap) {
699 addedList.push(updatedMap[url]);
700 }
701
702 if (removedUrls.length > 0)
703 this.fileList_.metadataCache_.clearByUrl(removedUrls, '*');
704
705 this.prefetchMetadata(updatedList, true, function() {
706 this.onNewEntries_(true, addedList);
707 this.onScanFinished_();
708 this.onScanCompleted_();
709 }.bind(this));
710 };
711
712 /**
666 * Cancels the running scan. 713 * Cancels the running scan.
667 */ 714 */
668 DirectoryContents.prototype.cancelScan = function() { 715 DirectoryContents.prototype.cancelScan = function() {
669 if (this.scanCancelled_) 716 if (this.scanCancelled_)
670 return; 717 return;
671 this.scanCancelled_ = true; 718 this.scanCancelled_ = true;
672 if (this.scanner_) 719 if (this.scanner_)
673 this.scanner_.cancel(); 720 this.scanner_.cancel();
674 721
675 this.onScanFinished_(); 722 this.onScanFinished_();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 DirectoryContents.createForDriveMetadataSearch = function( 937 DirectoryContents.createForDriveMetadataSearch = function(
891 context, fakeDirectoryEntry, searchType) { 938 context, fakeDirectoryEntry, searchType) {
892 return new DirectoryContents( 939 return new DirectoryContents(
893 context, 940 context,
894 true, // Search 941 true, // Search
895 fakeDirectoryEntry, 942 fakeDirectoryEntry,
896 function() { 943 function() {
897 return new DriveMetadataSearchContentScanner(searchType); 944 return new DriveMetadataSearchContentScanner(searchType);
898 }); 945 });
899 }; 946 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698