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

Side by Side Diff: ui/file_manager/file_manager/common/js/util.js

Issue 2833413003: Reuse FileTasks when entries are not changed. (Closed)
Patch Set: Use getter for FileTasks.entries. Created 3 years, 8 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
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/file_tasks.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 /** 5 /**
6 * Namespace for utility functions. 6 * Namespace for utility functions.
7 */ 7 */
8 var util = {}; 8 var util = {};
9 9
10 /** 10 /**
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 */ 676 */
677 util.isSameEntry = function(entry1, entry2) { 677 util.isSameEntry = function(entry1, entry2) {
678 if (!entry1 && !entry2) 678 if (!entry1 && !entry2)
679 return true; 679 return true;
680 if (!entry1 || !entry2) 680 if (!entry1 || !entry2)
681 return false; 681 return false;
682 return entry1.toURL() === entry2.toURL(); 682 return entry1.toURL() === entry2.toURL();
683 }; 683 };
684 684
685 /** 685 /**
686 * Compares two entry arrays.
687 * @param {Array<!Entry>} entries1 The entry array to be compared.
688 * @param {Array<!Entry>} entries2 The entry array to be compared.
689 * @return {boolean} True if the both arrays contain same files or directories
690 * in the same order. Returns true if both arrays are null.
691 */
692 util.isSameEntries = function(entries1, entries2) {
693 if (!entries1 && !entries2)
694 return true;
695 if (!entries1 || !entries2)
696 return false;
697 if (entries1.length !== entries2.length)
698 return false;
699 for (var i = 0; i < entries1.length; i++) {
700 if (!util.isSameEntry(entries1[i], entries2[i])) {
701 return false;
702 }
703 }
704 return true;
705 };
706
707 /**
686 * Compares two file systems. 708 * Compares two file systems.
687 * @param {FileSystem} fileSystem1 The file system to be compared. 709 * @param {FileSystem} fileSystem1 The file system to be compared.
688 * @param {FileSystem} fileSystem2 The file system to be compared. 710 * @param {FileSystem} fileSystem2 The file system to be compared.
689 * @return {boolean} True if the both file systems are equal. Also, returns true 711 * @return {boolean} True if the both file systems are equal. Also, returns true
690 * if both file systems are null. 712 * if both file systems are null.
691 */ 713 */
692 util.isSameFileSystem = function(fileSystem1, fileSystem2) { 714 util.isSameFileSystem = function(fileSystem1, fileSystem2) {
693 if (!fileSystem1 && !fileSystem2) 715 if (!fileSystem1 && !fileSystem2)
694 return true; 716 return true;
695 if (!fileSystem1 || !fileSystem2) 717 if (!fileSystem1 || !fileSystem2)
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 * @return {!Promise} A promise which can be rejected by timeout. 1101 * @return {!Promise} A promise which can be rejected by timeout.
1080 */ 1102 */
1081 util.timeoutPromise = function(promise, ms, opt_message) { 1103 util.timeoutPromise = function(promise, ms, opt_message) {
1082 return Promise.race([ 1104 return Promise.race([
1083 promise, 1105 promise,
1084 util.delay(ms).then(function() { 1106 util.delay(ms).then(function() {
1085 throw new Error(opt_message || 'Operation timed out.'); 1107 throw new Error(opt_message || 'Operation timed out.');
1086 }) 1108 })
1087 ]); 1109 ]);
1088 }; 1110 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/file_tasks.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698