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

Side by Side Diff: chrome/browser/renderer_host/render_process_host.cc

Issue 257028: Remove the RenderProcessHost from the list of renderer processes when we call... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix unit tests Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/renderer_host/render_process_host.h" 5 #include "chrome/browser/renderer_host/render_process_host.h"
6 6
7 #include "base/rand_util.h" 7 #include "base/rand_util.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "chrome/browser/child_process_security_policy.h" 9 #include "chrome/browser/child_process_security_policy.h"
10 #include "chrome/common/child_process_info.h" 10 #include "chrome/common/child_process_info.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 : max_page_id_(-1), 80 : max_page_id_(-1),
81 id_(ChildProcessInfo::GenerateChildProcessUniqueId()), 81 id_(ChildProcessInfo::GenerateChildProcessUniqueId()),
82 profile_(profile), 82 profile_(profile),
83 sudden_termination_allowed_(true), 83 sudden_termination_allowed_(true),
84 ignore_input_events_(false) { 84 ignore_input_events_(false) {
85 all_hosts.AddWithID(this, id()); 85 all_hosts.AddWithID(this, id());
86 all_hosts.set_check_on_null_data(true); 86 all_hosts.set_check_on_null_data(true);
87 } 87 }
88 88
89 RenderProcessHost::~RenderProcessHost() { 89 RenderProcessHost::~RenderProcessHost() {
90 all_hosts.Remove(id()); 90 // In unit tests, Release() might not have been called.
91 if (all_hosts.Lookup(id()))
92 all_hosts.Remove(id());
91 } 93 }
92 94
93 void RenderProcessHost::Attach(IPC::Channel::Listener* listener, 95 void RenderProcessHost::Attach(IPC::Channel::Listener* listener,
94 int routing_id) { 96 int routing_id) {
95 listeners_.AddWithID(listener, routing_id); 97 listeners_.AddWithID(listener, routing_id);
96 } 98 }
97 99
98 void RenderProcessHost::Release(int listener_id) { 100 void RenderProcessHost::Release(int listener_id) {
99 DCHECK(listeners_.Lookup(listener_id) != NULL); 101 DCHECK(listeners_.Lookup(listener_id) != NULL);
100 listeners_.Remove(listener_id); 102 listeners_.Remove(listener_id);
101 103
102 // Make sure that all associated resource requests are stopped. 104 // Make sure that all associated resource requests are stopped.
103 CancelResourceRequests(listener_id); 105 CancelResourceRequests(listener_id);
104 106
105 // When no other owners of this object, we can delete ourselves 107 // When no other owners of this object, we can delete ourselves
106 if (listeners_.IsEmpty()) { 108 if (listeners_.IsEmpty()) {
107 NotificationService::current()->Notify( 109 NotificationService::current()->Notify(
108 NotificationType::RENDERER_PROCESS_TERMINATED, 110 NotificationType::RENDERER_PROCESS_TERMINATED,
109 Source<RenderProcessHost>(this), NotificationService::NoDetails()); 111 Source<RenderProcessHost>(this), NotificationService::NoDetails());
110 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 112 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
113
114 // Remove ourself from the list of renderer processes so that we can't be
115 // reused in between now and when the Delete task runs.
116 all_hosts.Remove(id());
111 } 117 }
112 } 118 }
113 119
114 void RenderProcessHost::ReportExpectingClose(int32 listener_id) { 120 void RenderProcessHost::ReportExpectingClose(int32 listener_id) {
115 listeners_expecting_close_.insert(listener_id); 121 listeners_expecting_close_.insert(listener_id);
116 } 122 }
117 123
118 void RenderProcessHost::UpdateMaxPageID(int32 page_id) { 124 void RenderProcessHost::UpdateMaxPageID(int32 page_id) {
119 if (page_id > max_page_id_) 125 if (page_id > max_page_id_)
120 max_page_id_ = page_id; 126 max_page_id_ = page_id;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 168
163 // Now pick a random suitable renderer, if we have any. 169 // Now pick a random suitable renderer, if we have any.
164 if (!suitable_renderers.empty()) { 170 if (!suitable_renderers.empty()) {
165 int suitable_count = static_cast<int>(suitable_renderers.size()); 171 int suitable_count = static_cast<int>(suitable_renderers.size());
166 int random_index = base::RandInt(0, suitable_count - 1); 172 int random_index = base::RandInt(0, suitable_count - 1);
167 return suitable_renderers[random_index]; 173 return suitable_renderers[random_index];
168 } 174 }
169 175
170 return NULL; 176 return NULL;
171 } 177 }
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