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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 static PolicyPermission IsNativeMessagingHostAllowed( | 113 static PolicyPermission IsNativeMessagingHostAllowed( |
114 const PrefService* pref_service, | 114 const PrefService* pref_service, |
115 const std::string& native_host_name); | 115 const std::string& native_host_name); |
116 | 116 |
117 // Allocates a pair of port ids. | 117 // Allocates a pair of port ids. |
118 // NOTE: this can be called from any thread. | 118 // NOTE: this can be called from any thread. |
119 static void AllocatePortIdPair(int* port1, int* port2); | 119 static void AllocatePortIdPair(int* port1, int* port2); |
120 | 120 |
121 explicit MessageService(content::BrowserContext* context); | 121 explicit MessageService(content::BrowserContext* context); |
122 virtual ~MessageService(); | 122 ~MessageService() override; |
123 | 123 |
124 // BrowserContextKeyedAPI implementation. | 124 // BrowserContextKeyedAPI implementation. |
125 static BrowserContextKeyedAPIFactory<MessageService>* GetFactoryInstance(); | 125 static BrowserContextKeyedAPIFactory<MessageService>* GetFactoryInstance(); |
126 | 126 |
127 // Convenience method to get the MessageService for a browser context. | 127 // Convenience method to get the MessageService for a browser context. |
128 static MessageService* Get(content::BrowserContext* context); | 128 static MessageService* Get(content::BrowserContext* context); |
129 | 129 |
130 // Given an extension's ID, opens a channel between the given renderer "port" | 130 // Given an extension's ID, opens a channel between the given renderer "port" |
131 // and every listening context owned by that extension. |channel_name| is | 131 // and every listening context owned by that extension. |channel_name| is |
132 // an optional identifier for use by extension developers. | 132 // an optional identifier for use by extension developers. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, | 189 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, |
190 int port_id, | 190 int port_id, |
191 const std::string& error_message, | 191 const std::string& error_message, |
192 bool notify_other_port); | 192 bool notify_other_port); |
193 | 193 |
194 // Have MessageService take ownership of |channel|, and remove any pending | 194 // Have MessageService take ownership of |channel|, and remove any pending |
195 // channels with the same id. | 195 // channels with the same id. |
196 void AddChannel(MessageChannel* channel, int receiver_port_id); | 196 void AddChannel(MessageChannel* channel, int receiver_port_id); |
197 | 197 |
198 // content::NotificationObserver interface. | 198 // content::NotificationObserver interface. |
199 virtual void Observe(int type, | 199 void Observe(int type, |
200 const content::NotificationSource& source, | 200 const content::NotificationSource& source, |
201 const content::NotificationDetails& details) override; | 201 const content::NotificationDetails& details) override; |
202 | 202 |
203 // A process that might be in our list of channels has closed. | 203 // A process that might be in our list of channels has closed. |
204 void OnProcessClosed(content::RenderProcessHost* process); | 204 void OnProcessClosed(content::RenderProcessHost* process); |
205 | 205 |
206 void GotChannelID(scoped_ptr<OpenChannelParams> params, | 206 void GotChannelID(scoped_ptr<OpenChannelParams> params, |
207 const std::string& tls_channel_id); | 207 const std::string& tls_channel_id); |
208 | 208 |
209 // Enqueues a message on a pending channel. | 209 // Enqueues a message on a pending channel. |
210 void EnqueuePendingMessage(int port_id, int channel_id, | 210 void EnqueuePendingMessage(int port_id, int channel_id, |
211 const Message& message); | 211 const Message& message); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 271 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
272 | 272 |
273 base::WeakPtrFactory<MessageService> weak_factory_; | 273 base::WeakPtrFactory<MessageService> weak_factory_; |
274 | 274 |
275 DISALLOW_COPY_AND_ASSIGN(MessageService); | 275 DISALLOW_COPY_AND_ASSIGN(MessageService); |
276 }; | 276 }; |
277 | 277 |
278 } // namespace extensions | 278 } // namespace extensions |
279 | 279 |
280 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 280 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |