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

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

Issue 2959583002: [Extensions Bindings] Don't load lastError module with native bindings (Closed)
Patch Set: rebase Created 3 years, 5 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 | « extensions/renderer/resources/file_entry_binding_util.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/messaging.js
diff --git a/extensions/renderer/resources/messaging.js b/extensions/renderer/resources/messaging.js
index f44d753d4e9b4466d65a073edf2da51b3475771d..d0ca6c8a4c1262f87c070aa83cd0d71fe3e5121d 100644
--- a/extensions/renderer/resources/messaging.js
+++ b/extensions/renderer/resources/messaging.js
@@ -7,7 +7,6 @@
// TODO(kalman): factor requiring chrome out of here.
var chrome = requireNative('chrome').GetChrome();
- var lastError = require('lastError');
var logActivity = requireNative('activityLogger');
var logging = requireNative('logging');
var messagingNatives = requireNative('messaging_natives');
@@ -46,6 +45,28 @@
privates(event).impl.destroy_();
}
+ var jsLastError = bindingUtil ? undefined : require('lastError');
+ function setLastError(name, error) {
+ if (bindingUtil)
+ bindingUtil.setLastError(error);
+ else
+ jsLastError.set(name, error, null, chrome);
+ }
+
+ function clearLastError() {
+ if (bindingUtil)
+ bindingUtil.clearLastError();
+ else
+ jsLastError.clear(chrome);
+ }
+
+ function hasLastError() {
+ if (bindingUtil)
+ return bindingUtil.hasLastError();
+ else
+ return jsLastError.hasError(chrome);
+ }
+
// Map of port IDs to port object.
var ports = {__proto__: null};
@@ -152,7 +173,7 @@
if (sourceUrl)
errorMsg += ' for URL ' + sourceUrl;
errorMsg += ').';
- lastError.set(eventName, errorMsg, null, chrome);
+ setLastError(eventName, errorMsg);
}
// Helper function for dispatchOnConnect
@@ -348,12 +369,12 @@
if (port) {
delete ports[portId];
if (errorMessage)
- lastError.set('Port', errorMessage, null, chrome);
+ setLastError('Port', errorMessage);
try {
port.onDisconnect.dispatch(port);
} finally {
privates(port).impl.destroy_();
- lastError.clear(chrome);
+ clearLastError();
}
}
};
@@ -406,17 +427,16 @@
if (!responseCallback)
return;
- if (lastError.hasError(chrome)) {
+ if (hasLastError()) {
sendResponseAndClearCallback();
} else {
- lastError.set(
+ setLastError(
port.name,
- 'The message port closed before a response was received.', null,
- chrome);
+ 'The message port closed before a response was received.');
try {
sendResponseAndClearCallback();
} finally {
- lastError.clear(chrome);
+ clearLastError();
}
}
}
« no previous file with comments | « extensions/renderer/resources/file_entry_binding_util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698