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

Side by Side Diff: chrome/browser/extensions/lazy_background_task_queue.h

Issue 10830235: Remove obsolete cruft in LazyBackgroundTaskQueue that dealt with queueing up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/lazy_background_task_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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>
10 #include <string> 9 #include <string>
11 10
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
14 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
18 16
19 class Profile; 17 class Profile;
20 18
21 namespace extensions { 19 namespace extensions {
22 class Extension; 20 class Extension;
23 class ExtensionHost; 21 class ExtensionHost;
24 22
25 // This class maintains a queue of tasks that should execute when an 23 // This class maintains a queue of tasks that should execute when an
26 // extension's lazy background page is loaded. It is also in charge of loading 24 // extension's lazy background page is loaded. It is also in charge of loading
27 // the page when the first task is queued. 25 // the page when the first task is queued.
28 // 26 //
29 // It is the consumer's responsibility to use this class when appropriate, i.e. 27 // It is the consumer's responsibility to use this class when appropriate, i.e.
30 // only with extensions that have not-yet-loaded lazy background pages. 28 // only with extensions that have not-yet-loaded lazy background pages.
31 class LazyBackgroundTaskQueue 29 class LazyBackgroundTaskQueue : public content::NotificationObserver {
32 : public content::NotificationObserver,
33 public base::SupportsWeakPtr<LazyBackgroundTaskQueue> {
34 public: 30 public:
35 typedef base::Callback<void(ExtensionHost*)> PendingTask; 31 typedef base::Callback<void(ExtensionHost*)> PendingTask;
36 32
37 explicit LazyBackgroundTaskQueue(Profile* profile); 33 explicit LazyBackgroundTaskQueue(Profile* profile);
38 virtual ~LazyBackgroundTaskQueue(); 34 virtual ~LazyBackgroundTaskQueue();
39 35
40 // 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
41 // 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
42 // 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
43 // cancels that suspension. 39 // cancels that suspension.
(...skipping 10 matching lines...) Expand all
54 const PendingTask& task); 50 const PendingTask& task);
55 51
56 private: 52 private:
57 // 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
58 // the load of its background page. 54 // the load of its background page.
59 typedef std::string ExtensionID; 55 typedef std::string ExtensionID;
60 typedef std::pair<Profile*, ExtensionID> PendingTasksKey; 56 typedef std::pair<Profile*, ExtensionID> PendingTasksKey;
61 typedef std::vector<PendingTask> PendingTasksList; 57 typedef std::vector<PendingTask> PendingTasksList;
62 typedef std::map<PendingTasksKey, 58 typedef std::map<PendingTasksKey,
63 linked_ptr<PendingTasksList> > PendingTasksMap; 59 linked_ptr<PendingTasksList> > PendingTasksMap;
64 typedef std::set<PendingTasksKey> PendingPageLoadList;
65
66 void StartLazyBackgroundPage(Profile* profile,
67 const std::string& extension_id);
68 60
69 // content::NotificationObserver interface. 61 // content::NotificationObserver interface.
70 virtual void Observe(int type, 62 virtual void Observe(int type,
71 const content::NotificationSource& source, 63 const content::NotificationSource& source,
72 const content::NotificationDetails& details) OVERRIDE; 64 const content::NotificationDetails& details) OVERRIDE;
73 65
74 // Called when a lazy background page has finished loading, or has failed to 66 // Called when a lazy background page has finished loading, or has failed to
75 // load (host is NULL in that case). All enqueued tasks are run in order. 67 // load (host is NULL in that case). All enqueued tasks are run in order.
76 void ProcessPendingTasks( 68 void ProcessPendingTasks(
77 ExtensionHost* host, 69 ExtensionHost* host,
78 Profile* profile, 70 Profile* profile,
79 const Extension* extension); 71 const Extension* extension);
80 72
81 Profile* profile_; 73 Profile* profile_;
82 content::NotificationRegistrar registrar_; 74 content::NotificationRegistrar registrar_;
83 PendingTasksMap pending_tasks_; 75 PendingTasksMap pending_tasks_;
84 PendingPageLoadList pending_page_loads_;
85 }; 76 };
86 77
87 } // namespace extensions 78 } // namespace extensions
88 79
89 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_ 80 #endif // CHROME_BROWSER_EXTENSIONS_LAZY_BACKGROUND_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/lazy_background_task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698