| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_H_ | 5 #ifndef EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_H_ |
| 6 #define EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_H_ | 6 #define EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/scoped_observer.h" | 16 #include "base/scoped_observer.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
| 21 #include "extensions/common/extension_id.h" |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 class BrowserContext; | 24 class BrowserContext; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace extensions { | 27 namespace extensions { |
| 27 class Extension; | 28 class Extension; |
| 28 class ExtensionHost; | 29 class ExtensionHost; |
| 29 class ExtensionRegistry; | 30 class ExtensionRegistry; |
| 30 | 31 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void AddPendingTask( | 66 void AddPendingTask( |
| 66 content::BrowserContext* context, | 67 content::BrowserContext* context, |
| 67 const std::string& extension_id, | 68 const std::string& extension_id, |
| 68 const PendingTask& task); | 69 const PendingTask& task); |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 FRIEND_TEST_ALL_PREFIXES(LazyBackgroundTaskQueueTest, ProcessPendingTasks); | 72 FRIEND_TEST_ALL_PREFIXES(LazyBackgroundTaskQueueTest, ProcessPendingTasks); |
| 72 | 73 |
| 73 // A map between a BrowserContext/extension_id pair and the queue of tasks | 74 // A map between a BrowserContext/extension_id pair and the queue of tasks |
| 74 // pending the load of its background page. | 75 // pending the load of its background page. |
| 75 typedef std::string ExtensionID; | 76 typedef std::pair<content::BrowserContext*, ExtensionId> PendingTasksKey; |
| 76 typedef std::pair<content::BrowserContext*, ExtensionID> PendingTasksKey; | |
| 77 typedef std::vector<PendingTask> PendingTasksList; | 77 typedef std::vector<PendingTask> PendingTasksList; |
| 78 using PendingTasksMap = | 78 using PendingTasksMap = |
| 79 std::map<PendingTasksKey, std::unique_ptr<PendingTasksList>>; | 79 std::map<PendingTasksKey, std::unique_ptr<PendingTasksList>>; |
| 80 | 80 |
| 81 // content::NotificationObserver interface. | 81 // content::NotificationObserver interface. |
| 82 void Observe(int type, | 82 void Observe(int type, |
| 83 const content::NotificationSource& source, | 83 const content::NotificationSource& source, |
| 84 const content::NotificationDetails& details) override; | 84 const content::NotificationDetails& details) override; |
| 85 | 85 |
| 86 // ExtensionRegistryObserver interface. | 86 // ExtensionRegistryObserver interface. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 content::NotificationRegistrar registrar_; | 99 content::NotificationRegistrar registrar_; |
| 100 PendingTasksMap pending_tasks_; | 100 PendingTasksMap pending_tasks_; |
| 101 | 101 |
| 102 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 102 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 103 extension_registry_observer_; | 103 extension_registry_observer_; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace extensions | 106 } // namespace extensions |
| 107 | 107 |
| 108 #endif // EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_H_ | 108 #endif // EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_H_ |
| OLD | NEW |