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

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

Issue 11226002: Files app: fixed infinite Google Drive loading spinner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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
« no previous file with comments | « no previous file | no next file » | 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 // If directory files changes too often, don't rescan directory more than once 5 // If directory files changes too often, don't rescan directory more than once
6 // per specified interval 6 // per specified interval
7 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; 7 var SIMULTANEOUS_RESCAN_INTERVAL = 1000;
8 // Used for operations that require almost instant rescan. 8 // Used for operations that require almost instant rescan.
9 var SHORT_RESCAN_INTERVAL = 100; 9 var SHORT_RESCAN_INTERVAL = 100;
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 * DirectoryModel extends cr.EventTarget. 69 * DirectoryModel extends cr.EventTarget.
70 */ 70 */
71 DirectoryModel.prototype.__proto__ = cr.EventTarget.prototype; 71 DirectoryModel.prototype.__proto__ = cr.EventTarget.prototype;
72 72
73 /** 73 /**
74 * Fills the root list and starts tracking changes. 74 * Fills the root list and starts tracking changes.
75 */ 75 */
76 DirectoryModel.prototype.start = function() { 76 DirectoryModel.prototype.start = function() {
77 var volumesChangeHandler = this.onMountChanged_.bind(this); 77 var volumesChangeHandler = this.onMountChanged_.bind(this);
78 this.volumeManager_.addEventListener('change', volumesChangeHandler); 78 this.volumeManager_.addEventListener('change', volumesChangeHandler);
79 this.volumeManager_.addEventListener('gdata-status-changed',
80 this.onGDataStatusChanged_.bind(this));
79 this.updateRoots_(); 81 this.updateRoots_();
80 }; 82 };
81 83
82 /** 84 /**
83 * @return {cr.ui.ArrayDataModel} Files in the current directory. 85 * @return {cr.ui.ArrayDataModel} Files in the current directory.
84 */ 86 */
85 DirectoryModel.prototype.getFileList = function() { 87 DirectoryModel.prototype.getFileList = function() {
86 return this.currentFileListContext_.fileList; 88 return this.currentFileListContext_.fileList;
87 }; 89 };
88 90
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1078
1077 /** 1079 /**
1078 * @private 1080 * @private
1079 */ 1081 */
1080 DirectoryModel.prototype.updateRootsListSelection_ = function() { 1082 DirectoryModel.prototype.updateRootsListSelection_ = function() {
1081 var rootPath = this.getCurrentRootPath(); 1083 var rootPath = this.getCurrentRootPath();
1082 this.rootsListSelection_.selectedIndex = this.findRootsListIndex(rootPath); 1084 this.rootsListSelection_.selectedIndex = this.findRootsListIndex(rootPath);
1083 }; 1085 };
1084 1086
1085 /** 1087 /**
1086 * @return {boolean} True if GDATA if fully mounted. 1088 * @return {boolean} True if GDATA is fully mounted.
1087 * @private 1089 * @private
1088 */ 1090 */
1089 DirectoryModel.prototype.isGDataMounted_ = function() { 1091 DirectoryModel.prototype.isGDataMounted_ = function() {
1090 return this.volumeManager_.getGDataStatus() == 1092 return this.volumeManager_.getGDataStatus() ==
1091 VolumeManager.GDataStatus.MOUNTED; 1093 VolumeManager.GDataStatus.MOUNTED;
1092 }; 1094 };
1093 1095
1094 /** 1096 /**
1095 * Handler for the VolumeManager's event. 1097 * Handler for the VolumeManager's 'change' event.
1096 * @private 1098 * @private
1097 */ 1099 */
1098 DirectoryModel.prototype.onMountChanged_ = function() { 1100 DirectoryModel.prototype.onMountChanged_ = function() {
1099 this.updateRoots_(); 1101 this.updateRoots_();
1100 1102
1101 var rootType = this.getCurrentRootType(); 1103 var rootType = this.getCurrentRootType();
1102 1104
1103 if ((rootType == RootType.ARCHIVE || rootType == RootType.REMOVABLE) && 1105 if ((rootType == RootType.ARCHIVE || rootType == RootType.REMOVABLE) &&
1104 !this.volumeManager_.isMounted(this.getCurrentRootPath())) { 1106 !this.volumeManager_.isMounted(this.getCurrentRootPath())) {
1105 this.changeDirectory(this.getDefaultDirectory()); 1107 this.changeDirectory(this.getDefaultDirectory());
1106 } 1108 }
1109 };
1107 1110
1108 if (rootType != RootType.GDATA) 1111 /**
1109 return; 1112 * Handler for the VolumeManager's 'gdata-status-changed' event.
1113 * @private
1114 */
1115 DirectoryModel.prototype.onGDataStatusChanged_ = function() {
1116 if (this.getCurrentRootType() != RootType.GDATA)
1117 return;
1110 1118
1111 var mounted = this.isGDataMounted_(); 1119 var mounted = this.isGDataMounted_();
1112 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) { 1120 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) {
1113 if (mounted) { 1121 if (mounted) {
1114 // Change fake entry to real one and rescan. 1122 // Change fake entry to real one and rescan.
1115 function onGotDirectory(entry) { 1123 function onGotDirectory(entry) {
1116 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) { 1124 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) {
1117 this.changeDirectoryEntrySilent_(entry); 1125 this.changeDirectoryEntrySilent_(entry);
1118 } 1126 }
1119 } 1127 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 }.bind(this)); 1376 }.bind(this));
1369 } 1377 }
1370 }; 1378 };
1371 1379
1372 /** 1380 /**
1373 * @return {DirectoryEntry} Current watched directory entry. 1381 * @return {DirectoryEntry} Current watched directory entry.
1374 */ 1382 */
1375 FileWatcher.prototype.getWatchedDirectoryEntry = function() { 1383 FileWatcher.prototype.getWatchedDirectoryEntry = function() {
1376 return this.watchedDirectoryEntry_; 1384 return this.watchedDirectoryEntry_;
1377 }; 1385 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698