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..9effd8d4d4554aa21c84fbb6b54a723031215b7a 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/histogram_persistence.h" |
#include "base/single_thread_task_runner.h" |
#include "content/child/child_process.h" |
#include "content/common/child_process_messages.h" |
@@ -35,6 +36,8 @@ bool ChildHistogramMessageFilter::OnMessageReceived( |
const IPC::Message& message) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(ChildHistogramMessageFilter, message) |
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_SetHistogramMemory, |
+ OnSetHistogramMemory) |
IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildHistogramData, |
OnGetChildHistogramData) |
IPC_MESSAGE_UNHANDLED(handled = false) |
@@ -42,6 +45,20 @@ bool ChildHistogramMessageFilter::OnMessageReceived( |
return handled; |
} |
+void ChildHistogramMessageFilter::OnSetHistogramMemory( |
+ const base::SharedMemoryHandle& mem_handle, |
+ int mem_size) { |
+ scoped_ptr<base::PersistentMemoryAllocator> allocator( |
+ base::CreateSharedPersistentHistogramMemoryAllocator( |
+ mem_size, mem_handle, false)); |
+ |
+ if (allocator) { |
+ base::SetPersistentHistogramMemoryAllocator(allocator.release()); |
Alexei Svitkine (slow)
2016/03/24 17:29:53
What happens if there's already an allocator set?
bcwhite
2016/03/29 11:53:27
It dies with a CHECK().
Alexei Svitkine (slow)
2016/03/29 17:51:24
That's fair. Maybe add a comment mentioning that t
bcwhite
2016/03/30 21:25:55
Done.
|
+ base::GetPersistentHistogramMemoryAllocator()->CreateTrackingHistograms( |
+ base::GetPersistentHistogramMemoryAllocator()->Name()); |
+ } |
+} |
+ |
void ChildHistogramMessageFilter::SendHistograms(int sequence_number) { |
io_task_runner_->PostTask( |
FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistograms, |