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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 8597005: Provide a way for RenderProcessHosts to register themselves in the global host map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « content/browser/renderer_host/render_process_host_impl.h ('k') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return false; 242 return false;
243 243
244 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( 244 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(
245 host->GetID()) != 245 host->GetID()) !=
246 content::WebUIFactory::Get()->HasWebUIScheme(site_url)) 246 content::WebUIFactory::Get()->HasWebUIScheme(site_url))
247 return false; 247 return false;
248 248
249 return content::GetContentClient()->browser()->IsSuitableHost(host, site_url); 249 return content::GetContentClient()->browser()->IsSuitableHost(host, site_url);
250 } 250 }
251 251
252 } // namespace
253
254 // the global list of all renderer processes 252 // the global list of all renderer processes
255 base::LazyInstance< 253 base::LazyInstance<
256 IDMap<content::RenderProcessHost>, 254 IDMap<content::RenderProcessHost>,
257 base::LeakyLazyInstanceTraits<IDMap<content::RenderProcessHost> > > 255 base::LeakyLazyInstanceTraits<IDMap<content::RenderProcessHost> > >
258 g_all_hosts = LAZY_INSTANCE_INITIALIZER; 256 g_all_hosts = LAZY_INSTANCE_INITIALIZER;
259 257
258 } // namespace
259
260 // static 260 // static
261 bool g_run_renderer_in_process_ = false; 261 bool g_run_renderer_in_process_ = false;
262 262
263 // static 263 // static
264 void content::RenderProcessHost::SetMaxRendererProcessCountForTest( 264 void content::RenderProcessHost::SetMaxRendererProcessCountForTest(
265 size_t count) { 265 size_t count) {
266 max_renderer_count_override = count; 266 max_renderer_count_override = count;
267 } 267 }
268 268
269 RenderProcessHostImpl::RenderProcessHostImpl( 269 RenderProcessHostImpl::RenderProcessHostImpl(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 base::PLATFORM_FILE_WRITE_ATTRIBUTES | base::PLATFORM_FILE_ENUMERATE); 316 base::PLATFORM_FILE_WRITE_ATTRIBUTES | base::PLATFORM_FILE_ENUMERATE);
317 // This is so that we can rename the old sandbox out of the way so that we 317 // This is so that we can rename the old sandbox out of the way so that we
318 // know we've taken care of it. 318 // know we've taken care of it.
319 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( 319 ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile(
320 GetID(), browser_context->GetPath().Append( 320 GetID(), browser_context->GetPath().Append(
321 fileapi::SandboxMountPointProvider::kRenamedOldFileSystemDirectory), 321 fileapi::SandboxMountPointProvider::kRenamedOldFileSystemDirectory),
322 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | 322 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS |
323 base::PLATFORM_FILE_WRITE); 323 base::PLATFORM_FILE_WRITE);
324 324
325 CHECK(!content::ExitedMainMessageLoop()); 325 CHECK(!content::ExitedMainMessageLoop());
326 g_all_hosts.Get().AddWithID(this, GetID()); 326 RegisterHost(GetID(), this);
327 g_all_hosts.Get().set_check_on_null_data(true); 327 g_all_hosts.Get().set_check_on_null_data(true);
328 // Initialize |child_process_activity_time_| to a reasonable value. 328 // Initialize |child_process_activity_time_| to a reasonable value.
329 mark_child_process_activity_time(); 329 mark_child_process_activity_time();
330 // Note: When we create the RenderProcessHostImpl, it's technically 330 // Note: When we create the RenderProcessHostImpl, it's technically
331 // backgrounded, because it has no visible listeners. But the process 331 // backgrounded, because it has no visible listeners. But the process
332 // doesn't actually exist yet, so we'll Background it later, after 332 // doesn't actually exist yet, so we'll Background it later, after
333 // creation. 333 // creation.
334 } 334 }
335 335
336 RenderProcessHostImpl::~RenderProcessHostImpl() { 336 RenderProcessHostImpl::~RenderProcessHostImpl() {
337 ChildProcessSecurityPolicy::GetInstance()->Remove(GetID()); 337 ChildProcessSecurityPolicy::GetInstance()->Remove(GetID());
338 338
339 // We may have some unsent messages at this point, but that's OK. 339 // We may have some unsent messages at this point, but that's OK.
340 channel_.reset(); 340 channel_.reset();
341 while (!queued_messages_.empty()) { 341 while (!queued_messages_.empty()) {
342 delete queued_messages_.front(); 342 delete queued_messages_.front();
343 queued_messages_.pop(); 343 queued_messages_.pop();
344 } 344 }
345 345
346 ClearTransportDIBCache(); 346 ClearTransportDIBCache();
347 if (g_all_hosts.Get().Lookup(GetID())) 347 UnregisterHost(GetID());
348 g_all_hosts.Get().Remove(GetID());
349 } 348 }
350 349
351 void RenderProcessHostImpl::EnableSendQueue() { 350 void RenderProcessHostImpl::EnableSendQueue() {
352 is_initialized_ = false; 351 is_initialized_ = false;
353 } 352 }
354 353
355 bool RenderProcessHostImpl::Init(bool is_accessibility_enabled) { 354 bool RenderProcessHostImpl::Init(bool is_accessibility_enabled) {
356 // calling Init() more than once does nothing, this makes it more convenient 355 // calling Init() more than once does nothing, this makes it more convenient
357 // for the view host which may not be sure in some cases 356 // for the view host which may not be sure in some cases
358 if (channel_.get()) 357 if (channel_.get())
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (listeners_.size() == count) 1096 if (listeners_.size() == count)
1098 return FastShutdownIfPossible(); 1097 return FastShutdownIfPossible();
1099 return false; 1098 return false;
1100 } 1099 }
1101 1100
1102 bool RenderProcessHostImpl::FastShutdownStarted() const { 1101 bool RenderProcessHostImpl::FastShutdownStarted() const {
1103 return fast_shutdown_started_; 1102 return fast_shutdown_started_;
1104 } 1103 }
1105 1104
1106 // static 1105 // static
1106 void RenderProcessHostImpl::RegisterHost(int host_id,
1107 content::RenderProcessHost* host) {
1108 g_all_hosts.Get().AddWithID(host, host_id);
1109 }
1110
1111 void RenderProcessHostImpl::UnregisterHost(int host_id) {
1112 if (g_all_hosts.Get().Lookup(host_id))
1113 g_all_hosts.Get().Remove(host_id);
1114 }
1115
1116 // static
1107 bool content::RenderProcessHost::run_renderer_in_process() { 1117 bool content::RenderProcessHost::run_renderer_in_process() {
1108 return g_run_renderer_in_process_; 1118 return g_run_renderer_in_process_;
1109 } 1119 }
1110 1120
1111 void content::RenderProcessHost::set_run_renderer_in_process(bool value) { 1121 void content::RenderProcessHost::set_run_renderer_in_process(bool value) {
1112 g_run_renderer_in_process_ = value; 1122 g_run_renderer_in_process_ = value;
1113 } 1123 }
1114 1124
1115 content::RenderProcessHost::iterator 1125 content::RenderProcessHost::iterator
1116 content::RenderProcessHost::AllHostsIterator() { 1126 content::RenderProcessHost::AllHostsIterator() {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { 1304 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) {
1295 // Only honor the request if appropriate persmissions are granted. 1305 // Only honor the request if appropriate persmissions are granted.
1296 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) 1306 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path))
1297 content::GetContentClient()->browser()->OpenItem(path); 1307 content::GetContentClient()->browser()->OpenItem(path);
1298 } 1308 }
1299 1309
1300 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 1310 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
1301 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> 1311 content::GetContentClient()->browser()->GetMHTMLGenerationManager()->
1302 MHTMLGenerated(job_id, data_size); 1312 MHTMLGenerated(job_id, data_size);
1303 } 1313 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698