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

Side by Side Diff: chrome/browser/tab_contents/background_contents.cc

Issue 13871010: Explicitly free the web contents in the background contents destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | no next file » | 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 #include "chrome/browser/tab_contents/background_contents.h" 5 #include "chrome/browser/tab_contents/background_contents.h"
6 6
7 #include "chrome/browser/background/background_contents_service.h" 7 #include "chrome/browser/background/background_contents_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/renderer_preferences_util.h" 9 #include "chrome/browser/renderer_preferences_util.h"
10 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 10 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 profile_(NULL) { 54 profile_(NULL) {
55 } 55 }
56 56
57 BackgroundContents::~BackgroundContents() { 57 BackgroundContents::~BackgroundContents() {
58 if (!web_contents_.get()) // Will be null for unit tests. 58 if (!web_contents_.get()) // Will be null for unit tests.
59 return; 59 return;
60 content::NotificationService::current()->Notify( 60 content::NotificationService::current()->Notify(
61 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 61 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
62 content::Source<Profile>(profile_), 62 content::Source<Profile>(profile_),
63 content::Details<BackgroundContents>(this)); 63 content::Details<BackgroundContents>(this));
64 // Manually clear web_contents_ to try to track down http://crbug.com/164617.
65 // Freeing the WebContents can cause the RenderViewHost to be destroyed, so
66 // we need to do this after sending out BACKGROUND_CONTENTS_DELETED to give
67 // things like the TaskManager a chance to clean up their references first.
68 web_contents_.reset();
64 } 69 }
65 70
66 const GURL& BackgroundContents::GetURL() const { 71 const GURL& BackgroundContents::GetURL() const {
67 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL(); 72 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL();
68 } 73 }
69 74
70 void BackgroundContents::CloseContents(WebContents* source) { 75 void BackgroundContents::CloseContents(WebContents* source) {
71 content::NotificationService::current()->Notify( 76 content::NotificationService::current()->Notify(
72 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, 77 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED,
73 content::Source<Profile>(profile_), 78 content::Source<Profile>(profile_),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 case chrome::NOTIFICATION_PROFILE_DESTROYED: 131 case chrome::NOTIFICATION_PROFILE_DESTROYED:
127 case chrome::NOTIFICATION_APP_TERMINATING: { 132 case chrome::NOTIFICATION_APP_TERMINATING: {
128 delete this; 133 delete this;
129 break; 134 break;
130 } 135 }
131 default: 136 default:
132 NOTREACHED() << "Unexpected notification sent."; 137 NOTREACHED() << "Unexpected notification sent.";
133 break; 138 break;
134 } 139 }
135 } 140 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698