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

Unified Diff: extensions/browser/guest_view/guest_view_base.cc

Issue 618823002: GuestView: Move lifetime management out of content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix extensionoptions cleanup Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/guest_view/guest_view_base.cc
diff --git a/extensions/browser/guest_view/guest_view_base.cc b/extensions/browser/guest_view/guest_view_base.cc
index 9f5a244ffa0f36a2185a864d22e6b7f86746e78c..b29ebbd6655aebb4400ab85482d62be8c70361ed 100644
--- a/extensions/browser/guest_view/guest_view_base.cc
+++ b/extensions/browser/guest_view/guest_view_base.cc
@@ -79,6 +79,11 @@ class GuestViewBase::EmbedderWebContentsObserver : public WebContentsObserver {
Destroy();
}
+ virtual void AboutToNavigateRenderView(
+ content::RenderViewHost* render_view_host) OVERRIDE {
+ Destroy();
lfg 2014/09/30 18:59:27 Why do we need this? Is it safe? This call will d
Fady Samuel 2014/09/30 22:50:03 Add comments throughout to explain lifetime manage
lfg 2014/09/30 23:29:42 I see. Makes sense now :)
+ }
+
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE {
Destroy();
}
@@ -297,24 +302,6 @@ void GuestViewBase::RenderProcessExited(content::RenderProcessHost* host,
Destroy();
}
-void GuestViewBase::Destroy() {
- DCHECK(web_contents());
- content::RenderProcessHost* host =
- content::RenderProcessHost::FromID(embedder_render_process_id());
- if (host)
- host->RemoveObserver(this);
- WillDestroy();
- if (!destruction_callback_.is_null())
- destruction_callback_.Run();
-
- webcontents_guestview_map.Get().erase(web_contents());
- GuestViewManager::FromBrowserContext(browser_context_)->
- RemoveGuest(guest_instance_id_);
- pending_events_.clear();
-
- delete web_contents();
-}
-
void GuestViewBase::DidAttach(int guest_proxy_routing_id) {
// Give the derived class an opportunity to perform some actions.
DidAttachToEmbedder();
@@ -341,6 +328,24 @@ void GuestViewBase::GuestSizeChanged(const gfx::Size& old_size,
GuestSizeChangedDueToAutoSize(old_size, new_size);
}
+void GuestViewBase::Destroy() {
+ DCHECK(web_contents());
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(embedder_render_process_id());
+ if (host)
+ host->RemoveObserver(this);
+ WillDestroy();
+ if (!destruction_callback_.is_null())
+ destruction_callback_.Run();
+
+ webcontents_guestview_map.Get().erase(web_contents());
+ GuestViewManager::FromBrowserContext(browser_context_)->
+ RemoveGuest(guest_instance_id_);
+ pending_events_.clear();
+
+ delete web_contents();
+}
+
void GuestViewBase::SetAttachParams(const base::DictionaryValue& params) {
attach_params_.reset(params.DeepCopy());
attach_params_->GetInteger(guestview::kParameterInstanceId,

Powered by Google App Engine
This is Rietveld 408576698