Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / file_manager / file_manager / foreground / js / volume_manager_wrapper.js
index 214fe13..9abc2f7 100644 (file)
@@ -10,7 +10,7 @@
  * @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.
@@ -130,7 +130,7 @@ VolumeManagerWrapper.prototype.dispose = function() {
 /**
  * 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) {
@@ -187,13 +187,21 @@ VolumeManagerWrapper.prototype.onVolumeInfoListUpdated_ = 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;
   }
@@ -202,7 +210,7 @@ VolumeManagerWrapper.prototype.ensureInitialized = function(callback) {
 };
 
 /**
- * @return {VolumeManagerCommon.DriveConnectionType} Current drive connection
+ * @return {VolumeManagerCommon.DriveConnectionState} Current drive connection
  *     state.
  */
 VolumeManagerWrapper.prototype.getDriveConnectionState = function() {
@@ -258,7 +266,7 @@ VolumeManagerWrapper.prototype.getDefaultDisplayRoot =
 /**
  * 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) {
@@ -322,3 +330,23 @@ VolumeManagerWrapper.prototype.filterDisabledDriveVolume_ =
       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  ');
+};