From 7042b688fe403f1aa63e0ee5c44f63f4130e0392 Mon Sep 17 00:00:00 2001 From: "mpcomplete@chromium.org" Date: Thu, 19 Apr 2012 22:57:51 +0000 Subject: 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 --- chrome/browser/extensions/lazy_background_task_queue.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'chrome/browser/extensions/lazy_background_task_queue.h') 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 +#include #include #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 { public: typedef base::Callback PendingTask; @@ -56,6 +60,10 @@ class LazyBackgroundTaskQueue : public content::NotificationObserver { typedef std::vector PendingTasksList; typedef std::map > PendingTasksMap; + typedef std::set 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 -- cgit v1.1