Chromium Code Reviews| 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..3ad25c6d321fe99a07a3e38ce5d88e7cebb6401b 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,30 @@ 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) { |
|
Alexei Svitkine (slow)
2016/03/31 22:00:58
Nit: No {}'s
bcwhite
2016/03/31 23:53:47
Done.
|
| + global_allocator->CreateTrackingHistograms(global_allocator->Name()); |
| + } |
| +} |
| + |
| void ChildHistogramMessageFilter::SendHistograms(int sequence_number) { |
| io_task_runner_->PostTask( |
| FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistograms, |