| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_EXTENSION_MESSAGE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 TabContents* target_tab_contents, IPC::Message::Sender* source); | 107 TabContents* target_tab_contents, IPC::Message::Sender* source); |
| 108 | 108 |
| 109 // --- IO thread only: | 109 // --- IO thread only: |
| 110 | 110 |
| 111 // Given an extension's ID, opens a channel between the given renderer "port" | 111 // Given an extension's ID, opens a channel between the given renderer "port" |
| 112 // and every listening context owned by that extension. Returns a port ID | 112 // and every listening context owned by that extension. Returns a port ID |
| 113 // to be used for posting messages between the processes. |channel_name| is | 113 // to be used for posting messages between the processes. |channel_name| is |
| 114 // an optional identifier for use by extension developers. | 114 // an optional identifier for use by extension developers. |
| 115 // This runs on the IO thread so that it can be used in a synchronous IPC | 115 // This runs on the IO thread so that it can be used in a synchronous IPC |
| 116 // message. | 116 // message. |
| 117 int OpenChannelToExtension(int routing_id, const std::string& extension_id, | 117 int OpenChannelToExtension(int routing_id, |
| 118 const std::string& source_extension_id, |
| 119 const std::string& target_extension_id, |
| 118 const std::string& channel_name, | 120 const std::string& channel_name, |
| 119 ResourceMessageFilter* source); | 121 ResourceMessageFilter* source); |
| 120 | 122 |
| 121 // Same as above, but opens a channel to the tab with the given ID. Messages | 123 // Same as above, but opens a channel to the tab with the given ID. Messages |
| 122 // are restricted to that tab, so if there are multiple tabs in that process, | 124 // are restricted to that tab, so if there are multiple tabs in that process, |
| 123 // only the targeted tab will receive messages. | 125 // only the targeted tab will receive messages. |
| 124 int OpenChannelToTab(int routing_id, int tab_id, | 126 int OpenChannelToTab(int routing_id, int tab_id, |
| 125 const std::string& extension_id, | 127 const std::string& extension_id, |
| 126 const std::string& channel_name, | 128 const std::string& channel_name, |
| 127 ResourceMessageFilter* source); | 129 ResourceMessageFilter* source); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 139 | 141 |
| 140 // The UI message loop, used for posting tasks. | 142 // The UI message loop, used for posting tasks. |
| 141 MessageLoop* ui_loop_; | 143 MessageLoop* ui_loop_; |
| 142 | 144 |
| 143 // --- UI thread only: | 145 // --- UI thread only: |
| 144 | 146 |
| 145 // Handles channel creation and notifies the destinations that a channel was | 147 // Handles channel creation and notifies the destinations that a channel was |
| 146 // opened. | 148 // opened. |
| 147 void OpenChannelToExtensionOnUIThread( | 149 void OpenChannelToExtensionOnUIThread( |
| 148 int source_process_id, int source_routing_id, int receiver_port_id, | 150 int source_process_id, int source_routing_id, int receiver_port_id, |
| 149 const std::string& extension_id, const std::string& channel_name); | 151 const std::string& source_extension_id, |
| 152 const std::string& target_extension_id, |
| 153 const std::string& channel_name); |
| 150 | 154 |
| 151 void OpenChannelToTabOnUIThread( | 155 void OpenChannelToTabOnUIThread( |
| 152 int source_process_id, int source_routing_id, int receiver_port_id, | 156 int source_process_id, int source_routing_id, int receiver_port_id, |
| 153 int tab_id, const std::string& extension_id, | 157 int tab_id, const std::string& extension_id, |
| 154 const std::string& channel_name); | 158 const std::string& channel_name); |
| 155 | 159 |
| 156 // Common between OpenChannelOnUIThread and OpenSpecialChannelToExtension. | 160 // Common between OpenChannelOnUIThread and OpenSpecialChannelToExtension. |
| 157 bool OpenChannelOnUIThreadImpl( | 161 bool OpenChannelOnUIThreadImpl( |
| 158 IPC::Message::Sender* source, TabContents* source_contents, | 162 IPC::Message::Sender* source, TabContents* source_contents, |
| 159 const MessagePort& receiver, int receiver_port_id, | 163 const MessagePort& receiver, int receiver_port_id, |
| 160 const std::string& extension_id, const std::string& channel_name); | 164 const std::string& source_extension_id, |
| 165 const std::string& target_extension_id, |
| 166 const std::string& channel_name); |
| 161 | 167 |
| 162 // NotificationObserver interface. | 168 // NotificationObserver interface. |
| 163 void Observe(NotificationType type, | 169 void Observe(NotificationType type, |
| 164 const NotificationSource& source, | 170 const NotificationSource& source, |
| 165 const NotificationDetails& details); | 171 const NotificationDetails& details); |
| 166 | 172 |
| 167 // An IPC sender that might be in our list of channels has closed. | 173 // An IPC sender that might be in our list of channels has closed. |
| 168 void OnSenderClosed(IPC::Message::Sender* sender); | 174 void OnSenderClosed(IPC::Message::Sender* sender); |
| 169 | 175 |
| 170 Profile* profile_; | 176 Profile* profile_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 186 int next_port_id_; | 192 int next_port_id_; |
| 187 | 193 |
| 188 // Protects the next_port_id_ variable, since it can be | 194 // Protects the next_port_id_ variable, since it can be |
| 189 // used on the IO thread or the UI thread. | 195 // used on the IO thread or the UI thread. |
| 190 Lock next_port_id_lock_; | 196 Lock next_port_id_lock_; |
| 191 | 197 |
| 192 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); | 198 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); |
| 193 }; | 199 }; |
| 194 | 200 |
| 195 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ | 201 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
| OLD | NEW |