Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 /** |
|
SeRya
2012/10/19 11:00:25
The removed condition was essential. You mustn't d
Vladislav Kaznacheev
2012/10/19 13:48:40
Done.
| |
| 1109 return; | 1112 * Handler for the VolumeManager's 'gdata-status-changed' event. |
| 1110 | 1113 * @private |
| 1114 */ | |
| 1115 DirectoryModel.prototype.onGDataStatusChanged_ = function() { | |
| 1111 var mounted = this.isGDataMounted_(); | 1116 var mounted = this.isGDataMounted_(); |
| 1112 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) { | 1117 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) { |
| 1113 if (mounted) { | 1118 if (mounted) { |
| 1114 // Change fake entry to real one and rescan. | 1119 // Change fake entry to real one and rescan. |
| 1115 function onGotDirectory(entry) { | 1120 function onGotDirectory(entry) { |
| 1116 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) { | 1121 if (this.getCurrentDirEntry() == DirectoryModel.fakeGDataEntry_) { |
| 1117 this.changeDirectoryEntrySilent_(entry); | 1122 this.changeDirectoryEntrySilent_(entry); |
| 1118 } | 1123 } |
| 1119 } | 1124 } |
| 1120 this.root_.getDirectory(RootDirectory.GDATA, {}, | 1125 this.root_.getDirectory(RootDirectory.GDATA, {}, |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1368 }.bind(this)); | 1373 }.bind(this)); |
| 1369 } | 1374 } |
| 1370 }; | 1375 }; |
| 1371 | 1376 |
| 1372 /** | 1377 /** |
| 1373 * @return {DirectoryEntry} Current watched directory entry. | 1378 * @return {DirectoryEntry} Current watched directory entry. |
| 1374 */ | 1379 */ |
| 1375 FileWatcher.prototype.getWatchedDirectoryEntry = function() { | 1380 FileWatcher.prototype.getWatchedDirectoryEntry = function() { |
| 1376 return this.watchedDirectoryEntry_; | 1381 return this.watchedDirectoryEntry_; |
| 1377 }; | 1382 }; |
| OLD | NEW |