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

Unified Diff: chrome/renderer/resources/extensions/send_request.js

Issue 12378077: Attempting to fix problems in 11571014. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 10 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 | « chrome/renderer/resources/extensions/notification_custom_bindings.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/send_request.js
diff --git a/chrome/renderer/resources/extensions/send_request.js b/chrome/renderer/resources/extensions/send_request.js
index 1e5746f9ea712ad2b1489db8d034048e2524e595..256ef33cd9ad3fd540c763425b5e0aab15466562 100644
--- a/chrome/renderer/resources/extensions/send_request.js
+++ b/chrome/renderer/resources/extensions/send_request.js
@@ -9,21 +9,28 @@ var lastError = require('lastError');
var natives = requireNative('sendRequest');
var validate = require('schemaUtils').validate;
+// All outstanding requests from sendRequest().
+var requests = {};
+
// Callback handling.
-var requests = [];
chromeHidden.handleResponse = function(requestId, name,
success, responseList, error) {
+ var callerChrome = null;
try {
var request = requests[requestId];
DCHECK(request != null);
- if (success) {
- lastError.clear();
- } else {
- if (!error) {
+
+ // lastError needs to be set on the caller's global object, which may not
+ // necessarily be ours.
+ var callerGlobal =
+ natives.GetGlobal(request.callback || request.customCallback || chrome);
+ callerChrome = callerGlobal.chrome;
+
+ lastError.clear(callerChrome);
+ if (!success) {
+ if (!error)
error = "Unknown error.";
- }
- console.error("Error during " + name + ": " + error);
- lastError.set(error);
+ lastError.set(error, callerChrome);
}
if (request.customCallback) {
@@ -53,10 +60,9 @@ chromeHidden.handleResponse = function(requestId, name,
}
} finally {
delete requests[requestId];
- lastError.clear();
+ if (callerChrome)
+ lastError.clear(callerChrome);
}
-
- return undefined;
};
function prepareRequest(args, argSchemas) {
@@ -111,6 +117,7 @@ function sendRequest(functionName, args, argSchemas, optArgs) {
var requestId = natives.GetNextRequestId();
request.id = requestId;
requests[requestId] = request;
+
var hasCallback = request.callback || optArgs.customCallback;
return nativeFunction(functionName,
requestArgs,
« no previous file with comments | « chrome/renderer/resources/extensions/notification_custom_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698