Index: chrome/browser/resources/file_manager/js/file_manager.js |
=================================================================== |
--- chrome/browser/resources/file_manager/js/file_manager.js (revision 108087) |
+++ chrome/browser/resources/file_manager/js/file_manager.js (working copy) |
@@ -425,7 +425,7 @@ |
* @param {function(Entry)} successCallback The function to invoke once the |
* file size is known. |
*/ |
- function cacheEntrySize(entry, successCallback, opt_errorCallback) { |
+ function cacheEntrySize(entry, successCallback, opt_errorCallback, opt_sync) { |
Vladislav Kaznacheev
2011/11/08 09:33:31
Please update JSDoc
dgozman
2011/11/14 09:59:26
Done.
|
if (entry.isDirectory) { |
// No size for a directory, -1 ensures it's sorted before 0 length files. |
entry.cachedSize_ = -1; |
@@ -435,7 +435,12 @@ |
if (successCallback) { |
// Callback via a setTimeout so the sync/async semantics don't change |
Vladislav Kaznacheev
2011/11/08 09:33:31
Comment is now obsolete here and below. Here is an
dgozman
2011/11/14 09:59:26
Done.
|
// based on whether or not the value is cached. |
- setTimeout(function() { successCallback(entry) }, 0); |
+ if (opt_sync) { |
+ // If opt_sync, we are safe with synchronous call (which is faster). |
+ successCallback(entry); |
+ } else { |
+ setTimeout(function() { successCallback(entry) }, 0); |
+ } |
} |
return; |
} |
@@ -458,12 +463,17 @@ |
* @param {function(Entry)} successCallback The function to invoke once the |
* mtime is known. |
*/ |
- function cacheEntryDate(entry, successCallback, opt_errorCallback) { |
+ function cacheEntryDate(entry, successCallback, opt_errorCallback, opt_sync) { |
Vladislav Kaznacheev
2011/11/08 09:33:32
Please update JSDoc
dgozman
2011/11/14 09:59:26
Done.
|
if ('cachedMtime_' in entry) { |
if (successCallback) { |
- // Callback via a setTimeout so the sync/async semantics don't change |
- // based on whether or not the value is cached. |
- setTimeout(function() { successCallback(entry) }, 0); |
+ if (opt_sync) { |
+ // We are safe to make synchronous callback. |
+ successCallback(entry); |
+ } else { |
+ // Callback via a setTimeout so the sync/async semantics don't change |
+ // based on whether or not the value is cached. |
+ setTimeout(function() { successCallback(entry) }, 0); |
+ } |
} |
return; |
} |
@@ -762,12 +772,19 @@ |
* @param {Entry} entry An HTML5 Entry object. |
* @param {function(Entry)} successCallback The function to invoke once the |
* file size is known. |
+ * @param {boolean=} opt_sync If true, we are safe to do synchronous callback. |
*/ |
- FileManager.prototype.cacheEntryFileType = function(entry, successCallback) { |
+ FileManager.prototype.cacheEntryFileType = function( |
+ entry, successCallback, opt_sync) { |
this.getFileType(entry); |
- if (successCallback) |
- setTimeout(function() { successCallback(entry) }, 0); |
+ if (successCallback) { |
+ if (opt_sync) { |
+ successCallback(entry); |
+ } else { |
+ setTimeout(function() { successCallback(entry) }, 0); |
+ } |
+ } |
}; |
/** |
@@ -1552,7 +1569,7 @@ |
var icon = this.document_.createElement('div'); |
icon.className = 'detail-icon'; |
- this.cacheEntryIconType(entry); |
+ this.getIconType(entry); |
icon.setAttribute('iconType', entry.cachedIconType_); |
div.appendChild(icon); |
@@ -1613,7 +1630,7 @@ |
} else { |
div.textContent = util.bytesToSi(entry.cachedSize_); |
} |
- }); |
+ }, null, true); |
return div; |
}; |
@@ -1629,7 +1646,6 @@ |
var div = this.document_.createElement('div'); |
div.className = 'detail-type'; |
- div.textContent = '...'; |
this.cacheEntryFileType(entry, function(entry) { |
var info = entry.cachedFileType_; |
if (info.name) { |
@@ -1639,7 +1655,7 @@ |
div.textContent = str(info.name); |
} else |
div.textContent = ''; |
- }); |
+ }, true); |
return div; |
}; |
@@ -1667,7 +1683,7 @@ |
} else { |
div.textContent = self.shortDateFormatter_.format(entry.cachedMtime_); |
} |
- }); |
+ }, null, true); |
return div; |
}; |