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

Side by Side 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: Use MakeUnique instead of WrapUnique 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/messaging/extension_message_port.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/extensions/api/messaging/message_service.h" 9 #include "chrome/browser/extensions/api/messaging/message_service.h"
10 10
(...skipping 23 matching lines...) Expand all
34 content::RenderFrameHost* rfh, 34 content::RenderFrameHost* rfh,
35 bool include_child_frames); 35 bool include_child_frames);
36 // Create a port that is tied to all frames of an extension, possibly spanning 36 // Create a port that is tied to all frames of an extension, possibly spanning
37 // multiple tabs, including the invisible background page, popups, etc. 37 // multiple tabs, including the invisible background page, popups, etc.
38 ExtensionMessagePort(base::WeakPtr<MessageService> message_service, 38 ExtensionMessagePort(base::WeakPtr<MessageService> message_service,
39 int port_id, 39 int port_id,
40 const std::string& extension_id, 40 const std::string& extension_id,
41 content::RenderProcessHost* extension_process); 41 content::RenderProcessHost* extension_process);
42 ~ExtensionMessagePort() override; 42 ~ExtensionMessagePort() override;
43 43
44 // Checks whether the frames to which this port is tied at its construction
45 // are still aware of this port's existence. Frames that don't know about
46 // the port are removed from the set of frames. This should be used for opener
47 // ports because the frame may be navigated before the port was initialized.
48 void RevalidatePort();
49
44 // MessageService::MessagePort: 50 // MessageService::MessagePort:
45 void RemoveCommonFrames(const MessagePort& port) override; 51 void RemoveCommonFrames(const MessagePort& port) override;
46 bool HasFrame(content::RenderFrameHost* rfh) const override; 52 bool HasFrame(content::RenderFrameHost* rfh) const override;
47 bool IsValidPort() override; 53 bool IsValidPort() override;
48 void DispatchOnConnect(const std::string& channel_name, 54 void DispatchOnConnect(const std::string& channel_name,
49 std::unique_ptr<base::DictionaryValue> source_tab, 55 std::unique_ptr<base::DictionaryValue> source_tab,
50 int source_frame_id, 56 int source_frame_id,
51 int guest_process_id, 57 int guest_process_id,
52 int guest_render_frame_routing_id, 58 int guest_render_frame_routing_id,
53 const std::string& source_extension_id, 59 const std::string& source_extension_id,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // Only for receivers in an extension process. 91 // Only for receivers in an extension process.
86 content::RenderProcessHost* extension_process_; 92 content::RenderProcessHost* extension_process_;
87 93
88 // When the port is used as a sender, this set contains only one element. 94 // When the port is used as a sender, this set contains only one element.
89 // If used as a receiver, it may contain any number of frames. 95 // If used as a receiver, it may contain any number of frames.
90 // This set is populated before the first message is sent to the destination, 96 // This set is populated before the first message is sent to the destination,
91 // and shrinks over time when the port is rejected by the recipient frame, or 97 // and shrinks over time when the port is rejected by the recipient frame, or
92 // when the frame is removed or unloaded. 98 // when the frame is removed or unloaded.
93 std::set<content::RenderFrameHost*> frames_; 99 std::set<content::RenderFrameHost*> frames_;
94 100
101 // The ID of the tab where the channel was created. This is saved so that any
102 // onMessage events can be run in the scope of the tab.
103 // Only set on receiver ports (if the opener was a tab). -1 if invalid.
104 int opener_tab_id_;
105
95 // Whether the renderer acknowledged creation of the port. This is used to 106 // Whether the renderer acknowledged creation of the port. This is used to
96 // distinguish abnormal port closure (e.g. no receivers) from explicit port 107 // distinguish abnormal port closure (e.g. no receivers) from explicit port
97 // closure (e.g. by the port.disconnect() JavaScript method in the renderer). 108 // closure (e.g. by the port.disconnect() JavaScript method in the renderer).
98 bool did_create_port_; 109 bool did_create_port_;
99 110
100 ExtensionHost* background_host_ptr_; // used in IncrementLazyKeepaliveCount 111 ExtensionHost* background_host_ptr_; // used in IncrementLazyKeepaliveCount
101 std::unique_ptr<FrameTracker> frame_tracker_; 112 std::unique_ptr<FrameTracker> frame_tracker_;
102 113
103 DISALLOW_COPY_AND_ASSIGN(ExtensionMessagePort); 114 DISALLOW_COPY_AND_ASSIGN(ExtensionMessagePort);
104 }; 115 };
105 116
106 } // namespace extensions 117 } // namespace extensions
107 118
108 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_ 119 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/messaging/extension_message_port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698