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 <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/extensions/api/messaging/message_property_provider.h" | 18 #include "chrome/browser/extensions/api/messaging/message_property_provider.h" |
19 #include "extensions/browser/api/messaging/native_message_host.h" | 19 #include "extensions/browser/api/messaging/native_message_host.h" |
20 #include "extensions/browser/browser_context_keyed_api_factory.h" | 20 #include "extensions/browser/browser_context_keyed_api_factory.h" |
21 #include "extensions/common/api/messaging/message.h" | 21 #include "extensions/common/api/messaging/message.h" |
| 22 #include "extensions/common/extension_id.h" |
22 | 23 |
23 class GURL; | 24 class GURL; |
24 class Profile; | 25 class Profile; |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 class BrowserContext; | 28 class BrowserContext; |
28 } | 29 } |
29 | 30 |
30 namespace extensions { | 31 namespace extensions { |
31 class Extension; | 32 class Extension; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 using MessageChannelMap = std::map<int, std::unique_ptr<MessageChannel>>; | 189 using MessageChannelMap = std::map<int, std::unique_ptr<MessageChannel>>; |
189 | 190 |
190 using PendingMessage = std::pair<int, Message>; | 191 using PendingMessage = std::pair<int, Message>; |
191 using PendingMessagesQueue = std::vector<PendingMessage>; | 192 using PendingMessagesQueue = std::vector<PendingMessage>; |
192 // A set of channel IDs waiting to complete opening, and any pending messages | 193 // A set of channel IDs waiting to complete opening, and any pending messages |
193 // queued to be sent on those channels. | 194 // queued to be sent on those channels. |
194 using PendingChannelMap = std::map<int, PendingMessagesQueue>; | 195 using PendingChannelMap = std::map<int, PendingMessagesQueue>; |
195 | 196 |
196 // A map of channel ID to information about the extension that is waiting | 197 // A map of channel ID to information about the extension that is waiting |
197 // for that channel to open. Used for lazy background pages. | 198 // for that channel to open. Used for lazy background pages. |
198 using ExtensionID = std::string; | |
199 using PendingLazyBackgroundPageChannel = | 199 using PendingLazyBackgroundPageChannel = |
200 std::pair<content::BrowserContext*, ExtensionID>; | 200 std::pair<content::BrowserContext*, ExtensionId>; |
201 using PendingLazyBackgroundPageChannelMap = | 201 using PendingLazyBackgroundPageChannelMap = |
202 std::map<int, PendingLazyBackgroundPageChannel>; | 202 std::map<int, PendingLazyBackgroundPageChannel>; |
203 | 203 |
204 // Common implementation for opening a channel configured by |params|. | 204 // Common implementation for opening a channel configured by |params|. |
205 // | 205 // |
206 // |target_extension| will be non-null if |params->target_extension_id| is | 206 // |target_extension| will be non-null if |params->target_extension_id| is |
207 // non-empty, that is, if the target is an extension, it must exist. | 207 // non-empty, that is, if the target is an extension, it must exist. |
208 // | 208 // |
209 // |did_enqueue| will be true if the channel opening was delayed while | 209 // |did_enqueue| will be true if the channel opening was delayed while |
210 // waiting for an event page to start, false otherwise. | 210 // waiting for an event page to start, false otherwise. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 316 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
317 | 317 |
318 base::WeakPtrFactory<MessageService> weak_factory_; | 318 base::WeakPtrFactory<MessageService> weak_factory_; |
319 | 319 |
320 DISALLOW_COPY_AND_ASSIGN(MessageService); | 320 DISALLOW_COPY_AND_ASSIGN(MessageService); |
321 }; | 321 }; |
322 | 322 |
323 } // namespace extensions | 323 } // namespace extensions |
324 | 324 |
325 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 325 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |