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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * VolumeManager is responsible for tracking list of mounted volumes. | 8 * VolumeManager is responsible for tracking list of mounted volumes. |
9 * | 9 * |
10 * @constructor | 10 * @constructor |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 * | 306 * |
307 * @param {string} mountPath Drive mount path. | 307 * @param {string} mountPath Drive mount path. |
308 * @param {function(boolean, FileError=)} callback To be called when waiting | 308 * @param {function(boolean, FileError=)} callback To be called when waiting |
309 * finishes. If the case of error, there may be a FileError parameter. | 309 * finishes. If the case of error, there may be a FileError parameter. |
310 * @private | 310 * @private |
311 */ | 311 */ |
312 VolumeManager.prototype.waitDriveLoaded_ = function(mountPath, callback) { | 312 VolumeManager.prototype.waitDriveLoaded_ = function(mountPath, callback) { |
313 chrome.fileBrowserPrivate.requestLocalFileSystem(function(filesystem) { | 313 chrome.fileBrowserPrivate.requestLocalFileSystem(function(filesystem) { |
314 filesystem.root.getDirectory(mountPath, {}, | 314 filesystem.root.getDirectory(mountPath, {}, |
315 function(entry) { | 315 function(entry) { |
316 // After introducion of the 'fast-fetch' feature, getting the root | 316 // After file system is mounted, we need to "read" drive grand root |
317 // entry does not start fetching data. Rather, it starts when the | 317 // entry at first. It loads mydrive root entry as a part of |
318 // entry is read. | 318 // 'fast-fetch' quickly, and starts full feed fetch in parallel. |
319 entry.createReader().readEntries( | 319 // Without this read, accessing mydrive root will be 'full-fetch' |
320 callback.bind(null, true), | 320 // rather than 'fast-fetch' on the current architecture. |
321 callback.bind(null, false)); | 321 // Just "getting" the grand root entry doesn't trigger it. Rather, |
| 322 // it starts when the entry is "read". |
| 323 entry.createReader().readEntries( |
| 324 callback.bind(null, true), |
| 325 callback.bind(null, false)); |
322 }, | 326 }, |
323 callback.bind(null, false)); | 327 callback.bind(null, false)); |
324 }); | 328 }); |
325 }; | 329 }; |
326 | 330 |
327 /** | 331 /** |
328 * @param {string} mountPath Path to the volume. | 332 * @param {string} mountPath Path to the volume. |
329 * @param {VolumeManager?} error Mounting error if any. | 333 * @param {VolumeManager?} error Mounting error if any. |
330 * @param {function(Object)} callback Result acceptor. | 334 * @param {function(Object)} callback Result acceptor. |
331 * @private | 335 * @private |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 587 |
584 /** | 588 /** |
585 * @param {string} mountPath Mount path. | 589 * @param {string} mountPath Mount path. |
586 * @private | 590 * @private |
587 */ | 591 */ |
588 VolumeManager.prototype.validateMountPath_ = function(mountPath) { | 592 VolumeManager.prototype.validateMountPath_ = function(mountPath) { |
589 if (!/^\/(drive|drive_offline|Downloads)$/.test(mountPath) && | 593 if (!/^\/(drive|drive_offline|Downloads)$/.test(mountPath) && |
590 !/^\/((archive|removable|drive)\/[^\/]+)$/.test(mountPath)) | 594 !/^\/((archive|removable|drive)\/[^\/]+)$/.test(mountPath)) |
591 throw new Error('Invalid mount path: ', mountPath); | 595 throw new Error('Invalid mount path: ', mountPath); |
592 }; | 596 }; |
OLD | NEW |