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

Unified Diff: extensions/renderer/resources/last_error.js

Issue 855813002: Mark create/update/clear callbacks of notification API as optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: extensions/renderer/resources/last_error.js
diff --git a/extensions/renderer/resources/last_error.js b/extensions/renderer/resources/last_error.js
index 8d53371827acd01eeaa12840bd71497b5bb90120..7c93721880030ef914083ffe9a7053f7a839cc43 100644
--- a/extensions/renderer/resources/last_error.js
+++ b/extensions/renderer/resources/last_error.js
@@ -113,12 +113,28 @@ function run(name, message, stack, callback, args) {
try {
$Function.apply(callback, undefined, args);
} finally {
+ if (!hasAccessed(targetChrome))
not at google - send to devlin 2015/01/20 17:41:35 This doesn't look right, it'll always print an err
robwu 2015/01/20 22:34:01 This is correct. Function run sets chrome.runtime.
not at google - send to devlin 2015/01/21 22:21:19 What am I missing here? If I do: chrome.someNames
robwu 2015/01/21 23:21:09 callback is a user-supplied callback. That "// cod
not at google - send to devlin 2015/01/21 23:24:32 but if there isn't an error, it'll still print a n
robwu 2015/01/21 23:28:18 A few lines earlier, chrome.runtime.lastError is s
+ reportUncheckedLastError(name, message, stack);
clear(targetChrome);
}
}
+/**
+ * Call this method when runtime.lastError was set but not checked.
+ * This notifies the developer of the error via the (error) console.
+ *
+ * @param {string=} name - name of API.
+ * @param {string} message - error description.
+ * @param {string=} stack - Stack trace of the call up to the error.
+ */
+function reportUncheckedLastError(name, message, stack) {
not at google - send to devlin 2015/01/20 17:41:35 Given that this method is under the "lastError" na
robwu 2015/01/20 22:34:01 If we couple this method with the chrome object, t
robwu 2015/01/21 23:21:09 Done.
+ console.error("Unchecked runtime.lastError while running " +
+ (name || "unknown") + ": " + message + (stack ? "\n" + stack : ""));
+}
+
exports.clear = clear;
exports.hasAccessed = hasAccessed;
exports.hasError = hasError;
exports.set = set;
exports.run = run;
+exports.reportUncheckedLastError = reportUncheckedLastError;

Powered by Google App Engine
This is Rietveld 408576698