Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1197)

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1671933002: Create and pass shared-histogram-allocator from browser to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hsm-merge
Patch Set: cleanup on RenderProcessHostDestroyed instead of RenderProcessExited; use existing ScopedObserver c… Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e393673e44ba62ce6ddd97c410b8ba3aa24cb858..13ddefc0604c490bb3981e16a5b4733bfc4b812c 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -26,6 +26,8 @@
#include "base/macros.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/histogram_persistence.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"
@@ -1132,6 +1134,11 @@ ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() {
return mojo_application_host_->service_registry();
}
+scoped_ptr<base::SharedPersistentMemoryAllocator>
+RenderProcessHostImpl::GetMetricsAllocator() {
+ return std::move(metrics_allocator_);
+}
+
const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics()
const {
return init_time_;
@@ -2565,6 +2572,26 @@ void RenderProcessHostImpl::OnProcessLaunched() {
#else
UpdateProcessPriority();
#endif
+
+ // Create a persistent memory segment for renderer histograms only if
+ // they're active in the browser.
+ if (base::GetPersistentHistogramMemoryAllocator()) {
+ DCHECK(!metrics_allocator_);
+ // TODO(bcwhite): Update this with the correct memory size.
+ metrics_allocator_.reset(
+ base::CreateSharedPersistentHistogramMemoryAllocator(
+ 2 << 20, // 2 MiB
+ "RendererMetrics",
+ child_process_launcher_->GetProcess().Pid()));
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698