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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (host) | 205 if (host) |
206 CloseChannel(port_id, error_message); | 206 CloseChannel(port_id, error_message); |
207 } | 207 } |
208 void PendingPostMessage(int port_id, | 208 void PendingPostMessage(int port_id, |
209 scoped_ptr<base::ListValue> message, | 209 scoped_ptr<base::ListValue> message, |
210 extensions::ExtensionHost* host) { | 210 extensions::ExtensionHost* host) { |
211 if (host) | 211 if (host) |
212 PostMessage(port_id, message.Pass()); | 212 PostMessage(port_id, message.Pass()); |
213 } | 213 } |
214 | 214 |
| 215 // Immediate dispatches a disconnect to |source| for |port_id|. Sets source's |
| 216 // runtime.lastMessage to |error_message|, if any. |
| 217 void DispatchOnDisconnect(content::RenderProcessHost* source, |
| 218 int port_id, |
| 219 const std::string& error_message); |
| 220 |
215 // ProfileKeyedAPI implementation. | 221 // ProfileKeyedAPI implementation. |
216 static const char* service_name() { | 222 static const char* service_name() { |
217 return "MessageService"; | 223 return "MessageService"; |
218 } | 224 } |
219 static const bool kServiceRedirectedInIncognito = true; | 225 static const bool kServiceRedirectedInIncognito = true; |
220 static const bool kServiceIsCreatedWithBrowserContext = false; | 226 static const bool kServiceIsCreatedWithBrowserContext = false; |
221 static const bool kServiceIsNULLWhileTesting = true; | 227 static const bool kServiceIsNULLWhileTesting = true; |
222 | 228 |
223 content::NotificationRegistrar registrar_; | 229 content::NotificationRegistrar registrar_; |
224 MessageChannelMap channels_; | 230 MessageChannelMap channels_; |
225 PendingChannelMap pending_channels_; | 231 PendingChannelMap pending_channels_; |
226 | 232 |
227 // Weak pointer. Guaranteed to outlive this class. | 233 // Weak pointer. Guaranteed to outlive this class. |
228 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 234 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
229 | 235 |
230 base::WeakPtrFactory<MessageService> weak_factory_; | 236 base::WeakPtrFactory<MessageService> weak_factory_; |
231 | 237 |
232 DISALLOW_COPY_AND_ASSIGN(MessageService); | 238 DISALLOW_COPY_AND_ASSIGN(MessageService); |
233 }; | 239 }; |
234 | 240 |
235 } // namespace extensions | 241 } // namespace extensions |
236 | 242 |
237 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 243 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |