OLD | NEW |
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_MESSAGE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 typedef std::map<int, PendingMessagesQueue> PendingChannelMap; | 179 typedef std::map<int, PendingMessagesQueue> PendingChannelMap; |
180 | 180 |
181 // A map of channel ID to information about the extension that is waiting | 181 // A map of channel ID to information about the extension that is waiting |
182 // for that channel to open. Used for lazy background pages. | 182 // for that channel to open. Used for lazy background pages. |
183 typedef std::string ExtensionID; | 183 typedef std::string ExtensionID; |
184 typedef std::pair<content::BrowserContext*, ExtensionID> | 184 typedef std::pair<content::BrowserContext*, ExtensionID> |
185 PendingLazyBackgroundPageChannel; | 185 PendingLazyBackgroundPageChannel; |
186 typedef std::map<int, PendingLazyBackgroundPageChannel> | 186 typedef std::map<int, PendingLazyBackgroundPageChannel> |
187 PendingLazyBackgroundPageChannelMap; | 187 PendingLazyBackgroundPageChannelMap; |
188 | 188 |
189 // Common among OpenChannel* variants. | 189 // Common implementation for opening a channel configured by |params|. |
190 void OpenChannelImpl(scoped_ptr<OpenChannelParams> params); | 190 // |
| 191 // |target_extension| will be non-null if |params->target_extension_id| is |
| 192 // non-empty, that is, if the target is an extension, it must exist. |
| 193 // |
| 194 // |did_enqueue| will be true if the channel opening was delayed while |
| 195 // waiting for an event page to start, false otherwise. |
| 196 void OpenChannelImpl(content::BrowserContext* browser_context, |
| 197 scoped_ptr<OpenChannelParams> params, |
| 198 const Extension* target_extension, |
| 199 bool did_enqueue); |
191 | 200 |
192 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, | 201 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, |
193 int port_id, | 202 int port_id, |
194 const std::string& error_message, | 203 const std::string& error_message, |
195 bool notify_other_port); | 204 bool notify_other_port); |
196 | 205 |
197 // Have MessageService take ownership of |channel|, and remove any pending | 206 // Have MessageService take ownership of |channel|, and remove any pending |
198 // channels with the same id. | 207 // channels with the same id. |
199 void AddChannel(MessageChannel* channel, int receiver_port_id); | 208 void AddChannel(MessageChannel* channel, int receiver_port_id); |
200 | 209 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 298 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
290 | 299 |
291 base::WeakPtrFactory<MessageService> weak_factory_; | 300 base::WeakPtrFactory<MessageService> weak_factory_; |
292 | 301 |
293 DISALLOW_COPY_AND_ASSIGN(MessageService); | 302 DISALLOW_COPY_AND_ASSIGN(MessageService); |
294 }; | 303 }; |
295 | 304 |
296 } // namespace extensions | 305 } // namespace extensions |
297 | 306 |
298 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 307 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |