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

Unified Diff: ui/file_manager/video_player/js/error_util.js

Issue 315103004: Video Player: Supports bound arguments of wrap() util function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments & Added missing wrap() Created 6 years, 6 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
« no previous file with comments | « no previous file | ui/file_manager/video_player/js/video_player.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/video_player/js/error_util.js
diff --git a/ui/file_manager/video_player/js/error_util.js b/ui/file_manager/video_player/js/error_util.js
index 4bbe2eb22f43b83b4f5e6a09b06af7946168ce49..41e9dc4db4bba3950ba5a208c61df9c87cd13c63 100644
--- a/ui/file_manager/video_player/js/error_util.js
+++ b/ui/file_manager/video_player/js/error_util.js
@@ -22,19 +22,26 @@ window.onerror = function() { window.JSErrorCount++; };
* - Bind this object
*
* @param {Object} thisObject Object to be used as this.
+ * @param {...} var_args Arguments to be bound with the wrapped function.
* @return {function} Wrapped function.
*/
-Function.prototype.wrap = function(thisObject) {
+Function.prototype.wrap = function(thisObject, var_args) {
var func = this;
var liveStack = (new Error('Stack trace before async call')).stack;
if (thisObject === undefined)
thisObject = null;
+ var boundArguments = Array.prototype.slice.call(arguments, 1);
- return function wrappedCallback() {
+ return function wrappedCallback(var_args) {
try {
- return func.apply(thisObject, arguments);
+ var args = boundArguments.concat(Array.prototype.slice.call(arguments));
+ return func.apply(thisObject, args);
} catch (e) {
- console.error('Exception happens in callback.', liveStack);
+ // Some async funcrtion doesn't handle exception correctly. So outputing
+ // the exception message and stack trace just in case.
+ // The message will show twice if the caller handles exception correctly.
+ console.error(e.stack);
+ console.info('Exception above happened in callback.', liveStack);
window.JSErrorCount++;
throw e;
« no previous file with comments | « no previous file | ui/file_manager/video_player/js/video_player.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698