Chromium Code Reviews| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 int tab_id, const std::string& extension_id, | 137 int tab_id, const std::string& extension_id, |
| 138 const std::string& channel_name); | 138 const std::string& channel_name); |
| 139 | 139 |
| 140 void OpenChannelToNativeApp( | 140 void OpenChannelToNativeApp( |
| 141 int source_process_id, | 141 int source_process_id, |
| 142 int source_routing_id, | 142 int source_routing_id, |
| 143 int receiver_port_id, | 143 int receiver_port_id, |
| 144 const std::string& source_extension_id, | 144 const std::string& source_extension_id, |
| 145 const std::string& native_app_name); | 145 const std::string& native_app_name); |
| 146 | 146 |
| 147 // NativeMessageProcessHost::Client | |
| 148 virtual void PostMessageFromNativeProcess( | |
| 149 int port_id, | |
| 150 const std::string& message) OVERRIDE; | |
| 151 | |
| 152 // NativeMessageProcessHost::Client | |
| 147 // Closes the message channel associated with the given port, and notifies | 153 // Closes the message channel associated with the given port, and notifies |
| 148 // the other side. | 154 // the other side. |
| 149 virtual void CloseChannel(int port_id, | 155 virtual void CloseChannel(int port_id, |
| 150 const std::string& error_message) OVERRIDE; | 156 const std::string& error_message) OVERRIDE; |
| 151 | 157 |
| 152 // Enqueues a message on a pending channel, or sends a message to the given | 158 // Enqueues a message on a pending channel, or sends a message to the given |
| 153 // port if the channel isn't pending. | 159 // port if the channel isn't pending. |
| 154 void PostMessage(int port_id, const Message& message); | 160 void PostMessage(int port_id, const Message& message); |
| 155 | 161 |
| 156 // NativeMessageProcessHost::Client | 162 bool CanPlatformAppAccessTab(const std::string app_id, int tab_id) const; |
|
not at google - send to devlin
2014/01/23 16:41:59
const std::string&
Lei Zhang
2014/01/23 20:53:12
It sounds like CanPlatformAppAccessTab() isn't nee
| |
| 157 virtual void PostMessageFromNativeProcess( | |
| 158 int port_id, | |
| 159 const std::string& message) OVERRIDE; | |
| 160 | 163 |
| 161 private: | 164 private: |
| 162 friend class MockMessageService; | 165 friend class MockMessageService; |
| 163 friend class ProfileKeyedAPIFactory<MessageService>; | 166 friend class ProfileKeyedAPIFactory<MessageService>; |
| 164 struct OpenChannelParams; | 167 struct OpenChannelParams; |
| 165 | 168 |
| 166 // A map of channel ID to its channel object. | 169 // A map of channel ID to its channel object. |
| 167 typedef std::map<int, MessageChannel*> MessageChannelMap; | 170 typedef std::map<int, MessageChannel*> MessageChannelMap; |
| 168 | 171 |
| 169 typedef std::pair<int, Message> PendingMessage; | 172 typedef std::pair<int, Message> PendingMessage; |
| 170 typedef std::vector<PendingMessage> PendingMessagesQueue; | 173 typedef std::vector<PendingMessage> PendingMessagesQueue; |
| 171 // A set of channel IDs waiting for TLS channel IDs to complete opening, | 174 // A set of channel IDs waiting for TLS channel IDs to complete opening, |
| 172 // and any pending messages queued to be sent on those channels. | 175 // and any pending messages queued to be sent on those channels. |
| 173 typedef std::map<int, PendingMessagesQueue> PendingTlsChannelIdMap; | 176 typedef std::map<int, PendingMessagesQueue> PendingTlsChannelIdMap; |
| 174 | 177 |
| 175 // A map of channel ID to information about the extension that is waiting | 178 // A map of channel ID to information about the extension that is waiting |
| 176 // for that channel to open. Used for lazy background pages. | 179 // for that channel to open. Used for lazy background pages. |
| 177 typedef std::string ExtensionID; | 180 typedef std::string ExtensionID; |
| 178 typedef std::pair<Profile*, ExtensionID> PendingLazyBackgroundPageChannel; | 181 typedef std::pair<Profile*, ExtensionID> PendingLazyBackgroundPageChannel; |
| 179 typedef std::map<int, PendingLazyBackgroundPageChannel> | 182 typedef std::map<int, PendingLazyBackgroundPageChannel> |
| 180 PendingLazyBackgroundPageChannelMap; | 183 PendingLazyBackgroundPageChannelMap; |
| 181 | 184 |
| 185 // A map of channel ID to (target platform app id, tab id). | |
| 186 typedef std::map<int, std::pair<std::string, int> > | |
| 187 PendingDispatchesToPlatformAppsMap; | |
| 188 | |
| 182 // Common among OpenChannel* variants. | 189 // Common among OpenChannel* variants. |
| 183 bool OpenChannelImpl(scoped_ptr<OpenChannelParams> params); | 190 bool OpenChannelImpl(scoped_ptr<OpenChannelParams> params); |
| 184 | 191 |
| 185 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, | 192 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, |
| 186 int port_id, | 193 int port_id, |
| 187 const std::string& error_message, | 194 const std::string& error_message, |
| 188 bool notify_other_port); | 195 bool notify_other_port); |
| 189 | 196 |
| 190 // Have MessageService take ownership of |channel|, and remove any pending | 197 // Have MessageService take ownership of |channel|, and remove any pending |
| 191 // channels with the same id. | 198 // channels with the same id. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 } | 262 } |
| 256 static const bool kServiceRedirectedInIncognito = true; | 263 static const bool kServiceRedirectedInIncognito = true; |
| 257 static const bool kServiceIsCreatedWithBrowserContext = false; | 264 static const bool kServiceIsCreatedWithBrowserContext = false; |
| 258 static const bool kServiceIsNULLWhileTesting = true; | 265 static const bool kServiceIsNULLWhileTesting = true; |
| 259 | 266 |
| 260 content::NotificationRegistrar registrar_; | 267 content::NotificationRegistrar registrar_; |
| 261 MessageChannelMap channels_; | 268 MessageChannelMap channels_; |
| 262 PendingTlsChannelIdMap pending_tls_channel_id_channels_; | 269 PendingTlsChannelIdMap pending_tls_channel_id_channels_; |
| 263 PendingLazyBackgroundPageChannelMap pending_lazy_background_page_channels_; | 270 PendingLazyBackgroundPageChannelMap pending_lazy_background_page_channels_; |
| 264 MessagePropertyProvider property_provider_; | 271 MessagePropertyProvider property_provider_; |
| 272 PendingDispatchesToPlatformAppsMap pending_dispatches_to_platform_apps_; | |
| 265 | 273 |
| 266 // Weak pointer. Guaranteed to outlive this class. | 274 // Weak pointer. Guaranteed to outlive this class. |
| 267 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 275 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
| 268 | 276 |
| 269 base::WeakPtrFactory<MessageService> weak_factory_; | 277 base::WeakPtrFactory<MessageService> weak_factory_; |
| 270 | 278 |
| 271 DISALLOW_COPY_AND_ASSIGN(MessageService); | 279 DISALLOW_COPY_AND_ASSIGN(MessageService); |
| 272 }; | 280 }; |
| 273 | 281 |
| 274 } // namespace extensions | 282 } // namespace extensions |
| 275 | 283 |
| 276 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 284 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
| OLD | NEW |