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

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

Issue 11414152: Drive: Rename GData to Drive in extension JS API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Change 'gdata' to 'drive' of mount type. Created 8 years 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
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 /** 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 */
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * @enum 54 * @enum
55 */ 55 */
56 VolumeManager.GDataStatus = { 56 VolumeManager.GDataStatus = {
57 UNMOUNTED: 'unmounted', 57 UNMOUNTED: 'unmounted',
58 MOUNTING: 'mounting', 58 MOUNTING: 'mounting',
59 ERROR: 'error', 59 ERROR: 'error',
60 MOUNTED: 'mounted' 60 MOUNTED: 'mounted'
61 }; 61 };
62 62
63 /** 63 /**
64 * @enum
65 */
66 VolumeManager.MountType = {
67 DEVICE: 'device',
68 FILE: 'file',
69 NETWORK: 'network',
70 DRIVE: 'drive'
71 };
satorux1 2012/11/26 05:50:40 Looks like a good cleanup, but I think we should d
yoshiki 2012/11/26 06:07:22 Got it, I'll do that at another CL.
72
73 /**
64 * Time in milliseconds that we wait a respone for. If no response on 74 * Time in milliseconds that we wait a respone for. If no response on
65 * mount/unmount received the request supposed failed. 75 * mount/unmount received the request supposed failed.
66 */ 76 */
67 VolumeManager.TIMEOUT = 15 * 60 * 1000; 77 VolumeManager.TIMEOUT = 15 * 60 * 1000;
68 78
69 /** 79 /**
70 * Delay in milliseconds GDATA changes its state from |UNMOUNTED| to 80 * Delay in milliseconds GDATA changes its state from |UNMOUNTED| to
71 * |MOUNTING|. Used to display progress in the UI. 81 * |MOUNTING|. Used to display progress in the UI.
72 */ 82 */
73 VolumeManager.MOUNTING_DELAY = 500; 83 VolumeManager.MOUNTING_DELAY = 500;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 * @private 122 * @private
113 */ 123 */
114 VolumeManager.prototype.initMountPoints_ = function() { 124 VolumeManager.prototype.initMountPoints_ = function() {
115 var mountedVolumes = []; 125 var mountedVolumes = [];
116 var self = this; 126 var self = this;
117 var index = 0; 127 var index = 0;
118 this.deferredQueue_ = []; 128 this.deferredQueue_ = [];
119 function step(mountPoints) { 129 function step(mountPoints) {
120 if (index < mountPoints.length) { 130 if (index < mountPoints.length) {
121 var info = mountPoints[index]; 131 var info = mountPoints[index];
122 if (info.mountType == 'gdata') 132 if (info.mountType == VolumeManager.MountType.DRIVE)
123 console.error('GData is not expected initially mounted'); 133 console.error('GData is not expected initially mounted');
124 var error = info.mountCondition ? 'error_' + info.mountCondition : ''; 134 var error = info.mountCondition ? 'error_' + info.mountCondition : '';
125 function onVolumeInfo(volume) { 135 function onVolumeInfo(volume) {
126 mountedVolumes.push(volume); 136 mountedVolumes.push(volume);
127 index++; 137 index++;
128 step(mountPoints); 138 step(mountPoints);
129 } 139 }
130 self.makeVolumeInfo_('/' + info.mountPath, error, onVolumeInfo); 140 self.makeVolumeInfo_('/' + info.mountPath, error, onVolumeInfo);
131 } else { 141 } else {
132 for (var i = 0; i < mountedVolumes.length; i++) { 142 for (var i = 0; i < mountedVolumes.length; i++) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 this.dispatchEvent(e); 200 this.dispatchEvent(e);
191 } 201 }
192 this.finishRequest_(requestKey, status); 202 this.finishRequest_(requestKey, status);
193 203
194 if (event.status == 'success') { 204 if (event.status == 'success') {
195 delete this.mountedVolumes_[mountPath]; 205 delete this.mountedVolumes_[mountPath];
196 cr.dispatchSimpleEvent(this, 'change'); 206 cr.dispatchSimpleEvent(this, 'change');
197 } 207 }
198 } 208 }
199 209
200 if (event.mountType == 'gdata') { 210 if (event.mountType == VolumeManager.MountType.DRIVE) {
201 if (event.status == 'success') { 211 if (event.status == 'success') {
202 if (event.eventType == 'mount') { 212 if (event.eventType == 'mount') {
203 // If the mount is not requested, the mount status will not be changed 213 // If the mount is not requested, the mount status will not be changed
204 // at mountGData(). Sets it here in such a case. 214 // at mountGData(). Sets it here in such a case.
205 var self = this; 215 var self = this;
206 var timeout = setTimeout(function() { 216 var timeout = setTimeout(function() {
207 if (self.getGDataStatus() == VolumeManager.GDataStatus.UNMOUNTED) 217 if (self.getGDataStatus() == VolumeManager.GDataStatus.UNMOUNTED)
208 self.setGDataStatus_(VolumeManager.GDataStatus.MOUNTING); 218 self.setGDataStatus_(VolumeManager.GDataStatus.MOUNTING);
209 timeout = null; 219 timeout = null;
210 }, VolumeManager.MOUNTING_DELAY); 220 }, VolumeManager.MOUNTING_DELAY);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 293
284 /** 294 /**
285 * @param {Function} successCallback Success callback. 295 * @param {Function} successCallback Success callback.
286 * @param {Function} errorCallback Error callback. 296 * @param {Function} errorCallback Error callback.
287 */ 297 */
288 VolumeManager.prototype.mountGData = function(successCallback, errorCallback) { 298 VolumeManager.prototype.mountGData = function(successCallback, errorCallback) {
289 if (this.getGDataStatus() == VolumeManager.GDataStatus.ERROR) { 299 if (this.getGDataStatus() == VolumeManager.GDataStatus.ERROR) {
290 this.setGDataStatus_(VolumeManager.GDataStatus.UNMOUNTED); 300 this.setGDataStatus_(VolumeManager.GDataStatus.UNMOUNTED);
291 } 301 }
292 var self = this; 302 var self = this;
293 this.mount_('', 'gdata', function(mountPath) { 303 this.mount_('', VolumeManager.MountType.DRIVE, function(mountPath) {
294 this.waitGDataLoaded_(mountPath, function(success, error) { 304 this.waitGDataLoaded_(mountPath, function(success, error) {
295 if (success) { 305 if (success) {
296 successCallback(mountPath); 306 successCallback(mountPath);
297 } else { 307 } else {
298 errorCallback(error); 308 errorCallback(error);
299 } 309 }
300 }); 310 });
301 }, function(error) { 311 }, function(error) {
302 if (self.getGDataStatus() != VolumeManager.GDataStatus.MOUNTED) 312 if (self.getGDataStatus() != VolumeManager.GDataStatus.MOUNTED)
303 self.setGDataStatus_(VolumeManager.GDataStatus.ERROR); 313 self.setGDataStatus_(VolumeManager.GDataStatus.ERROR);
304 errorCallback(error); 314 errorCallback(error);
305 }); 315 });
306 }; 316 };
307 317
308 /** 318 /**
309 * @param {string} fileUrl File url to the archive file. 319 * @param {string} fileUrl File url to the archive file.
310 * @param {Function} successCallback Success callback. 320 * @param {Function} successCallback Success callback.
311 * @param {Function} errorCallback Error callback. 321 * @param {Function} errorCallback Error callback.
312 */ 322 */
313 VolumeManager.prototype.mountArchive = function(fileUrl, successCallback, 323 VolumeManager.prototype.mountArchive = function(fileUrl, successCallback,
314 errorCallback) { 324 errorCallback) {
315 this.mount_(fileUrl, 'file', successCallback, errorCallback); 325 this.mount_(fileUrl,
326 VolumeManager.MountType.FILE,
327 successCallback,
328 errorCallback);
316 }; 329 };
317 330
318 /** 331 /**
319 * Unmounts volume. 332 * Unmounts volume.
320 * @param {string} mountPath Volume mounted path. 333 * @param {string} mountPath Volume mounted path.
321 * @param {Function} successCallback Success callback. 334 * @param {Function} successCallback Success callback.
322 * @param {Function} errorCallback Error callback. 335 * @param {Function} errorCallback Error callback.
323 */ 336 */
324 VolumeManager.prototype.unmount = function(mountPath, 337 VolumeManager.prototype.unmount = function(mountPath,
325 successCallback, 338 successCallback,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 }; 513 };
501 514
502 /** 515 /**
503 * @param {string} mountPath Mount path. 516 * @param {string} mountPath Mount path.
504 * @private 517 * @private
505 */ 518 */
506 VolumeManager.prototype.validateMountPath_ = function(mountPath) { 519 VolumeManager.prototype.validateMountPath_ = function(mountPath) {
507 if (!/^\/(((archive|removable)\/[^\/]+)|drive|Downloads)$/.test(mountPath)) 520 if (!/^\/(((archive|removable)\/[^\/]+)|drive|Downloads)$/.test(mountPath))
508 throw new Error('Invalid mount path: ', mountPath); 521 throw new Error('Invalid mount path: ', mountPath);
509 }; 522 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698