| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Closes the message channel associated with the given port, and notifies | 147 // Closes the message channel associated with the given port, and notifies |
| 148 // the other side. | 148 // the other side. |
| 149 virtual void CloseChannel(int port_id, | 149 virtual void CloseChannel(int port_id, |
| 150 const std::string& error_message) OVERRIDE; | 150 const std::string& error_message) override; |
| 151 | 151 |
| 152 // Enqueues a message on a pending channel, or sends a message to the given | 152 // Enqueues a message on a pending channel, or sends a message to the given |
| 153 // port if the channel isn't pending. | 153 // port if the channel isn't pending. |
| 154 void PostMessage(int port_id, const Message& message); | 154 void PostMessage(int port_id, const Message& message); |
| 155 | 155 |
| 156 // NativeMessageProcessHost::Client | 156 // NativeMessageProcessHost::Client |
| 157 virtual void PostMessageFromNativeProcess( | 157 virtual void PostMessageFromNativeProcess( |
| 158 int port_id, | 158 int port_id, |
| 159 const std::string& message) OVERRIDE; | 159 const std::string& message) override; |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 friend class MockMessageService; | 162 friend class MockMessageService; |
| 163 friend class BrowserContextKeyedAPIFactory<MessageService>; | 163 friend class BrowserContextKeyedAPIFactory<MessageService>; |
| 164 struct OpenChannelParams; | 164 struct OpenChannelParams; |
| 165 | 165 |
| 166 // A map of channel ID to its channel object. | 166 // A map of channel ID to its channel object. |
| 167 typedef std::map<int, MessageChannel*> MessageChannelMap; | 167 typedef std::map<int, MessageChannel*> MessageChannelMap; |
| 168 | 168 |
| 169 typedef std::pair<int, Message> PendingMessage; | 169 typedef std::pair<int, Message> PendingMessage; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 188 const std::string& error_message, | 188 const std::string& error_message, |
| 189 bool notify_other_port); | 189 bool notify_other_port); |
| 190 | 190 |
| 191 // Have MessageService take ownership of |channel|, and remove any pending | 191 // Have MessageService take ownership of |channel|, and remove any pending |
| 192 // channels with the same id. | 192 // channels with the same id. |
| 193 void AddChannel(MessageChannel* channel, int receiver_port_id); | 193 void AddChannel(MessageChannel* channel, int receiver_port_id); |
| 194 | 194 |
| 195 // content::NotificationObserver interface. | 195 // content::NotificationObserver interface. |
| 196 virtual void Observe(int type, | 196 virtual void Observe(int type, |
| 197 const content::NotificationSource& source, | 197 const content::NotificationSource& source, |
| 198 const content::NotificationDetails& details) OVERRIDE; | 198 const content::NotificationDetails& details) override; |
| 199 | 199 |
| 200 // A process that might be in our list of channels has closed. | 200 // A process that might be in our list of channels has closed. |
| 201 void OnProcessClosed(content::RenderProcessHost* process); | 201 void OnProcessClosed(content::RenderProcessHost* process); |
| 202 | 202 |
| 203 void GotChannelID(scoped_ptr<OpenChannelParams> params, | 203 void GotChannelID(scoped_ptr<OpenChannelParams> params, |
| 204 const std::string& tls_channel_id); | 204 const std::string& tls_channel_id); |
| 205 | 205 |
| 206 // Enqueues a message on a pending channel. | 206 // Enqueues a message on a pending channel. |
| 207 void EnqueuePendingMessage(int port_id, int channel_id, | 207 void EnqueuePendingMessage(int port_id, int channel_id, |
| 208 const Message& message); | 208 const Message& message); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 268 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
| 269 | 269 |
| 270 base::WeakPtrFactory<MessageService> weak_factory_; | 270 base::WeakPtrFactory<MessageService> weak_factory_; |
| 271 | 271 |
| 272 DISALLOW_COPY_AND_ASSIGN(MessageService); | 272 DISALLOW_COPY_AND_ASSIGN(MessageService); |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 } // namespace extensions | 275 } // namespace extensions |
| 276 | 276 |
| 277 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 277 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
| OLD | NEW |