diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-15 02:07:32 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-15 02:07:32 +0000 |
commit | 86809eba59ca96feb557e98bbc5bdcf03c0c149b (patch) | |
tree | 93b19aa77bf2ef6fb8da10ec7768256da7e527e0 | |
parent | 235c01f7b7419a9e391e80826a51cd5027db4b0c (diff) | |
download | chromium_src-86809eba59ca96feb557e98bbc5bdcf03c0c149b.zip chromium_src-86809eba59ca96feb557e98bbc5bdcf03c0c149b.tar.gz chromium_src-86809eba59ca96feb557e98bbc5bdcf03c0c149b.tar.bz2 |
Revert 71458 - Blow away BackgroundContents when RenderView goes away.
Rolling this out because it breaks NoticeNotificationChanges on XP for some reason.
BUG=65189
TEST=TaskManagerBrowserTest.KillBGContents
Review URL: http://codereview.chromium.org/6226002
TBR=atwilson@chromium.org
Review URL: http://codereview.chromium.org/6310008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71536 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 5 insertions, 102 deletions
diff --git a/chrome/browser/background_contents_service.h b/chrome/browser/background_contents_service.h index 3a167c6..7fe16ac 100644 --- a/chrome/browser/background_contents_service.h +++ b/chrome/browser/background_contents_service.h @@ -84,8 +84,6 @@ class BackgroundContentsService : private NotificationObserver, TestApplicationIDLinkage); FRIEND_TEST_ALL_PREFIXES(TaskManagerBrowserTest, NoticeBGContentsChanges); - FRIEND_TEST_ALL_PREFIXES(TaskManagerBrowserTest, - KillBGContents); // Registers for various notifications. void StartObserving(Profile* profile); diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index b4eed25..1904d38 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -175,16 +175,6 @@ void BackgroundContents::Close(RenderViewHost* render_view_host) { delete this; } -void BackgroundContents::RenderViewGone(RenderViewHost* rvh, - base::TerminationStatus status, - int error_code) { - // Our RenderView went away, so we should go away also, so killing the process - // via the TaskManager doesn't permanently leave a BackgroundContents hanging - // around the system, blocking future instances from being created - // (http://crbug.com/65189). - delete this; -} - RendererPreferences BackgroundContents::GetRendererPrefs( Profile* profile) const { RendererPreferences preferences; diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h index 3ced642..ad5780016 100644 --- a/chrome/browser/tab_contents/background_contents.h +++ b/chrome/browser/tab_contents/background_contents.h @@ -75,9 +75,6 @@ class BackgroundContents : public RenderViewHostDelegate, bool* did_suppress_message); virtual void Close(RenderViewHost* render_view_host); virtual RendererPreferences GetRendererPrefs(Profile* profile) const; - virtual void RenderViewGone(RenderViewHost* rvh, - base::TerminationStatus status, - int error_code); // RenderViewHostDelegate::View virtual void CreateNewWindow( diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 1e6c367..b17132f 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -34,15 +34,12 @@ namespace { const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); -class ResourceChangeObserver - : public TaskManagerModelObserver, - public base::RefCountedThreadSafe<ResourceChangeObserver> { +class ResourceChangeObserver : public TaskManagerModelObserver { public: ResourceChangeObserver(const TaskManagerModel* model, int target_resource_count) : model_(model), - target_resource_count_(target_resource_count), - check_pending_(false) { + target_resource_count_(target_resource_count) { } virtual void OnModelChanged() { @@ -62,46 +59,13 @@ class ResourceChangeObserver } private: - friend class base::RefCountedThreadSafe<ResourceChangeObserver>; void OnResourceChange() { - // The task manager can churn resources (for example, when a - // BackgroundContents navigates, we remove and re-add the resource to - // allow the UI to update properly). So check the resource count via - // a task to make sure we aren't triggered by a transient change. - if (check_pending_) - return; - check_pending_ = true; - MessageLoopForUI::current()->PostTask( - FROM_HERE, - NewRunnableMethod(this, &ResourceChangeObserver::CheckResourceCount)); - } - - void CheckResourceCount() { if (model_->ResourceCount() == target_resource_count_) MessageLoopForUI::current()->Quit(); } const TaskManagerModel* model_; const int target_resource_count_; - bool check_pending_; -}; - -// Helper class used to wait for a BackgroundContents to finish loading. -class BackgroundContentsListener : public NotificationObserver { - public: - explicit BackgroundContentsListener(Profile* profile) { - registrar_.Add(this, NotificationType::BACKGROUND_CONTENTS_NAVIGATED, - Source<Profile>(profile)); - } - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - // Quit once the BackgroundContents has been loaded. - if (type.value == NotificationType::BACKGROUND_CONTENTS_NAVIGATED) - MessageLoopForUI::current()->Quit(); - } - private: - NotificationRegistrar registrar_; }; } // namespace @@ -115,17 +79,10 @@ class TaskManagerBrowserTest : public ExtensionBrowserTest { void WaitForResourceChange(int target_count) { if (model()->ResourceCount() == target_count) return; - scoped_refptr<ResourceChangeObserver> observer( - new ResourceChangeObserver(model(), target_count)); - model()->AddObserver(observer.get()); - ui_test_utils::RunMessageLoop(); - model()->RemoveObserver(observer.get()); - } - - // Wait for any pending BackgroundContents to finish starting up. - void WaitForBackgroundContents() { - BackgroundContentsListener listener(browser()->profile()); + ResourceChangeObserver observer(model(), target_count); + model()->AddObserver(&observer); ui_test_utils::RunMessageLoop(); + model()->RemoveObserver(&observer); } }; @@ -192,45 +149,6 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeBGContentsChanges) { WaitForResourceChange(2); } -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillBGContents) { - EXPECT_EQ(0, model()->ResourceCount()); - - // Show the task manager. This populates the model, and helps with debugging - // (you see the task manager). - browser()->window()->ShowTaskManager(); - - // Browser and the New Tab Page. - WaitForResourceChange(2); - - // Open a new background contents and make sure we notice that. - GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), - FilePath(kTitle1File))); - - BackgroundContentsService* service = - browser()->profile()->GetBackgroundContentsService(); - string16 application_id(ASCIIToUTF16("test_app_id")); - service->LoadBackgroundContents(browser()->profile(), - url, - ASCIIToUTF16("background_page"), - application_id); - // Wait for the background contents process to finish loading. - WaitForBackgroundContents(); - EXPECT_EQ(3, model()->ResourceCount()); - - // Kill the background contents process and verify that it disappears from the - // model. - bool found = false; - for (int i = 0; i < model()->ResourceCount(); ++i) { - if (model()->IsBackgroundResource(i)) { - TaskManager::GetInstance()->KillProcess(i); - found = true; - break; - } - } - ASSERT_TRUE(found); - WaitForResourceChange(2); -} - IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionChanges) { EXPECT_EQ(0, model()->ResourceCount()); |