OLD | NEW |
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 // 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 is_initialized_(false), | 389 is_initialized_(false), |
390 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 390 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
391 browser_context_(browser_context), | 391 browser_context_(browser_context), |
392 storage_partition_impl_(storage_partition_impl), | 392 storage_partition_impl_(storage_partition_impl), |
393 sudden_termination_allowed_(true), | 393 sudden_termination_allowed_(true), |
394 ignore_input_events_(false), | 394 ignore_input_events_(false), |
395 #if defined(OS_ANDROID) | 395 #if defined(OS_ANDROID) |
396 dummy_shutdown_event_(false, false), | 396 dummy_shutdown_event_(false, false), |
397 #endif | 397 #endif |
398 supports_browser_plugin_(supports_browser_plugin), | 398 supports_browser_plugin_(supports_browser_plugin), |
399 is_guest_(is_guest) { | 399 is_guest_(is_guest), |
| 400 gpu_switch_callback_(base::Bind(&RenderProcessHostImpl::OnGpuSwitch, |
| 401 base::Unretained(this))) { |
400 widget_helper_ = new RenderWidgetHelper(); | 402 widget_helper_ = new RenderWidgetHelper(); |
401 | 403 |
402 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 404 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
403 | 405 |
404 CHECK(!g_exited_main_message_loop); | 406 CHECK(!g_exited_main_message_loop); |
405 RegisterHost(GetID(), this); | 407 RegisterHost(GetID(), this); |
406 g_all_hosts.Get().set_check_on_null_data(true); | 408 g_all_hosts.Get().set_check_on_null_data(true); |
407 // Initialize |child_process_activity_time_| to a reasonable value. | 409 // Initialize |child_process_activity_time_| to a reasonable value. |
408 mark_child_process_activity_time(); | 410 mark_child_process_activity_time(); |
409 | 411 |
410 if (!GetBrowserContext()->IsOffTheRecord() && | 412 if (!GetBrowserContext()->IsOffTheRecord() && |
411 !CommandLine::ForCurrentProcess()->HasSwitch( | 413 !CommandLine::ForCurrentProcess()->HasSwitch( |
412 switches::kDisableGpuShaderDiskCache)) { | 414 switches::kDisableGpuShaderDiskCache)) { |
413 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 415 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
414 base::Bind(&CacheShaderInfo, GetID(), | 416 base::Bind(&CacheShaderInfo, GetID(), |
415 storage_partition_impl_->GetPath())); | 417 storage_partition_impl_->GetPath())); |
416 } | 418 } |
417 | 419 |
418 // Note: When we create the RenderProcessHostImpl, it's technically | 420 // Note: When we create the RenderProcessHostImpl, it's technically |
419 // backgrounded, because it has no visible listeners. But the process | 421 // backgrounded, because it has no visible listeners. But the process |
420 // doesn't actually exist yet, so we'll Background it later, after | 422 // doesn't actually exist yet, so we'll Background it later, after |
421 // creation. | 423 // creation. |
422 } | 424 } |
423 | 425 |
424 RenderProcessHostImpl::~RenderProcessHostImpl() { | 426 RenderProcessHostImpl::~RenderProcessHostImpl() { |
425 DCHECK(!run_renderer_in_process()); | 427 DCHECK(!run_renderer_in_process()); |
426 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); | 428 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); |
| 429 GpuDataManagerImpl::GetInstance()->RemoveGpuSwitchCallback( |
| 430 gpu_switch_callback_); |
427 | 431 |
428 // We may have some unsent messages at this point, but that's OK. | 432 // We may have some unsent messages at this point, but that's OK. |
429 channel_.reset(); | 433 channel_.reset(); |
430 while (!queued_messages_.empty()) { | 434 while (!queued_messages_.empty()) { |
431 delete queued_messages_.front(); | 435 delete queued_messages_.front(); |
432 queued_messages_.pop(); | 436 queued_messages_.pop(); |
433 } | 437 } |
434 | 438 |
435 ClearTransportDIBCache(); | 439 ClearTransportDIBCache(); |
436 UnregisterHost(GetID()); | 440 UnregisterHost(GetID()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 base::EnvironmentVector(), | 541 base::EnvironmentVector(), |
538 channel_->TakeClientFileDescriptor(), | 542 channel_->TakeClientFileDescriptor(), |
539 #endif | 543 #endif |
540 cmd_line, | 544 cmd_line, |
541 GetID(), | 545 GetID(), |
542 this)); | 546 this)); |
543 | 547 |
544 fast_shutdown_started_ = false; | 548 fast_shutdown_started_ = false; |
545 } | 549 } |
546 | 550 |
| 551 GpuDataManagerImpl::GetInstance()->AddGpuSwitchCallback(gpu_switch_callback_); |
| 552 |
547 is_initialized_ = true; | 553 is_initialized_ = true; |
548 return true; | 554 return true; |
549 } | 555 } |
550 | 556 |
551 void RenderProcessHostImpl::CreateMessageFilters() { | 557 void RenderProcessHostImpl::CreateMessageFilters() { |
552 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
553 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); | 559 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); |
554 MediaInternals* media_internals = MediaInternals::GetInstance();; | 560 MediaInternals* media_internals = MediaInternals::GetInstance();; |
555 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages | 561 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages |
556 // from guests. | 562 // from guests. |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 int32 gpu_process_host_id) { | 1747 int32 gpu_process_host_id) { |
1742 TRACE_EVENT0("renderer_host", | 1748 TRACE_EVENT0("renderer_host", |
1743 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1749 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
1744 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1750 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
1745 ack_params.sync_point = 0; | 1751 ack_params.sync_point = 0; |
1746 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1752 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
1747 gpu_process_host_id, | 1753 gpu_process_host_id, |
1748 ack_params); | 1754 ack_params); |
1749 } | 1755 } |
1750 | 1756 |
| 1757 void RenderProcessHostImpl::OnGpuSwitch() { |
| 1758 for (RenderWidgetHostsIterator iter = GetRenderWidgetHostsIterator(); |
| 1759 !iter.IsAtEnd(); |
| 1760 iter.Advance()) { |
| 1761 const RenderWidgetHost* widget = iter.GetCurrentValue(); |
| 1762 DCHECK(widget); |
| 1763 if (!widget || !widget->IsRenderView()) |
| 1764 continue; |
| 1765 |
| 1766 RenderViewHost* rvh = |
| 1767 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
| 1768 |
| 1769 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
| 1770 } |
| 1771 } |
| 1772 |
1751 } // namespace content | 1773 } // namespace content |
OLD | NEW |