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

Side by Side Diff: chrome/browser/extensions/api/messaging/extension_message_port.h

Issue 1413543005: Use FrameTreeNode ID as frameId in extension APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 0UL Created 5 years, 2 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
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 "chrome/browser/extensions/api/messaging/message_service.h" 8 #include "chrome/browser/extensions/api/messaging/message_service.h"
9 9
10 class GURL; 10 class GURL;
11 11
12 namespace content { 12 namespace content {
13 class BrowserContext;
14 class RenderFrameHost;
13 class RenderProcessHost; 15 class RenderProcessHost;
14 } // namespace content 16 } // namespace content
15 17
18 namespace IPC {
19 class Message;
20 } // namespace IPC
21
16 namespace extensions { 22 namespace extensions {
17 23
18 // A port that manages communication with an extension. 24 // A port that manages communication with an extension.
25 // The port's lifetime will end when either all receivers close the port, or
26 // when the opener / receiver explicitly closes the channel.
19 class ExtensionMessagePort : public MessageService::MessagePort { 27 class ExtensionMessagePort : public MessageService::MessagePort {
20 public: 28 public:
21 ExtensionMessagePort(content::RenderProcessHost* process, 29 // Create a port that is tied to frame(s) in a single tab.
22 int routing_id, 30 ExtensionMessagePort(base::WeakPtr<MessageService> message_service,
23 const std::string& extension_id); 31 int port_id,
24 void DispatchOnConnect(int dest_port_id, 32 const std::string& extension_id,
25 const std::string& channel_name, 33 content::RenderFrameHost* rfh,
34 bool include_child_frames);
35 // Create a port that is tied to all frames of an extension, possibly spanning
36 // multiple tabs, including the invisible background page, popups, etc.
37 ExtensionMessagePort(base::WeakPtr<MessageService> message_service,
38 int port_id,
39 const std::string& extension_id,
40 content::RenderProcessHost* extension_process);
41 ~ExtensionMessagePort() override;
42
43 void DispatchOnConnect(const std::string& channel_name,
26 scoped_ptr<base::DictionaryValue> source_tab, 44 scoped_ptr<base::DictionaryValue> source_tab,
27 int source_frame_id, 45 int source_frame_id,
28 int target_tab_id,
29 int target_frame_id,
30 int guest_process_id, 46 int guest_process_id,
31 int guest_render_frame_routing_id, 47 int guest_render_frame_routing_id,
32 const std::string& source_extension_id, 48 const std::string& source_extension_id,
33 const std::string& target_extension_id, 49 const std::string& target_extension_id,
34 const GURL& source_url, 50 const GURL& source_url,
35 const std::string& tls_channel_id) override; 51 const std::string& tls_channel_id) override;
36 void DispatchOnDisconnect(int source_port_id, 52 void DispatchOnDisconnect(const std::string& error_message) override;
37 const std::string& error_message) override; 53 void DispatchOnMessage(const Message& message) override;
38 void DispatchOnMessage(const Message& message, int target_port_id) override;
39 void IncrementLazyKeepaliveCount() override; 54 void IncrementLazyKeepaliveCount() override;
40 void DecrementLazyKeepaliveCount() override; 55 void DecrementLazyKeepaliveCount() override;
41 content::RenderProcessHost* GetRenderProcessHost() override; 56 void OpenPort(int process_id, int routing_id) override;
57 void ClosePort(int process_id, int routing_id) override;
42 58
43 private: 59 private:
44 content::RenderProcessHost* process_; 60 class FrameTracker;
45 int routing_id_; 61
62 void RegisterFrame(content::RenderFrameHost* rfh);
63 void UnregisterFrame(content::RenderFrameHost* rfh);
64 void CloseChannel();
65 void SendToPort(IPC::Message* msg);
66
67 base::WeakPtr<MessageService> weak_message_service_;
68 int port_id_;
46 std::string extension_id_; 69 std::string extension_id_;
70 bool did_create_port_;
71 content::BrowserContext* browser_context_;
72 std::set<content::RenderFrameHost*> frames_;
73 // Only for receivers in an extension process.
74 content::RenderProcessHost* extension_process_;
47 void* background_host_ptr_; // used in IncrementLazyKeepaliveCount 75 void* background_host_ptr_; // used in IncrementLazyKeepaliveCount
Devlin 2015/10/30 01:49:39 There's no reason for this to be a void*. Can you
robwu 2015/11/02 19:08:33 Done.
76 scoped_ptr<FrameTracker> frame_tracker_;
48 }; 77 };
Devlin 2015/10/30 01:49:39 DISALLOW_COPY_AND_ASSIGN
robwu 2015/11/02 19:08:33 Done.
49 78
50 } // namespace extensions 79 } // namespace extensions
51 80
52 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_ 81 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_EXTENSION_MESSAGE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698