Chromium Code Reviews| Index: content/browser/renderer_host/render_process_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
| index 5ba612b18bf6b304bfbd7ac8088b7694a5514d5e..7facd9f1c637fea4d50d0c67039a3ad387c71b69 100644 |
| --- a/content/browser/renderer_host/render_process_host_impl.cc |
| +++ b/content/browser/renderer_host/render_process_host_impl.cc |
| @@ -24,8 +24,12 @@ |
| #include "base/location.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| +#include "base/memory/shared_memory.h" |
| +#include "base/memory/shared_memory_handle.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/metrics/persistent_histogram_allocator.h" |
| +#include "base/metrics/persistent_memory_allocator.h" |
| #include "base/process/process_handle.h" |
| #include "base/rand_util.h" |
| #include "base/single_thread_task_runner.h" |
| @@ -1121,6 +1125,11 @@ ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { |
| return mojo_application_host_->service_registry(); |
| } |
| +scoped_ptr<base::SharedPersistentMemoryAllocator> |
| +RenderProcessHostImpl::TakeMetricsAllocator() { |
| + return std::move(metrics_allocator_); |
| +} |
| + |
| const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics() |
| const { |
| return init_time_; |
| @@ -2360,6 +2369,28 @@ void RenderProcessHostImpl::RegisterProcessHostForSite( |
| map->RegisterProcess(site, process); |
| } |
| +void RenderProcessHostImpl::CreateSharedRendererHistogramAllocator() { |
| + DCHECK(!metrics_allocator_); |
| + |
| + // Create a persistent memory segment for renderer histograms only if |
| + // they're active in the browser. |
| + if (!base::GlobalHistogramAllocator::Get()) |
| + return; |
| + |
| + // TODO(bcwhite): Update this with the correct memory size. |
| + scoped_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| + shm->CreateAndMapAnonymous(2 << 20); // 2 MiB |
| + metrics_allocator_.reset(new base::SharedPersistentMemoryAllocator( |
| + std::move(shm), child_process_launcher_->GetProcess().Pid(), |
|
Will Harris
2016/04/07 00:29:41
use RenderProcessHostImpl::GetHandle here
also, d
bcwhite
2016/04/07 01:15:55
It looks like GetId() is a better choice; I just n
|
| + "RendererMetrics", /*readonly=*/false)); |
| + |
| + base::SharedMemoryHandle shm_handle; |
| + metrics_allocator_->shared_memory()->ShareToProcess( |
| + child_process_launcher_->GetProcess().Handle(), &shm_handle); |
| + Send(new ChildProcessMsg_SetHistogramMemory( |
| + shm_handle, metrics_allocator_->shared_memory()->mapped_size())); |
| +} |
| + |
| void RenderProcessHostImpl::ProcessDied(bool already_dead, |
| RendererClosedDetails* known_details) { |
| // Our child process has died. If we didn't expect it, it's a crash. |
| @@ -2565,6 +2596,9 @@ void RenderProcessHostImpl::OnProcessLaunched() { |
| #else |
| UpdateProcessPriority(); |
| #endif |
| + |
| + // Share histograms between the renderer and this process. |
| + CreateSharedRendererHistogramAllocator(); |
| } |
| // NOTE: This needs to be before sending queued messages because |