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

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 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 input.selectionStart = 0; 2605 input.selectionStart = 0;
2606 input.selectionEnd = selectionEnd; 2606 input.selectionEnd = selectionEnd;
2607 } 2607 }
2608 }, 0); 2608 }, 0);
2609 }; 2609 };
2610 2610
2611 /** 2611 /**
2612 * @private 2612 * @private
2613 */ 2613 */
2614 FileManager.prototype.onScanStarted_ = function() { 2614 FileManager.prototype.onScanStarted_ = function() {
2615 if (this.scanInProgress_ && !this.scanUpdatedAtLeastOnceOrCompleted_) { 2615 if (this.scanInProgress_) {
2616 this.table_.list.endBatchUpdates(); 2616 this.table_.list.endBatchUpdates();
2617 this.grid_.endBatchUpdates(); 2617 this.grid_.endBatchUpdates();
2618 } 2618 }
2619 2619
2620 this.updateCommands(); 2620 this.updateCommands();
2621 this.table_.list.startBatchUpdates(); 2621 this.table_.list.startBatchUpdates();
2622 this.grid_.startBatchUpdates(); 2622 this.grid_.startBatchUpdates();
2623 this.scanInProgress_ = true; 2623 this.scanInProgress_ = true;
2624 2624
2625 this.scanUpdatedAtLeastOnceOrCompleted_ = false; 2625 this.scanUpdatedAtLeastOnceOrCompleted_ = false;
(...skipping 20 matching lines...) Expand all
2646 FileManager.prototype.onScanCompleted_ = function() { 2646 FileManager.prototype.onScanCompleted_ = function() {
2647 if (!this.scanInProgress_) { 2647 if (!this.scanInProgress_) {
2648 console.error('Scan-completed event recieved. But scan is not started.'); 2648 console.error('Scan-completed event recieved. But scan is not started.');
2649 return; 2649 return;
2650 } 2650 }
2651 2651
2652 this.updateCommands(); 2652 this.updateCommands();
2653 this.hideSpinnerLater_(); 2653 this.hideSpinnerLater_();
2654 this.refreshCurrentDirectoryMetadata_(); 2654 this.refreshCurrentDirectoryMetadata_();
2655 2655
2656 if (this.scanUpdatedTimer_) {
2657 clearTimeout(this.scanUpdatedTimer_);
2658 this.scanUpdatedTimer_ = null;
2659 }
2660
2656 // To avoid flickering postpone updating the ui by a small amount of time. 2661 // To avoid flickering postpone updating the ui by a small amount of time.
2657 // There is a high chance, that metadata will be received within 50 ms. 2662 // There is a high chance, that metadata will be received within 50 ms.
2658 this.scanCompletedTimer_ = setTimeout(function() { 2663 this.scanCompletedTimer_ = setTimeout(function() {
2659 // Check if batch updates are already finished by onScanUpdated_(). 2664 // Check if batch updates are already finished by onScanUpdated_().
2660 if (this.scanUpdatedAtLeastOnceOrCompleted_) 2665 if (!this.scanUpdatedAtLeastOnceOrCompleted_) {
2661 return; 2666 this.scanUpdatedAtLeastOnceOrCompleted_ = true;
2662 this.scanUpdatedAtLeastOnceOrCompleted_ = true; 2667 this.updateMiddleBarVisibility_();
2668 }
2669
2663 this.scanInProgress_ = false; 2670 this.scanInProgress_ = false;
2664 if (this.scanUpdatedTimer_) {
2665 clearTimeout(this.scanUpdatedTimer_);
2666 this.scanUpdatedTimer_ = null;
2667 }
2668 this.table_.list.endBatchUpdates(); 2671 this.table_.list.endBatchUpdates();
2669 this.grid_.endBatchUpdates(); 2672 this.grid_.endBatchUpdates();
2670 this.updateMiddleBarVisibility_();
2671 this.scanCompletedTimer_ = null; 2673 this.scanCompletedTimer_ = null;
2672 }.bind(this), 50); 2674 }.bind(this), 50);
2673 }; 2675 };
2674 2676
2675 /** 2677 /**
2676 * @private 2678 * @private
2677 */ 2679 */
2678 FileManager.prototype.onScanUpdated_ = function() { 2680 FileManager.prototype.onScanUpdated_ = function() {
2679 if (!this.scanInProgress_) { 2681 if (!this.scanInProgress_) {
2680 console.error('Scan-updated event recieved. But scan is not started.'); 2682 console.error('Scan-updated event recieved. But scan is not started.');
2681 return; 2683 return;
2682 } 2684 }
2683 2685
2684 // We need to hide the spinner only once. 2686 if (this.scanUpdatedTimer_ || this.scanCompletedTimer_)
2685 if (this.scanUpdatedAtLeastOnceOrCompleted_ || this.scanUpdatedTimer_)
2686 return; 2687 return;
2687 2688
2688 // Show contents incrementally by finishing batch updated, but only after 2689 // Show contents incrementally by finishing batch updated, but only after
2689 // 200ms elapsed, to avoid flickering when it is not necessary. 2690 // 200ms elapsed, to avoid flickering when it is not necessary.
2690 this.scanUpdatedTimer_ = setTimeout(function() { 2691 this.scanUpdatedTimer_ = setTimeout(function() {
2691 // We need to hide the spinner only once. 2692 // We need to hide the spinner only once.
2692 if (this.scanUpdatedAtLeastOnceOrCompleted_) 2693 if (!this.scanUpdatedAtLeastOnceOrCompleted_) {
2693 return; 2694 this.scanUpdatedAtLeastOnceOrCompleted_ = true;
2694 if (this.scanCompletedTimer_) { 2695 this.hideSpinnerLater_();
2695 clearTimeout(this.scanCompletedTimer_); 2696 this.updateMiddleBarVisibility_();
2696 this.scanCompletedTimer_ = null;
2697 } 2697 }
2698 this.scanUpdatedAtLeastOnceOrCompleted_ = true; 2698
2699 this.scanInProgress_ = false; 2699 // Update the UI.
2700 this.hideSpinnerLater_(); 2700 if (this.scanInProgress_) {
2701 this.table_.list.endBatchUpdates(); 2701 this.table_.list.endBatchUpdates();
2702 this.grid_.endBatchUpdates(); 2702 this.grid_.endBatchUpdates();
2703 this.updateMiddleBarVisibility_(); 2703 this.table_.list.startBatchUpdates();
2704 this.grid_.startBatchUpdates();
2705 }
2704 this.scanUpdatedTimer_ = null; 2706 this.scanUpdatedTimer_ = null;
2705 }.bind(this), 200); 2707 }.bind(this), 200);
2706 }; 2708 };
2707 2709
2708 /** 2710 /**
2709 * @private 2711 * @private
2710 */ 2712 */
2711 FileManager.prototype.onScanCancelled_ = function() { 2713 FileManager.prototype.onScanCancelled_ = function() {
2712 if (!this.scanInProgress_) { 2714 if (!this.scanInProgress_) {
2713 console.error('Scan-cancelled event recieved. But scan is not started.'); 2715 console.error('Scan-cancelled event recieved. But scan is not started.');
2714 return; 2716 return;
2715 } 2717 }
2716 2718
2717 this.updateCommands(); 2719 this.updateCommands();
2718 this.hideSpinnerLater_(); 2720 this.hideSpinnerLater_();
2719 if (this.scanCompletedTimer_) { 2721 if (this.scanCompletedTimer_) {
2720 clearTimeout(this.scanCompletedTimer_); 2722 clearTimeout(this.scanCompletedTimer_);
2721 this.scanCompletedTimer_ = null; 2723 this.scanCompletedTimer_ = null;
2722 } 2724 }
2723 if (this.scanUpdatedTimer_) { 2725 if (this.scanUpdatedTimer_) {
2724 clearTimeout(this.scanUpdatedTimer_); 2726 clearTimeout(this.scanUpdatedTimer_);
2725 this.scanUpdatedTimer_ = null; 2727 this.scanUpdatedTimer_ = null;
2726 } 2728 }
2727 // Finish unfinished batch updates. 2729 // Finish unfinished batch updates.
2728 if (!this.scanUpdatedAtLeastOnceOrCompleted_) { 2730 if (!this.scanUpdatedAtLeastOnceOrCompleted_) {
2729 this.scanUpdatedAtLeastOnceOrCompleted_ = true; 2731 this.scanUpdatedAtLeastOnceOrCompleted_ = true;
2730 this.scanInProgress_ = false;
2731 this.table_.list.endBatchUpdates();
2732 this.grid_.endBatchUpdates();
2733 this.updateMiddleBarVisibility_(); 2732 this.updateMiddleBarVisibility_();
2734 } 2733 }
2734
2735 this.scanInProgress_ = false;
2736 this.table_.list.endBatchUpdates();
2737 this.grid_.endBatchUpdates();
2735 }; 2738 };
2736 2739
2737 /** 2740 /**
2738 * @private 2741 * @private
2739 */ 2742 */
2740 FileManager.prototype.cancelSpinnerTimeout_ = function() { 2743 FileManager.prototype.cancelSpinnerTimeout_ = function() {
2741 if (this.showSpinnerTimeout_) { 2744 if (this.showSpinnerTimeout_) {
2742 clearTimeout(this.showSpinnerTimeout_); 2745 clearTimeout(this.showSpinnerTimeout_);
2743 this.showSpinnerTimeout_ = null; 2746 this.showSpinnerTimeout_ = null;
2744 } 2747 }
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
3827 */ 3830 */
3828 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { 3831 FileManager.prototype.setCtrlKeyPressed_ = function(flag) {
3829 this.ctrlKeyPressed_ = flag; 3832 this.ctrlKeyPressed_ = flag;
3830 // Before the DOM is constructed, the key event can be handled. 3833 // Before the DOM is constructed, the key event can be handled.
3831 var cacheClearCommand = 3834 var cacheClearCommand =
3832 this.document_.querySelector('#drive-clear-local-cache'); 3835 this.document_.querySelector('#drive-clear-local-cache');
3833 if (cacheClearCommand) 3836 if (cacheClearCommand)
3834 cacheClearCommand.canExecuteChange(); 3837 cacheClearCommand.canExecuteChange();
3835 }; 3838 };
3836 })(); 3839 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698