Commit e037cd16 authored by serya@chromium.org's avatar serya@chromium.org

Fixed race condition on mounting dgrive while file manager initialization.

BUG=139680
TEST=Manual test.


Review URL: https://chromiumcodereview.appspot.com/10824110

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149209 0039d316-1c4b-4281-b951-d872f2087c98
parent f522a1e5
...@@ -115,6 +115,7 @@ VolumeManager.prototype.initMountPoints_ = function() { ...@@ -115,6 +115,7 @@ VolumeManager.prototype.initMountPoints_ = function() {
var mountedVolumes = []; var mountedVolumes = [];
var self = this; var self = this;
var index = 0; var index = 0;
this.deferredQueue_ = [];
function step(mountPoints) { function step(mountPoints) {
if (index < mountPoints.length) { if (index < mountPoints.length) {
var info = mountPoints[index]; var info = mountPoints[index];
...@@ -137,6 +138,12 @@ VolumeManager.prototype.initMountPoints_ = function() { ...@@ -137,6 +138,12 @@ VolumeManager.prototype.initMountPoints_ = function() {
chrome.fileBrowserPrivate.onMountCompleted.addListener( chrome.fileBrowserPrivate.onMountCompleted.addListener(
self.onMountCompleted_.bind(self)); self.onMountCompleted_.bind(self));
var deferredQueue = self.deferredQueue_;
self.deferredQueue_ = null;
for (var i = 0; i < deferredQueue.length; i++) {
deferredQueue[i]();
}
if (mountedVolumes.length > 0) if (mountedVolumes.length > 0)
cr.dispatchSimpleEvent(self, 'change'); cr.dispatchSimpleEvent(self, 'change');
} }
...@@ -302,6 +309,12 @@ VolumeManager.prototype.unmount = function(mountPath, ...@@ -302,6 +309,12 @@ VolumeManager.prototype.unmount = function(mountPath,
successCallback, successCallback,
errorCallback) { errorCallback) {
this.validateMountPath_(mountPath); this.validateMountPath_(mountPath);
if (this.deferredQueue_) {
this.deferredQueue_.push(this.unmount.bind(this,
mountPath, successCallback, errorCallback));
return;
}
var volumeInfo = this.mountedVolumes_[mountPath]; var volumeInfo = this.mountedVolumes_[mountPath];
if (!volumeInfo) { if (!volumeInfo) {
errorCallback(VolumeManager.Error.NOT_MOUNTED); errorCallback(VolumeManager.Error.NOT_MOUNTED);
...@@ -370,6 +383,12 @@ VolumeManager.prototype.getVolumeInfo_ = function(mountPath) { ...@@ -370,6 +383,12 @@ VolumeManager.prototype.getVolumeInfo_ = function(mountPath) {
*/ */
VolumeManager.prototype.mount_ = function(url, mountType, VolumeManager.prototype.mount_ = function(url, mountType,
successCallback, errorCallback) { successCallback, errorCallback) {
if (this.deferredQueue_) {
this.deferredQueue_.push(this.mount_.bind(this,
url, mountType, successCallback, errorCallback));
return;
}
chrome.fileBrowserPrivate.addMount(url, mountType, {}, chrome.fileBrowserPrivate.addMount(url, mountType, {},
function(sourcePath) { function(sourcePath) {
console.log('Mount request: url=' + url + '; mountType=' + mountType + console.log('Mount request: url=' + url + '; mountType=' + mountType +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment