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 /** | 5 /** |
6 * VolumeManager is responsible for tracking list of mounted volumes. | 6 * VolumeManager is responsible for tracking list of mounted volumes. |
7 * | 7 * |
8 * @constructor | 8 * @constructor |
9 * @extends {cr.EventTarget} | 9 * @extends {cr.EventTarget} |
10 */ | 10 */ |
11 function VolumeManager() { | 11 function VolumeManager() { |
12 /** | 12 /** |
13 * The list of archives requested to mount. We will show contents once | 13 * The list of archives requested to mount. We will show contents once |
14 * archive is mounted, but only for mounts from within this filebrowser tab. | 14 * archive is mounted, but only for mounts from within this filebrowser tab. |
15 * @type {Object.<string, Object>} | 15 * @type {Object.<string, Object>} |
16 * @private | 16 * @private |
17 */ | 17 */ |
18 this.requests_ = {}; | 18 this.requests_ = {}; |
19 | 19 |
20 /** | 20 /** |
21 * @type {Object.<string, Object>} | 21 * @type {Object.<string, Object>} |
22 * @private | 22 * @private |
23 */ | 23 */ |
24 this.mountedVolumes_ = {}; | 24 this.mountedVolumes_ = {}; |
25 | 25 |
26 this.initMountPoints_(); | 26 this.initMountPoints_(); |
27 chrome.fileBrowserPrivate.onMountCompleted.addListener( | |
28 this.onMountCompleted_.bind(this)); | |
29 this.gDataStatus_ = VolumeManager.GDataStatus.UNMOUNTED; | 27 this.gDataStatus_ = VolumeManager.GDataStatus.UNMOUNTED; |
30 } | 28 } |
31 | 29 |
32 /** | 30 /** |
33 * VolumeManager extends cr.EventTarget. | 31 * VolumeManager extends cr.EventTarget. |
34 */ | 32 */ |
35 VolumeManager.prototype.__proto__ = cr.EventTarget.prototype; | 33 VolumeManager.prototype.__proto__ = cr.EventTarget.prototype; |
36 | 34 |
37 /** | 35 /** |
38 * @enum | 36 * @enum |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 mountedVolumes.push(volume); | 125 mountedVolumes.push(volume); |
128 index++; | 126 index++; |
129 step(mountPoints); | 127 step(mountPoints); |
130 } | 128 } |
131 self.makeVolumeInfo_('/' + info.mountPath, error, onVolumeInfo); | 129 self.makeVolumeInfo_('/' + info.mountPath, error, onVolumeInfo); |
132 } else { | 130 } else { |
133 for (var i = 0; i < mountedVolumes.length; i++) { | 131 for (var i = 0; i < mountedVolumes.length; i++) { |
134 var volume = mountedVolumes[i]; | 132 var volume = mountedVolumes[i]; |
135 self.mountedVolumes_[volume.mountPath] = volume; | 133 self.mountedVolumes_[volume.mountPath] = volume; |
136 } | 134 } |
| 135 |
| 136 // Subscribe to the mount completed event when mount points initialized. |
| 137 chrome.fileBrowserPrivate.onMountCompleted.addListener( |
| 138 self.onMountCompleted_.bind(self)); |
| 139 |
137 if (mountedVolumes.length > 0) | 140 if (mountedVolumes.length > 0) |
138 cr.dispatchSimpleEvent(self, 'change'); | 141 cr.dispatchSimpleEvent(self, 'change'); |
139 } | 142 } |
140 } | 143 } |
141 | 144 |
142 chrome.fileBrowserPrivate.getMountPoints(step); | 145 chrome.fileBrowserPrivate.getMountPoints(step); |
143 }; | 146 }; |
144 | 147 |
145 /** | 148 /** |
146 * Event handler called when some volume was mounted or unmouted. | 149 * Event handler called when some volume was mounted or unmouted. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 }; | 465 }; |
463 | 466 |
464 /** | 467 /** |
465 * @param {string} mountPath Mount path. | 468 * @param {string} mountPath Mount path. |
466 * @private | 469 * @private |
467 */ | 470 */ |
468 VolumeManager.prototype.validateMountPath_ = function(mountPath) { | 471 VolumeManager.prototype.validateMountPath_ = function(mountPath) { |
469 if (!/^\/(((archive|removable)\/[^\/]+)|drive|Downloads)$/.test(mountPath)) | 472 if (!/^\/(((archive|removable)\/[^\/]+)|drive|Downloads)$/.test(mountPath)) |
470 throw new Error('Invalid mount path: ', mountPath); | 473 throw new Error('Invalid mount path: ', mountPath); |
471 }; | 474 }; |
OLD | NEW |