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

Side by Side Diff: chrome/browser/resources/file_manager/js/directory_model.js

Issue 16351002: Fix problems when renaming and entering a directory fast in Files.app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | chrome/browser/resources/file_manager/js/file_manager.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 // If directory files changes too often, don't rescan directory more than once 7 // If directory files changes too often, don't rescan directory more than once
8 // per specified interval 8 // per specified interval
9 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; 9 var SIMULTANEOUS_RESCAN_INTERVAL = 1000;
10 // Used for operations that require almost instant rescan. 10 // Used for operations that require almost instant rescan.
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 * @param {string} newName New name. 679 * @param {string} newName New name.
680 * @param {function} errorCallback Called on error. 680 * @param {function} errorCallback Called on error.
681 * @param {function()=} opt_successCallback Called on success. 681 * @param {function()=} opt_successCallback Called on success.
682 */ 682 */
683 DirectoryModel.prototype.renameEntry = function(entry, newName, 683 DirectoryModel.prototype.renameEntry = function(entry, newName,
684 errorCallback, 684 errorCallback,
685 opt_successCallback) { 685 opt_successCallback) {
686 var currentDirPath = this.getCurrentDirPath(); 686 var currentDirPath = this.getCurrentDirPath();
687 var onSuccess = function(newEntry) { 687 var onSuccess = function(newEntry) {
688 this.currentDirContents_.prefetchMetadata([newEntry], function() { 688 this.currentDirContents_.prefetchMetadata([newEntry], function() {
689 // Do not change anything or call the callback if current 689 // If the current directory is the old entry, then quietly change to the
690 // directory changed. 690 // new one.
691 if (entry.fullPath == this.getCurrentDirPath())
692 this.changeDirectory(newEntry.fullPath);
693
694 // Update selection and call the success callback if still in the same
695 // directory as while started renaming.
691 if (currentDirPath != this.getCurrentDirPath()) 696 if (currentDirPath != this.getCurrentDirPath())
692 return; 697 return;
693 698
694 var index = this.findIndexByName_(entry.name); 699 var index = this.findIndexByName_(entry.name);
695 700
696 if (index >= 0) { 701 if (index >= 0) {
697 var wasSelected = this.fileListSelection_.getIndexSelected(index); 702 var wasSelected = this.fileListSelection_.getIndexSelected(index);
698 703
699 this.getFileList().splice(index, 1, newEntry); 704 this.getFileList().splice(index, 1, newEntry);
700 705
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 }.bind(this)); 1546 }.bind(this));
1542 } 1547 }
1543 }; 1548 };
1544 1549
1545 /** 1550 /**
1546 * @return {DirectoryEntry} Current watched directory entry. 1551 * @return {DirectoryEntry} Current watched directory entry.
1547 */ 1552 */
1548 FileWatcher.prototype.getWatchedDirectoryEntry = function() { 1553 FileWatcher.prototype.getWatchedDirectoryEntry = function() {
1549 return this.watchedDirectoryEntry_; 1554 return this.watchedDirectoryEntry_;
1550 }; 1555 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698