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

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

Issue 141803016: Hide Port privates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments and fixed tests Created 6 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: chrome/renderer/resources/extensions/messaging.js
diff --git a/chrome/renderer/resources/extensions/messaging.js b/chrome/renderer/resources/extensions/messaging.js
index d51ec78cb6feff09d637fd9d75abc754c3b372a1..7128178cec86d10a6f403b1a80f19f0bd2c08443 100644
--- a/chrome/renderer/resources/extensions/messaging.js
+++ b/chrome/renderer/resources/extensions/messaging.js
@@ -15,6 +15,7 @@
var messagingNatives = requireNative('messaging_natives');
var processNatives = requireNative('process');
var unloadEvent = require('unload_event');
+ var utils = require('utils');
var messagingUtils = require('messaging_utils');
// The reserved channel name for the sendRequest/send(Native)Message APIs.
@@ -36,7 +37,7 @@
// Port object. Represents a connection to another script context through
// which messages can be passed.
- function Port(portId, opt_name) {
+ function PortImpl(portId, opt_name) {
this.portId_ = portId;
this.name = opt_name;
@@ -52,7 +53,7 @@
// Sends a message asynchronously to the context on the other end of this
// port.
- Port.prototype.postMessage = function(msg) {
+ PortImpl.prototype.postMessage = function(msg) {
// JSON.stringify doesn't support a root object which is undefined.
if (msg === undefined)
msg = null;
@@ -72,12 +73,12 @@
};
// Disconnects the port from the other end.
- Port.prototype.disconnect = function() {
+ PortImpl.prototype.disconnect = function() {
messagingNatives.CloseChannel(this.portId_, true);
this.destroy_();
};
- Port.prototype.destroy_ = function() {
+ PortImpl.prototype.destroy_ = function() {
var portId = this.portId_;
if (this.onDestroy_)
@@ -182,7 +183,7 @@
// using some native hackery.
messagingNatives.BindToGC(responseCallback, function() {
if (port) {
- port.destroy_();
+ privates(port).impl.destroy_();
port = null;
}
});
@@ -193,7 +194,7 @@
if (!responseCallbackPreserved && port) {
// If they didn't access the response callback, they're not
// going to send a response, so clean up the port immediately.
- port.destroy_();
+ privates(port).impl.destroy_();
port = null;
}
}
@@ -288,7 +289,7 @@
try {
port.onDisconnect.dispatch(port);
} finally {
- port.destroy_();
+ privates(port).impl.destroy_();
lastError.clear(chrome);
}
}
@@ -360,6 +361,15 @@
return alignedArgs;
}
+var Port = utils.expose(PortImpl, [
+ 'disconnect',
+ 'postMessage'
+ ],
+ [
+ 'onDisconnect',
+ 'onMessage'
+ ]);
+
exports.kRequestChannel = kRequestChannel;
exports.kMessageChannel = kMessageChannel;
exports.kNativeMessageChannel = kNativeMessageChannel;
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/utils.js » ('j') | chrome/renderer/resources/extensions/utils.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698