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

Unified Diff: content/child/child_histogram_message_filter.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: addressed review comments by Alexei; fixed test on some builds Created 4 years, 9 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/child/child_histogram_message_filter.cc
diff --git a/content/child/child_histogram_message_filter.cc b/content/child/child_histogram_message_filter.cc
index f749cf812fb571c502af103b8068c53b71aeb271..876ebd38cc97d458fe2c2f520a06bee6f6449d73 100644
--- a/content/child/child_histogram_message_filter.cc
+++ b/content/child/child_histogram_message_filter.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_delta_serialization.h"
+#include "base/metrics/persistent_histogram_allocator.h"
#include "base/single_thread_task_runner.h"
#include "content/child/child_process.h"
#include "content/common/child_process_messages.h"
@@ -35,13 +36,29 @@ bool ChildHistogramMessageFilter::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ChildHistogramMessageFilter, message)
- IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildHistogramData,
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_SetHistogramMemory,
+ OnSetHistogramMemory)
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildNonPersistentHistogramData,
OnGetChildHistogramData)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
+void ChildHistogramMessageFilter::OnSetHistogramMemory(
+ const base::SharedMemoryHandle& memory_handle,
+ int memory_size) {
+ // This message must be received only once. Multiple calls to create a global
+ // allocator will cause a CHECK() failure.
+ base::PersistentHistogramAllocator::CreateGlobalAllocatorOnSharedMemoryHandle(
+ memory_handle, memory_size);
+
+ base::PersistentHistogramAllocator* global_allocator =
+ base::PersistentHistogramAllocator::GetGlobalAllocator();
+ if (global_allocator)
+ global_allocator->CreateTrackingHistograms(global_allocator->Name());
+}
+
void ChildHistogramMessageFilter::SendHistograms(int sequence_number) {
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistograms,

Powered by Google App Engine
This is Rietveld 408576698