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

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

Issue 25278002: Extract ContentScanner from DirectoryContent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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 * FileManager constructor. 8 * FileManager constructor.
9 * 9 *
10 * FileManager objects encapsulate the functionality of the file selector 10 * FileManager objects encapsulate the functionality of the file selector
(...skipping 2651 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 input.selectionStart = 0; 2662 input.selectionStart = 0;
2663 input.selectionEnd = selectionEnd; 2663 input.selectionEnd = selectionEnd;
2664 } 2664 }
2665 }, 0); 2665 }, 0);
2666 }; 2666 };
2667 2667
2668 /** 2668 /**
2669 * @private 2669 * @private
2670 */ 2670 */
2671 FileManager.prototype.onScanStarted_ = function() { 2671 FileManager.prototype.onScanStarted_ = function() {
2672 if (this.scanInProgress_ && !this.scanUpdatedAtLeastOnceOrCompleted_) { 2672 if (this.scanInProgress_) {
2673 this.table_.list.endBatchUpdates(); 2673 this.table_.list.endBatchUpdates();
2674 this.grid_.endBatchUpdates(); 2674 this.grid_.endBatchUpdates();
2675 } 2675 }
2676 2676
2677 this.updateCommands(); 2677 this.updateCommands();
2678 this.table_.list.startBatchUpdates(); 2678 this.table_.list.startBatchUpdates();
2679 this.grid_.startBatchUpdates(); 2679 this.grid_.startBatchUpdates();
2680 this.scanInProgress_ = true; 2680 this.scanInProgress_ = true;
2681 2681
2682 this.scanUpdatedAtLeastOnceOrCompleted_ = false; 2682 this.scanUpdatedAtLeastOnceOrCompleted_ = false;
(...skipping 20 matching lines...) Expand all
2703 FileManager.prototype.onScanCompleted_ = function() { 2703 FileManager.prototype.onScanCompleted_ = function() {
2704 if (!this.scanInProgress_) { 2704 if (!this.scanInProgress_) {
2705 console.error('Scan-completed event recieved. But scan is not started.'); 2705 console.error('Scan-completed event recieved. But scan is not started.');
2706 return; 2706 return;
2707 } 2707 }
2708 2708
2709 this.updateCommands(); 2709 this.updateCommands();
2710 this.hideSpinnerLater_(); 2710 this.hideSpinnerLater_();
2711 this.refreshCurrentDirectoryMetadata_(); 2711 this.refreshCurrentDirectoryMetadata_();
2712 2712
2713 if (this.scanUpdatedTimer_) {
mtomasz 2013/10/01 02:13:44 Can you please briefly explain this change? Thanks
hidehiko 2013/10/01 04:12:23 This patch fixes some weird event firing in Direct
2714 clearTimeout(this.scanUpdatedTimer_);
2715 this.scanUpdatedTimer_ = null;
2716 }
2717
2713 // To avoid flickering postpone updating the ui by a small amount of time. 2718 // To avoid flickering postpone updating the ui by a small amount of time.
2714 // There is a high chance, that metadata will be received within 50 ms. 2719 // There is a high chance, that metadata will be received within 50 ms.
2715 this.scanCompletedTimer_ = setTimeout(function() { 2720 this.scanCompletedTimer_ = setTimeout(function() {
2716 // Check if batch updates are already finished by onScanUpdated_(). 2721 // Check if batch updates are already finished by onScanUpdated_().
2717 if (this.scanUpdatedAtLeastOnceOrCompleted_) 2722 if (!this.scanUpdatedAtLeastOnceOrCompleted_) {
2718 return; 2723 this.scanUpdatedAtLeastOnceOrCompleted_ = true;
2719 this.scanUpdatedAtLeastOnceOrCompleted_ = true; 2724 this.updateMiddleBarVisibility_();
2725 }
2726
2720 this.scanInProgress_ = false; 2727 this.scanInProgress_ = false;
2721 if (this.scanUpdatedTimer_) {
2722 clearTimeout(this.scanUpdatedTimer_);
2723 this.scanUpdatedTimer_ = null;
2724 }
2725 this.table_.list.endBatchUpdates(); 2728 this.table_.list.endBatchUpdates();
2726 this.grid_.endBatchUpdates(); 2729 this.grid_.endBatchUpdates();
2727 this.updateMiddleBarVisibility_();
2728 this.scanCompletedTimer_ = null; 2730 this.scanCompletedTimer_ = null;
2729 }.bind(this), 50); 2731 }.bind(this), 50);
2730 }; 2732 };
2731 2733
2732 /** 2734 /**
2733 * @private 2735 * @private
2734 */ 2736 */
2735 FileManager.prototype.onScanUpdated_ = function() { 2737 FileManager.prototype.onScanUpdated_ = function() {
2736 if (!this.scanInProgress_) { 2738 if (!this.scanInProgress_) {
2737 console.error('Scan-updated event recieved. But scan is not started.'); 2739 console.error('Scan-updated event recieved. But scan is not started.');
2738 return; 2740 return;
2739 } 2741 }
2740 2742
2741 // We need to hide the spinner only once. 2743 if (this.scanUpdatedTimer_ || this.scanCompletedTimer_)
2742 if (this.scanUpdatedAtLeastOnceOrCompleted_ || this.scanUpdatedTimer_)
2743 return; 2744 return;
2744 2745
2745 // Show contents incrementally by finishing batch updated, but only after 2746 // Show contents incrementally by finishing batch updated, but only after
2746 // 200ms elapsed, to avoid flickering when it is not necessary. 2747 // 200ms elapsed, to avoid flickering when it is not necessary.
2747 this.scanUpdatedTimer_ = setTimeout(function() { 2748 this.scanUpdatedTimer_ = setTimeout(function() {
2748 // We need to hide the spinner only once. 2749 // We need to hide the spinner only once.
2749 if (this.scanUpdatedAtLeastOnceOrCompleted_) 2750 if (!this.scanUpdatedAtLeastOnceOrCompleted_) {
2750 return; 2751 this.scanUpdatedAtLeastOnceOrCompleted_ = true;
2751 if (this.scanCompletedTimer_) { 2752 this.hideSpinnerLater_();
2752 clearTimeout(this.scanCompletedTimer_); 2753 this.updateMiddleBarVisibility_();
2753 this.scanCompletedTimer_ = null;
2754 } 2754 }
2755 this.scanUpdatedAtLeastOnceOrCompleted_ = true; 2755
2756 this.scanInProgress_ = false; 2756 // Update the UI.
2757 this.hideSpinnerLater_(); 2757 if (this.scanInProgress_) {
2758 this.table_.list.endBatchUpdates(); 2758 this.table_.list.endBatchUpdates();
2759 this.grid_.endBatchUpdates(); 2759 this.grid_.endBatchUpdates();
2760 this.updateMiddleBarVisibility_(); 2760 this.table_.list.startBatchUpdates();
2761 this.grid_.startBatchUpdates();
2762 }
2761 this.scanUpdatedTimer_ = null; 2763 this.scanUpdatedTimer_ = null;
2762 }.bind(this), 200); 2764 }.bind(this), 200);
2763 }; 2765 };
2764 2766
2765 /** 2767 /**
2766 * @private 2768 * @private
2767 */ 2769 */
2768 FileManager.prototype.onScanCancelled_ = function() { 2770 FileManager.prototype.onScanCancelled_ = function() {
2769 if (!this.scanInProgress_) { 2771 if (!this.scanInProgress_) {
2770 console.error('Scan-cancelled event recieved. But scan is not started.'); 2772 console.error('Scan-cancelled event recieved. But scan is not started.');
2771 return; 2773 return;
2772 } 2774 }
2773 2775
2774 this.updateCommands(); 2776 this.updateCommands();
2775 this.hideSpinnerLater_(); 2777 this.hideSpinnerLater_();
2776 if (this.scanCompletedTimer_) { 2778 if (this.scanCompletedTimer_) {
2777 clearTimeout(this.scanCompletedTimer_); 2779 clearTimeout(this.scanCompletedTimer_);
2778 this.scanCompletedTimer_ = null; 2780 this.scanCompletedTimer_ = null;
2779 } 2781 }
2780 if (this.scanUpdatedTimer_) { 2782 if (this.scanUpdatedTimer_) {
2781 clearTimeout(this.scanUpdatedTimer_); 2783 clearTimeout(this.scanUpdatedTimer_);
2782 this.scanUpdatedTimer_ = null; 2784 this.scanUpdatedTimer_ = null;
2783 } 2785 }
2784 // Finish unfinished batch updates. 2786 // Finish unfinished batch updates.
2785 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { 2787 if (!this.scanUpdatedAtLeastOnceOrCompleted_) {
2786 this.scanUpdatedAtLeastOnceOrCompleted_ = true; 2788 this.scanUpdatedAtLeastOnceOrCompleted_ = true;
2789 this.updateMiddleBarVisibility_();
2790 }
2791 if (this.scanInProgress_) {
mtomasz 2013/10/01 02:25:23 This will always return true because of #2771, so
hidehiko 2013/10/01 04:12:23 Done.
2787 this.scanInProgress_ = false; 2792 this.scanInProgress_ = false;
2788 this.table_.list.endBatchUpdates(); 2793 this.table_.list.endBatchUpdates();
2789 this.grid_.endBatchUpdates(); 2794 this.grid_.endBatchUpdates();
2790 this.updateMiddleBarVisibility_();
2791 } 2795 }
2792 }; 2796 };
2793 2797
2794 /** 2798 /**
2795 * @private 2799 * @private
2796 */ 2800 */
2797 FileManager.prototype.cancelSpinnerTimeout_ = function() { 2801 FileManager.prototype.cancelSpinnerTimeout_ = function() {
2798 if (this.showSpinnerTimeout_) { 2802 if (this.showSpinnerTimeout_) {
2799 clearTimeout(this.showSpinnerTimeout_); 2803 clearTimeout(this.showSpinnerTimeout_);
2800 this.showSpinnerTimeout_ = null; 2804 this.showSpinnerTimeout_ = null;
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 */ 3888 */
3885 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { 3889 FileManager.prototype.setCtrlKeyPressed_ = function(flag) {
3886 this.ctrlKeyPressed_ = flag; 3890 this.ctrlKeyPressed_ = flag;
3887 // Before the DOM is constructed, the key event can be handled. 3891 // Before the DOM is constructed, the key event can be handled.
3888 var cacheClearCommand = 3892 var cacheClearCommand =
3889 this.document_.querySelector('#drive-clear-local-cache'); 3893 this.document_.querySelector('#drive-clear-local-cache');
3890 if (cacheClearCommand) 3894 if (cacheClearCommand)
3891 cacheClearCommand.canExecuteChange(); 3895 cacheClearCommand.canExecuteChange();
3892 }; 3896 };
3893 })(); 3897 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698