* @param {VolumeManagerWrapper.DriveEnabledStatus} driveEnabled DRIVE_ENABLED
* if drive should be available. DRIVE_DISABLED if drive related
* data/events should be hidden.
- * @param {DOMWindow=} opt_backgroundPage Window object of the background
+ * @param {Window=} opt_backgroundPage Window object of the background
* page. If this is specified, the class skips to get background page.
* TOOD(hirono): Let all clients of the class pass the background page and
* make the argument not optional.
/**
* Called on events sent from VolumeManager. This has responsibility to
* re-dispatch the event to the listeners.
- * @param {Event} event Event object sent from VolumeManager.
+ * @param {!Event} event Event object sent from VolumeManager.
* @private
*/
VolumeManagerWrapper.prototype.onEvent_ = function(event) {
};
/**
+ * Returns whether the VolumeManager is initialized or not.
+ * @return {boolean} True if the VolumeManager is initialized.
+ */
+VolumeManagerWrapper.prototype.isInitialized = function() {
+ return this.pendingTasks_ === null;
+};
+
+/**
* Ensures the VolumeManager is initialized, and then invokes callback.
* If the VolumeManager is already initialized, callback will be called
* immediately.
* @param {function()} callback Called on initialization completion.
*/
VolumeManagerWrapper.prototype.ensureInitialized = function(callback) {
- if (this.pendingTasks_) {
+ if (!this.isInitialized()) {
this.pendingTasks_.push(this.ensureInitialized.bind(this, callback));
return;
}
};
/**
- * @return {VolumeManagerCommon.DriveConnectionType} Current drive connection
+ * @return {VolumeManagerCommon.DriveConnectionState} Current drive connection
* state.
*/
VolumeManagerWrapper.prototype.getDriveConnectionState = function() {
/**
* Obtains location information from an entry.
*
- * @param {Entry} entry File or directory entry.
+ * @param {(Entry|Object)} entry File or directory entry.
* @return {EntryLocation} Location information.
*/
VolumeManagerWrapper.prototype.getLocationInfo = function(entry) {
VolumeManagerCommon.VolumeType.DRIVE;
return this.driveEnabled_ || !isDrive ? volumeInfo : null;
};
+
+/**
+ * Returns current state of VolumeManagerWrapper.
+ * @return {string} Current state of VolumeManagerWrapper.
+ */
+VolumeManagerWrapper.prototype.toString = function() {
+ var initialized = this.isInitialized();
+ var volumeManager = initialized ?
+ this.volumeManager_ :
+ this.backgroundPage_.VolumeManager.getInstanceForDebug();
+
+ var str = 'VolumeManagerWrapper\n' +
+ '- Initialized: ' + initialized + '\n';
+
+ if (!initialized)
+ str += '- PendingTasksCount: ' + this.pendingTasks_.length + '\n';
+
+ return str + '- VolumeManager:\n' +
+ ' ' + volumeManager.toString().replace(/\n/g, '\n ');
+};