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 e52c35499c165848a4fa11cd452f95dcfebe57a9..ed13ae8f9d37eb8958455bf600fd7fc59b9c3af3 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" |
@@ -1134,6 +1138,11 @@ ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { |
return mojo_application_host_->service_registry(); |
} |
+scoped_ptr<base::SharedPersistentMemoryAllocator> |
+RenderProcessHostImpl::ExtractMetricsAllocator() { |
+ return std::move(metrics_allocator_); |
+} |
+ |
const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics() |
const { |
return init_time_; |
@@ -2589,6 +2598,26 @@ void RenderProcessHostImpl::OnProcessLaunched() { |
#else |
UpdateProcessPriority(); |
#endif |
+ |
+ // Create a persistent memory segment for renderer histograms only if |
Alexei Svitkine (slow)
2016/03/29 17:51:24
Please make a separate function for this block to
bcwhite
2016/03/30 21:25:55
Done.
|
+ // they're active in the browser. |
+ if (base::PersistentHistogramAllocator::GetGlobalAllocator()) { |
+ DCHECK(!metrics_allocator_); |
+ // 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(), |
+ "RendererMetrics", /*readonly=*/false)); |
+ |
+ if (metrics_allocator_) { |
+ 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())); |
+ } |
+ } |
} |
// NOTE: This needs to be before sending queued messages because |