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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var GetAvailability = requireNative('v8_context').GetAvailability; 5 var GetAvailability = requireNative('v8_context').GetAvailability;
6 var GetGlobal = requireNative('sendRequest').GetGlobal; 6 var GetGlobal = requireNative('sendRequest').GetGlobal;
7 7
8 // Utility for setting chrome.*.lastError. 8 // Utility for setting chrome.*.lastError.
9 // 9 //
10 // A utility here is useful for two reasons: 10 // A utility here is useful for two reasons:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 * 106 *
107 * The target chrome object is the global object's of the callback, so this 107 * The target chrome object is the global object's of the callback, so this
108 * method won't work if the real callback has been wrapped (etc). 108 * method won't work if the real callback has been wrapped (etc).
109 */ 109 */
110 function run(name, message, stack, callback, args) { 110 function run(name, message, stack, callback, args) {
111 var targetChrome = GetGlobal(callback).chrome; 111 var targetChrome = GetGlobal(callback).chrome;
112 set(name, message, stack, targetChrome); 112 set(name, message, stack, targetChrome);
113 try { 113 try {
114 $Function.apply(callback, undefined, args); 114 $Function.apply(callback, undefined, args);
115 } finally { 115 } finally {
116 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
117 reportUncheckedLastError(name, message, stack);
116 clear(targetChrome); 118 clear(targetChrome);
117 } 119 }
118 } 120 }
119 121
122 /**
123 * Call this method when runtime.lastError was set but not checked.
124 * This notifies the developer of the error via the (error) console.
125 *
126 * @param {string=} name - name of API.
127 * @param {string} message - error description.
128 * @param {string=} stack - Stack trace of the call up to the error.
129 */
130 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.
131 console.error("Unchecked runtime.lastError while running " +
132 (name || "unknown") + ": " + message + (stack ? "\n" + stack : ""));
133 }
134
120 exports.clear = clear; 135 exports.clear = clear;
121 exports.hasAccessed = hasAccessed; 136 exports.hasAccessed = hasAccessed;
122 exports.hasError = hasError; 137 exports.hasError = hasError;
123 exports.set = set; 138 exports.set = set;
124 exports.run = run; 139 exports.run = run;
140 exports.reportUncheckedLastError = reportUncheckedLastError;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698