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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 storage_partition_impl_(storage_partition_impl), | 450 storage_partition_impl_(storage_partition_impl), |
451 sudden_termination_allowed_(true), | 451 sudden_termination_allowed_(true), |
452 ignore_input_events_(false), | 452 ignore_input_events_(false), |
453 is_isolated_guest_(is_isolated_guest), | 453 is_isolated_guest_(is_isolated_guest), |
454 gpu_observer_registered_(false), | 454 gpu_observer_registered_(false), |
455 delayed_cleanup_needed_(false), | 455 delayed_cleanup_needed_(false), |
456 within_process_died_observer_(false), | 456 within_process_died_observer_(false), |
457 power_monitor_broadcaster_(this), | 457 power_monitor_broadcaster_(this), |
458 worker_ref_count_(0), | 458 worker_ref_count_(0), |
459 permission_service_context_(new PermissionServiceContext(this)), | 459 permission_service_context_(new PermissionServiceContext(this)), |
| 460 pending_valuebuffer_state_(new gpu::ValueStateMap()), |
| 461 subscribe_uniform_enabled_(false), |
460 weak_factory_(this) { | 462 weak_factory_(this) { |
461 widget_helper_ = new RenderWidgetHelper(); | 463 widget_helper_ = new RenderWidgetHelper(); |
462 | 464 |
463 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 465 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
464 | 466 |
465 CHECK(!g_exited_main_message_loop); | 467 CHECK(!g_exited_main_message_loop); |
466 RegisterHost(GetID(), this); | 468 RegisterHost(GetID(), this); |
467 g_all_hosts.Get().set_check_on_null_data(true); | 469 g_all_hosts.Get().set_check_on_null_data(true); |
468 // Initialize |child_process_activity_time_| to a reasonable value. | 470 // Initialize |child_process_activity_time_| to a reasonable value. |
469 mark_child_process_activity_time(); | 471 mark_child_process_activity_time(); |
470 | 472 |
471 if (!GetBrowserContext()->IsOffTheRecord() && | 473 if (!GetBrowserContext()->IsOffTheRecord() && |
472 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 474 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
473 switches::kDisableGpuShaderDiskCache)) { | 475 switches::kDisableGpuShaderDiskCache)) { |
474 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 476 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
475 base::Bind(&CacheShaderInfo, GetID(), | 477 base::Bind(&CacheShaderInfo, GetID(), |
476 storage_partition_impl_->GetPath())); | 478 storage_partition_impl_->GetPath())); |
477 } | 479 } |
| 480 subscribe_uniform_enabled_ = |
| 481 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 482 switches::kEnableSubscribeUniformExtension); |
478 | 483 |
479 // Note: When we create the RenderProcessHostImpl, it's technically | 484 // Note: When we create the RenderProcessHostImpl, it's technically |
480 // backgrounded, because it has no visible listeners. But the process | 485 // backgrounded, because it has no visible listeners. But the process |
481 // doesn't actually exist yet, so we'll Background it later, after | 486 // doesn't actually exist yet, so we'll Background it later, after |
482 // creation. | 487 // creation. |
483 } | 488 } |
484 | 489 |
485 // static | 490 // static |
486 void RenderProcessHostImpl::ShutDownInProcessRenderer() { | 491 void RenderProcessHostImpl::ShutDownInProcessRenderer() { |
487 DCHECK(g_run_renderer_in_process_); | 492 DCHECK(g_run_renderer_in_process_); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { | 926 ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { |
922 DCHECK(mojo_application_host_); | 927 DCHECK(mojo_application_host_); |
923 return mojo_application_host_->service_registry(); | 928 return mojo_application_host_->service_registry(); |
924 } | 929 } |
925 | 930 |
926 const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics() | 931 const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics() |
927 const { | 932 const { |
928 return init_time_; | 933 return init_time_; |
929 } | 934 } |
930 | 935 |
| 936 bool RenderProcessHostImpl::SubscribeUniformEnabled() const { |
| 937 return subscribe_uniform_enabled_; |
| 938 } |
| 939 |
| 940 void RenderProcessHostImpl::OnAddSubscription(unsigned int target) { |
| 941 DCHECK(subscribe_uniform_enabled_); |
| 942 subscription_set_.insert(target); |
| 943 const gpu::ValueState* state = pending_valuebuffer_state_->GetState(target); |
| 944 if (state) { |
| 945 SendUpdateValueState(target, *state); |
| 946 } |
| 947 } |
| 948 |
| 949 void RenderProcessHostImpl::OnRemoveSubscription(unsigned int target) { |
| 950 DCHECK(subscribe_uniform_enabled_); |
| 951 subscription_set_.erase(target); |
| 952 } |
| 953 |
| 954 void RenderProcessHostImpl::SendUpdateValueState(unsigned int target, |
| 955 const gpu::ValueState& state) { |
| 956 DCHECK(subscribe_uniform_enabled_); |
| 957 if (subscription_set_.find(target) != subscription_set_.end()) { |
| 958 GpuProcessHost::SendOnIO( |
| 959 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 960 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 961 new GpuMsg_UpdateValueState(id_, target, state)); |
| 962 } else { |
| 963 // Store the ValueState locally in case a Valuebuffer subscribes to it later |
| 964 pending_valuebuffer_state_->UpdateState(target, state); |
| 965 } |
| 966 } |
| 967 |
931 void RenderProcessHostImpl::AddRoute( | 968 void RenderProcessHostImpl::AddRoute( |
932 int32 routing_id, | 969 int32 routing_id, |
933 IPC::Listener* listener) { | 970 IPC::Listener* listener) { |
934 CHECK(!listeners_.Lookup(routing_id)) | 971 CHECK(!listeners_.Lookup(routing_id)) |
935 << "Found Routing ID Conflict: " << routing_id; | 972 << "Found Routing ID Conflict: " << routing_id; |
936 listeners_.AddWithID(listener, routing_id); | 973 listeners_.AddWithID(listener, routing_id); |
937 } | 974 } |
938 | 975 |
939 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { | 976 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { |
940 DCHECK(listeners_.Lookup(routing_id) != NULL); | 977 DCHECK(listeners_.Lookup(routing_id) != NULL); |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 | 2350 |
2314 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2351 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2315 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2352 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2316 DCHECK_GT(worker_ref_count_, 0); | 2353 DCHECK_GT(worker_ref_count_, 0); |
2317 --worker_ref_count_; | 2354 --worker_ref_count_; |
2318 if (worker_ref_count_ == 0) | 2355 if (worker_ref_count_ == 0) |
2319 Cleanup(); | 2356 Cleanup(); |
2320 } | 2357 } |
2321 | 2358 |
2322 } // namespace content | 2359 } // namespace content |
OLD | NEW |