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

Unified Diff: chrome/browser/extensions/api/messaging/extension_message_port.h

Issue 1966283002: Remove port lifetime management from renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Devlin's nits up to #12 Created 4 years, 7 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/browser/extensions/api/messaging/extension_message_port.h
diff --git a/chrome/browser/extensions/api/messaging/extension_message_port.h b/chrome/browser/extensions/api/messaging/extension_message_port.h
index dd6e584fc5ef842cd18a8e4161cb1b2950516c6e..92b785803d2184935a5558c0dfaf4921d6644757 100644
--- a/chrome/browser/extensions/api/messaging/extension_message_port.h
+++ b/chrome/browser/extensions/api/messaging/extension_message_port.h
@@ -41,6 +41,12 @@ class ExtensionMessagePort : public MessageService::MessagePort {
content::RenderProcessHost* extension_process);
~ExtensionMessagePort() override;
+ // Checks whether the frames to which this port is tied at its construction
+ // are still aware of this port's existence. Frames that don't know about
+ // the port are removed from the set of frames. This should be used for opener
+ // ports because the frame may be navigated before the port was initialized.
+ void RevalidatePort();
+
// MessageService::MessagePort:
void RemoveCommonFrames(const MessagePort& port) override;
bool HasFrame(content::RenderFrameHost* rfh) const override;
@@ -92,6 +98,11 @@ class ExtensionMessagePort : public MessageService::MessagePort {
// when the frame is removed or unloaded.
std::set<content::RenderFrameHost*> frames_;
+ // The ID of the tab where the channel was created. This is saved so that any
+ // onMessage events can be run in the scope of the tab.
+ // Only set on receiver ports (if the opener was a tab). -1 if invalid.
+ int opener_tab_id_;
+
// Whether the renderer acknowledged creation of the port. This is used to
// distinguish abnormal port closure (e.g. no receivers) from explicit port
// closure (e.g. by the port.disconnect() JavaScript method in the renderer).

Powered by Google App Engine
This is Rietveld 408576698