summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/lazy_background_task_queue.h
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 22:57:51 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 22:57:51 +0000
commit7042b688fe403f1aa63e0ee5c44f63f4130e0392 (patch)
tree8fcad02d8a21f09df775f9ca2302fbec8900cb5e /chrome/browser/extensions/lazy_background_task_queue.h
parent9c46a89faedc01afa43d5332f362d9c01caaea68 (diff)
downloadchromium_src-7042b688fe403f1aa63e0ee5c44f63f4130e0392.zip
chromium_src-7042b688fe403f1aa63e0ee5c44f63f4130e0392.tar.gz
chromium_src-7042b688fe403f1aa63e0ee5c44f63f4130e0392.tar.bz2
Fix bug where transient pages would miss events dispatched while it was
unloading. The fix is a 2-parter: Part 1: lazy_background_queue.* now checks if the background page is unloading before allowing a task to run. If it is unloading, we wait until the page unloads, then reload it. Part 2: Part 1 exposed the problem which I had previously outlined in extension_process_manager.cc:403 - after we reload the page, we occasionally received messages from the renderer to decrement the keepalive count for the old page, throwing the count out of balance. The fix is to make sure we decrement keepalive counts only if the host we incremented them for is still active. BUG=123243 TEST=no Review URL: https://chromiumcodereview.appspot.com/10114015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/lazy_background_task_queue.h')
-rw-r--r--chrome/browser/extensions/lazy_background_task_queue.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/chrome/browser/extensions/lazy_background_task_queue.h b/chrome/browser/extensions/lazy_background_task_queue.h
index 12b85ba..abe71b2 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.h
+++ b/chrome/browser/extensions/lazy_background_task_queue.h
@@ -7,11 +7,13 @@
#pragma once
#include <map>
+#include <set>
#include <string>
#include "base/compiler_specific.h"
#include "base/callback_forward.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -27,7 +29,9 @@ namespace extensions {
//
// It is the consumer's responsibility to use this class when appropriate, i.e.
// only with extensions that have not-yet-loaded lazy background pages.
-class LazyBackgroundTaskQueue : public content::NotificationObserver {
+class LazyBackgroundTaskQueue
+ : public content::NotificationObserver,
+ public base::SupportsWeakPtr<LazyBackgroundTaskQueue> {
public:
typedef base::Callback<void(ExtensionHost*)> PendingTask;
@@ -56,6 +60,10 @@ class LazyBackgroundTaskQueue : public content::NotificationObserver {
typedef std::vector<PendingTask> PendingTasksList;
typedef std::map<PendingTasksKey,
linked_ptr<PendingTasksList> > PendingTasksMap;
+ typedef std::set<PendingTasksKey> PendingPageLoadList;
+
+ void StartLazyBackgroundPage(Profile* profile,
+ const std::string& extension_id);
// content::NotificationObserver interface.
virtual void Observe(int type,
@@ -72,6 +80,7 @@ class LazyBackgroundTaskQueue : public content::NotificationObserver {
Profile* profile_;
content::NotificationRegistrar registrar_;
PendingTasksMap pending_tasks_;
+ PendingPageLoadList pending_page_loads_;
};
} // namespace extensions