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

Unified Diff: ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js

Issue 681693003: Added debugMe method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added more debug information of VolumeManager. Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js
diff --git a/ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js b/ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js
index 775475254059ad451bec6df7ffebbe91e424e169..9abc2f7a285bfeddf86d046f28f24f0e1a2b60ee 100644
--- a/ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js
+++ b/ui/file_manager/file_manager/foreground/js/volume_manager_wrapper.js
@@ -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;
}
@@ -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 ');
+};

Powered by Google App Engine
This is Rietveld 408576698