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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 is_initialized_(false), | 393 is_initialized_(false), |
394 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 394 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
395 browser_context_(browser_context), | 395 browser_context_(browser_context), |
396 storage_partition_impl_(storage_partition_impl), | 396 storage_partition_impl_(storage_partition_impl), |
397 sudden_termination_allowed_(true), | 397 sudden_termination_allowed_(true), |
398 ignore_input_events_(false), | 398 ignore_input_events_(false), |
399 #if defined(OS_ANDROID) | 399 #if defined(OS_ANDROID) |
400 dummy_shutdown_event_(false, false), | 400 dummy_shutdown_event_(false, false), |
401 #endif | 401 #endif |
402 supports_browser_plugin_(supports_browser_plugin), | 402 supports_browser_plugin_(supports_browser_plugin), |
403 is_guest_(is_guest) { | 403 is_guest_(is_guest), |
| 404 gpu_observer_registered_(false) { |
404 widget_helper_ = new RenderWidgetHelper(); | 405 widget_helper_ = new RenderWidgetHelper(); |
405 | 406 |
406 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 407 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
407 | 408 |
408 CHECK(!g_exited_main_message_loop); | 409 CHECK(!g_exited_main_message_loop); |
409 RegisterHost(GetID(), this); | 410 RegisterHost(GetID(), this); |
410 g_all_hosts.Get().set_check_on_null_data(true); | 411 g_all_hosts.Get().set_check_on_null_data(true); |
411 // Initialize |child_process_activity_time_| to a reasonable value. | 412 // Initialize |child_process_activity_time_| to a reasonable value. |
412 mark_child_process_activity_time(); | 413 mark_child_process_activity_time(); |
413 | 414 |
414 if (!GetBrowserContext()->IsOffTheRecord() && | 415 if (!GetBrowserContext()->IsOffTheRecord() && |
415 !CommandLine::ForCurrentProcess()->HasSwitch( | 416 !CommandLine::ForCurrentProcess()->HasSwitch( |
416 switches::kDisableGpuShaderDiskCache)) { | 417 switches::kDisableGpuShaderDiskCache)) { |
417 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 418 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
418 base::Bind(&CacheShaderInfo, GetID(), | 419 base::Bind(&CacheShaderInfo, GetID(), |
419 storage_partition_impl_->GetPath())); | 420 storage_partition_impl_->GetPath())); |
420 } | 421 } |
421 | 422 |
422 // Note: When we create the RenderProcessHostImpl, it's technically | 423 // Note: When we create the RenderProcessHostImpl, it's technically |
423 // backgrounded, because it has no visible listeners. But the process | 424 // backgrounded, because it has no visible listeners. But the process |
424 // doesn't actually exist yet, so we'll Background it later, after | 425 // doesn't actually exist yet, so we'll Background it later, after |
425 // creation. | 426 // creation. |
426 } | 427 } |
427 | 428 |
428 RenderProcessHostImpl::~RenderProcessHostImpl() { | 429 RenderProcessHostImpl::~RenderProcessHostImpl() { |
429 DCHECK(!run_renderer_in_process()); | 430 DCHECK(!run_renderer_in_process()); |
430 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); | 431 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); |
431 | 432 |
| 433 if (gpu_observer_registered_) { |
| 434 GpuDataManagerImpl::GetInstance()->RemoveObserver(this); |
| 435 gpu_observer_registered_ = false; |
| 436 } |
| 437 |
432 // We may have some unsent messages at this point, but that's OK. | 438 // We may have some unsent messages at this point, but that's OK. |
433 channel_.reset(); | 439 channel_.reset(); |
434 while (!queued_messages_.empty()) { | 440 while (!queued_messages_.empty()) { |
435 delete queued_messages_.front(); | 441 delete queued_messages_.front(); |
436 queued_messages_.pop(); | 442 queued_messages_.pop(); |
437 } | 443 } |
438 | 444 |
439 ClearTransportDIBCache(); | 445 ClearTransportDIBCache(); |
440 UnregisterHost(GetID()); | 446 UnregisterHost(GetID()); |
441 | 447 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 base::EnvironmentVector(), | 551 base::EnvironmentVector(), |
546 channel_->TakeClientFileDescriptor(), | 552 channel_->TakeClientFileDescriptor(), |
547 #endif | 553 #endif |
548 cmd_line, | 554 cmd_line, |
549 GetID(), | 555 GetID(), |
550 this)); | 556 this)); |
551 | 557 |
552 fast_shutdown_started_ = false; | 558 fast_shutdown_started_ = false; |
553 } | 559 } |
554 | 560 |
| 561 if (!gpu_observer_registered_) { |
| 562 gpu_observer_registered_ = true; |
| 563 GpuDataManagerImpl::GetInstance()->AddObserver(this); |
| 564 } |
| 565 |
555 is_initialized_ = true; | 566 is_initialized_ = true; |
556 return true; | 567 return true; |
557 } | 568 } |
558 | 569 |
559 void RenderProcessHostImpl::CreateMessageFilters() { | 570 void RenderProcessHostImpl::CreateMessageFilters() { |
560 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
561 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); | 572 channel_->AddFilter(new ResourceSchedulerFilter(GetID())); |
562 MediaInternals* media_internals = MediaInternals::GetInstance();; | 573 MediaInternals* media_internals = MediaInternals::GetInstance();; |
563 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages | 574 // Add BrowserPluginMessageFilter to ensure it gets the first stab at messages |
564 // from guests. | 575 // from guests. |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { | 1777 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { |
1767 TRACE_EVENT0("renderer_host", | 1778 TRACE_EVENT0("renderer_host", |
1768 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1779 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
1769 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1780 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
1770 ack_params.sync_point = 0; | 1781 ack_params.sync_point = 0; |
1771 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, | 1782 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, |
1772 params.gpu_process_host_id, | 1783 params.gpu_process_host_id, |
1773 ack_params); | 1784 ack_params); |
1774 } | 1785 } |
1775 | 1786 |
| 1787 void RenderProcessHostImpl::OnGpuSwitching() { |
| 1788 for (RenderWidgetHostsIterator iter = GetRenderWidgetHostsIterator(); |
| 1789 !iter.IsAtEnd(); |
| 1790 iter.Advance()) { |
| 1791 const RenderWidgetHost* widget = iter.GetCurrentValue(); |
| 1792 DCHECK(widget); |
| 1793 if (!widget || !widget->IsRenderView()) |
| 1794 continue; |
| 1795 |
| 1796 RenderViewHost* rvh = |
| 1797 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
| 1798 |
| 1799 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
| 1800 } |
| 1801 } |
| 1802 |
1776 } // namespace content | 1803 } // namespace content |
OLD | NEW |