| 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 011104d99fc99bac4b3e86e9c48c70729a0b81cb..c6c9d15c2d347473b7ce53a993fb7e7028706fdd 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"
|
| @@ -1119,6 +1123,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_;
|
| @@ -2359,6 +2368,31 @@ 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;
|
| +
|
| + // Get handle to the renderer process. Stop if there is none.
|
| + base::ProcessHandle destination = GetHandle();
|
| + if (destination == base::kNullProcessHandle)
|
| + 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), GetID(), "RendererMetrics", /*readonly=*/false));
|
| +
|
| + base::SharedMemoryHandle shm_handle;
|
| + metrics_allocator_->shared_memory()->ShareToProcess(destination, &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.
|
| @@ -2561,6 +2595,9 @@ void RenderProcessHostImpl::OnProcessLaunched() {
|
| #if defined(OS_ANDROID)
|
| UpdateProcessPriority();
|
| #endif
|
| +
|
| + // Share histograms between the renderer and this process.
|
| + CreateSharedRendererHistogramAllocator();
|
| }
|
|
|
| // NOTE: This needs to be before sending queued messages because
|
|
|