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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // Returns true if the task should be added to the queue (that is, if the | 36 // Returns true if the task should be added to the queue (that is, if the |
37 // extension has a lazy background page that isn't ready yet). If the | 37 // extension has a lazy background page that isn't ready yet). If the |
38 // extension has a lazy background page that is being suspended this method | 38 // extension has a lazy background page that is being suspended this method |
39 // cancels that suspension. | 39 // cancels that suspension. |
40 bool ShouldEnqueueTask(Profile* profile, const Extension* extension); | 40 bool ShouldEnqueueTask(Profile* profile, const Extension* extension); |
41 | 41 |
42 // Adds a task to the queue for a given extension. If this is the first | 42 // Adds a task to the queue for a given extension. If this is the first |
43 // task added for the extension, its lazy background page will be loaded. | 43 // task added for the extension, its lazy background page will be loaded. |
44 // The task will be called either when the page is loaded, or when the | 44 // The task will be called either when the page is loaded, or when the |
45 // page fails to load for some reason (e.g. a crash). In the latter case, | 45 // page fails to load for some reason (e.g. a crash or browser |
46 // the ExtensionHost parameter is NULL. | 46 // shutdown). In the latter case, the ExtensionHost parameter is NULL. |
47 void AddPendingTask( | 47 void AddPendingTask( |
48 Profile* profile, | 48 Profile* profile, |
49 const std::string& extension_id, | 49 const std::string& extension_id, |
50 const PendingTask& task); | 50 const PendingTask& task); |
51 | 51 |
52 private: | 52 private: |
53 // A map between an extension_id,Profile pair and the queue of tasks pending | 53 // A map between an extension_id,Profile pair and the queue of tasks pending |
54 // the load of its background page. | 54 // the load of its background page. |
55 typedef std::string ExtensionID; | 55 typedef std::string ExtensionID; |
56 typedef std::pair<Profile*, ExtensionID> PendingTasksKey; | 56 typedef std::pair<Profile*, ExtensionID> PendingTasksKey; |
(...skipping 14 matching lines...) Expand all Loading... |
71 const Extension* extension); | 71 const Extension* extension); |
72 | 72 |
73 Profile* profile_; | 73 Profile* profile_; |
74 content::NotificationRegistrar registrar_; | 74 content::NotificationRegistrar registrar_; |
75 PendingTasksMap pending_tasks_; | 75 PendingTasksMap pending_tasks_; |
76 }; | 76 }; |
77 | 77 |
78 } // namespace extensions | 78 } // namespace extensions |
79 | 79 |
80 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ | 80 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ |
OLD | NEW |