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_LAZY_BACKGROUND_TASK_QUEUE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 21 matching lines...) Expand all Loading... |
32 class LazyBackgroundTaskQueue | 32 class LazyBackgroundTaskQueue |
33 : public content::NotificationObserver, | 33 : public content::NotificationObserver, |
34 public base::SupportsWeakPtr<LazyBackgroundTaskQueue> { | 34 public base::SupportsWeakPtr<LazyBackgroundTaskQueue> { |
35 public: | 35 public: |
36 typedef base::Callback<void(ExtensionHost*)> PendingTask; | 36 typedef base::Callback<void(ExtensionHost*)> PendingTask; |
37 | 37 |
38 explicit LazyBackgroundTaskQueue(Profile* profile); | 38 explicit LazyBackgroundTaskQueue(Profile* profile); |
39 virtual ~LazyBackgroundTaskQueue(); | 39 virtual ~LazyBackgroundTaskQueue(); |
40 | 40 |
41 // Returns true if the task should be added to the queue (that is, if the | 41 // Returns true if the task should be added to the queue (that is, if the |
42 // extension has a lazy background page that isn't ready yet). | 42 // extension has a lazy background page that isn't ready yet). If the |
| 43 // extension has a lazy background page that is being suspended this method |
| 44 // cancels that suspension. |
43 bool ShouldEnqueueTask(Profile* profile, const Extension* extension); | 45 bool ShouldEnqueueTask(Profile* profile, const Extension* extension); |
44 | 46 |
45 // Adds a task to the queue for a given extension. If this is the first | 47 // Adds a task to the queue for a given extension. If this is the first |
46 // task added for the extension, its lazy background page will be loaded. | 48 // task added for the extension, its lazy background page will be loaded. |
47 // The task will be called either when the page is loaded, or when the | 49 // The task will be called either when the page is loaded, or when the |
48 // page fails to load for some reason (e.g. a crash). In the latter case, | 50 // page fails to load for some reason (e.g. a crash). In the latter case, |
49 // the ExtensionHost parameter is NULL. | 51 // the ExtensionHost parameter is NULL. |
50 void AddPendingTask( | 52 void AddPendingTask( |
51 Profile* profile, | 53 Profile* profile, |
52 const std::string& extension_id, | 54 const std::string& extension_id, |
(...skipping 26 matching lines...) Expand all Loading... |
79 | 81 |
80 Profile* profile_; | 82 Profile* profile_; |
81 content::NotificationRegistrar registrar_; | 83 content::NotificationRegistrar registrar_; |
82 PendingTasksMap pending_tasks_; | 84 PendingTasksMap pending_tasks_; |
83 PendingPageLoadList pending_page_loads_; | 85 PendingPageLoadList pending_page_loads_; |
84 }; | 86 }; |
85 | 87 |
86 } // namespace extensions | 88 } // namespace extensions |
87 | 89 |
88 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ |
OLD | NEW |