Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: chrome/browser/extensions/api/messaging/message_service.h

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 MessagePort() {} 102 MessagePort() {}
103 103
104 private: 104 private:
105 DISALLOW_COPY_AND_ASSIGN(MessagePort); 105 DISALLOW_COPY_AND_ASSIGN(MessagePort);
106 }; 106 };
107 107
108 // Allocates a pair of port ids. 108 // Allocates a pair of port ids.
109 // NOTE: this can be called from any thread. 109 // NOTE: this can be called from any thread.
110 static void AllocatePortIdPair(int* port1, int* port2); 110 static void AllocatePortIdPair(int* port1, int* port2);
111 111
112 explicit MessageService(Profile* profile); 112 explicit MessageService(content::BrowserContext* context);
113 virtual ~MessageService(); 113 virtual ~MessageService();
114 114
115 // ProfileKeyedAPI implementation. 115 // ProfileKeyedAPI implementation.
116 static ProfileKeyedAPIFactory<MessageService>* GetFactoryInstance(); 116 static ProfileKeyedAPIFactory<MessageService>* GetFactoryInstance();
117 117
118 // Convenience method to get the MessageService for a browser context. 118 // Convenience method to get the MessageService for a browser context.
119 static MessageService* Get(content::BrowserContext* profile); 119 static MessageService* Get(content::BrowserContext* context);
120 120
121 // Given an extension's ID, opens a channel between the given renderer "port" 121 // Given an extension's ID, opens a channel between the given renderer "port"
122 // and every listening context owned by that extension. |channel_name| is 122 // and every listening context owned by that extension. |channel_name| is
123 // an optional identifier for use by extension developers. 123 // an optional identifier for use by extension developers.
124 void OpenChannelToExtension( 124 void OpenChannelToExtension(
125 int source_process_id, int source_routing_id, int receiver_port_id, 125 int source_process_id, int source_routing_id, int receiver_port_id,
126 const std::string& source_extension_id, 126 const std::string& source_extension_id,
127 const std::string& target_extension_id, 127 const std::string& target_extension_id,
128 const GURL& source_url, 128 const GURL& source_url,
129 const std::string& channel_name, 129 const std::string& channel_name,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 typedef std::pair<int, Message> PendingMessage; 169 typedef std::pair<int, Message> PendingMessage;
170 typedef std::vector<PendingMessage> PendingMessagesQueue; 170 typedef std::vector<PendingMessage> PendingMessagesQueue;
171 // A set of channel IDs waiting for TLS channel IDs to complete opening, 171 // 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. 172 // and any pending messages queued to be sent on those channels.
173 typedef std::map<int, PendingMessagesQueue> PendingTlsChannelIdMap; 173 typedef std::map<int, PendingMessagesQueue> PendingTlsChannelIdMap;
174 174
175 // A map of channel ID to information about the extension that is waiting 175 // A map of channel ID to information about the extension that is waiting
176 // for that channel to open. Used for lazy background pages. 176 // for that channel to open. Used for lazy background pages.
177 typedef std::string ExtensionID; 177 typedef std::string ExtensionID;
178 typedef std::pair<Profile*, ExtensionID> PendingLazyBackgroundPageChannel; 178 typedef std::pair<content::BrowserContext*, ExtensionID>
179 PendingLazyBackgroundPageChannel;
179 typedef std::map<int, PendingLazyBackgroundPageChannel> 180 typedef std::map<int, PendingLazyBackgroundPageChannel>
180 PendingLazyBackgroundPageChannelMap; 181 PendingLazyBackgroundPageChannelMap;
181 182
182 // Common among OpenChannel* variants. 183 // Common among OpenChannel* variants.
183 bool OpenChannelImpl(scoped_ptr<OpenChannelParams> params); 184 bool OpenChannelImpl(scoped_ptr<OpenChannelParams> params);
184 185
185 void CloseChannelImpl(MessageChannelMap::iterator channel_iter, 186 void CloseChannelImpl(MessageChannelMap::iterator channel_iter,
186 int port_id, 187 int port_id,
187 const std::string& error_message, 188 const std::string& error_message,
188 bool notify_other_port); 189 bool notify_other_port);
(...skipping 23 matching lines...) Expand all
212 const Message& message); 213 const Message& message);
213 214
214 // Immediately sends a message to the given port. 215 // Immediately sends a message to the given port.
215 void DispatchMessage(int port_id, MessageChannel* channel, 216 void DispatchMessage(int port_id, MessageChannel* channel,
216 const Message& message); 217 const Message& message);
217 218
218 // Potentially registers a pending task with the LazyBackgroundTaskQueue 219 // Potentially registers a pending task with the LazyBackgroundTaskQueue
219 // to open a channel. Returns true if a task was queued. 220 // to open a channel. Returns true if a task was queued.
220 // Takes ownership of |params| if true is returned. 221 // Takes ownership of |params| if true is returned.
221 bool MaybeAddPendingLazyBackgroundPageOpenChannelTask( 222 bool MaybeAddPendingLazyBackgroundPageOpenChannelTask(
222 Profile* profile, 223 content::BrowserContext* context,
223 const Extension* extension, 224 const Extension* extension,
224 OpenChannelParams* params); 225 OpenChannelParams* params);
225 226
226 // Callbacks for LazyBackgroundTaskQueue tasks. The queue passes in an 227 // Callbacks for LazyBackgroundTaskQueue tasks. The queue passes in an
227 // ExtensionHost to its task callbacks, though some of our callbacks don't 228 // ExtensionHost to its task callbacks, though some of our callbacks don't
228 // use that argument. 229 // use that argument.
229 void PendingLazyBackgroundPageOpenChannel( 230 void PendingLazyBackgroundPageOpenChannel(
230 scoped_ptr<OpenChannelParams> params, 231 scoped_ptr<OpenChannelParams> params,
231 int source_process_id, 232 int source_process_id,
232 extensions::ExtensionHost* host); 233 extensions::ExtensionHost* host);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 LazyBackgroundTaskQueue* lazy_background_task_queue_; 268 LazyBackgroundTaskQueue* lazy_background_task_queue_;
268 269
269 base::WeakPtrFactory<MessageService> weak_factory_; 270 base::WeakPtrFactory<MessageService> weak_factory_;
270 271
271 DISALLOW_COPY_AND_ASSIGN(MessageService); 272 DISALLOW_COPY_AND_ASSIGN(MessageService);
272 }; 273 };
273 274
274 } // namespace extensions 275 } // namespace extensions
275 276
276 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ 277 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698