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 <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 // Enqueues a message on a pending channel, or sends a message to the given | 178 // Enqueues a message on a pending channel, or sends a message to the given |
179 // port if the channel isn't pending. | 179 // port if the channel isn't pending. |
180 void PostMessage(int port_id, const Message& message); | 180 void PostMessage(int port_id, const Message& message); |
181 | 181 |
182 private: | 182 private: |
183 friend class MockMessageService; | 183 friend class MockMessageService; |
184 friend class BrowserContextKeyedAPIFactory<MessageService>; | 184 friend class BrowserContextKeyedAPIFactory<MessageService>; |
185 struct OpenChannelParams; | 185 struct OpenChannelParams; |
186 | 186 |
187 // A map of channel ID to its channel object. | 187 // A map of channel ID to its channel object. |
188 typedef std::map<int, MessageChannel*> MessageChannelMap; | 188 typedef std::map<int, std::unique_ptr<MessageChannel>> MessageChannelMap; |
Devlin
2016/09/16 20:23:19
nit: update to 'using' syntax since we're here?
Avi (use Gerrit)
2016/09/16 20:41:45
Done.
| |
189 | 189 |
190 typedef std::pair<int, Message> PendingMessage; | 190 typedef std::pair<int, Message> PendingMessage; |
191 typedef std::vector<PendingMessage> PendingMessagesQueue; | 191 typedef std::vector<PendingMessage> PendingMessagesQueue; |
192 // A set of channel IDs waiting to complete opening, and any pending messages | 192 // A set of channel IDs waiting to complete opening, and any pending messages |
193 // queued to be sent on those channels. | 193 // queued to be sent on those channels. |
194 typedef std::map<int, PendingMessagesQueue> PendingChannelMap; | 194 typedef std::map<int, PendingMessagesQueue> PendingChannelMap; |
195 | 195 |
196 // A map of channel ID to information about the extension that is waiting | 196 // A map of channel ID to information about the extension that is waiting |
197 // for that channel to open. Used for lazy background pages. | 197 // for that channel to open. Used for lazy background pages. |
198 typedef std::string ExtensionID; | 198 typedef std::string ExtensionID; |
(...skipping 20 matching lines...) Expand all Loading... | |
219 bool force_close, | 219 bool force_close, |
220 const std::string& error_message); | 220 const std::string& error_message); |
221 | 221 |
222 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, | 222 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, |
223 int port_id, | 223 int port_id, |
224 const std::string& error_message, | 224 const std::string& error_message, |
225 bool notify_other_port); | 225 bool notify_other_port); |
226 | 226 |
227 // Have MessageService take ownership of |channel|, and remove any pending | 227 // Have MessageService take ownership of |channel|, and remove any pending |
228 // channels with the same id. | 228 // channels with the same id. |
229 void AddChannel(MessageChannel* channel, int receiver_port_id); | 229 void AddChannel(std::unique_ptr<MessageChannel> channel, |
230 int receiver_port_id); | |
230 | 231 |
231 // If the channel is being opened from an incognito tab the user must allow | 232 // If the channel is being opened from an incognito tab the user must allow |
232 // the connection. | 233 // the connection. |
233 void OnOpenChannelAllowed(std::unique_ptr<OpenChannelParams> params, | 234 void OnOpenChannelAllowed(std::unique_ptr<OpenChannelParams> params, |
234 bool allowed); | 235 bool allowed); |
235 void GotChannelID(std::unique_ptr<OpenChannelParams> params, | 236 void GotChannelID(std::unique_ptr<OpenChannelParams> params, |
236 const std::string& tls_channel_id); | 237 const std::string& tls_channel_id); |
237 | 238 |
238 // Enqueues a message on a pending channel. | 239 // Enqueues a message on a pending channel. |
239 void EnqueuePendingMessage(int port_id, int channel_id, | 240 void EnqueuePendingMessage(int port_id, int channel_id, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 316 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
316 | 317 |
317 base::WeakPtrFactory<MessageService> weak_factory_; | 318 base::WeakPtrFactory<MessageService> weak_factory_; |
318 | 319 |
319 DISALLOW_COPY_AND_ASSIGN(MessageService); | 320 DISALLOW_COPY_AND_ASSIGN(MessageService); |
320 }; | 321 }; |
321 | 322 |
322 } // namespace extensions | 323 } // namespace extensions |
323 | 324 |
324 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 325 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |