Skip to content

Commit 70f52a1

Browse files
author
Cong Liu
committed
Delete DispatcherHost when RVH deleted
1 parent 899d022 commit 70f52a1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/api/dispatcher_host.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ DispatcherHost::DispatcherHost(content::RenderViewHost* host)
6262

6363
DispatcherHost::~DispatcherHost() {
6464
g_dispatcher_host_map.erase(render_view_host());
65+
render_view_host_ = NULL;
6566
std::set<int>::iterator it;
6667
for (it = objects_.begin(); it != objects_.end(); it++) {
6768
if (objects_registry_.Lookup(*it))
@@ -139,6 +140,15 @@ void DispatcherHost::RenderViewHostChanged(content::RenderViewHost* old_host,
139140
delete this;
140141
}
141142

143+
void DispatcherHost::RenderViewDeleted(content::RenderViewHost* host) {
144+
if (render_view_host_ == host)
145+
delete this;
146+
}
147+
148+
void DispatcherHost::RenderProcessGone(base::TerminationStatus status) {
149+
delete this;
150+
}
151+
142152
void DispatcherHost::OnAllocateObject(int object_id,
143153
const std::string& type,
144154
const base::DictionaryValue& option) {

src/api/dispatcher_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class DispatcherHost : public content::WebContentsObserver {
7272
virtual bool Send(IPC::Message* message) OVERRIDE;
7373
virtual void RenderViewHostChanged(content::RenderViewHost* old_host,
7474
content::RenderViewHost* new_host) OVERRIDE;
75+
virtual void RenderViewDeleted(content::RenderViewHost* host) OVERRIDE;
76+
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
7577
content::RenderViewHost* render_view_host() const {
7678
return render_view_host_;
7779
}

0 commit comments

Comments
 (0)