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

Side by Side Diff: content/child/child_histogram_message_filter.cc

Issue 1875503003: Revert "Create and pass shared-histogram-allocator from browser to renderer." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/child/child_histogram_message_filter.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/child_histogram_message_filter.h" 5 #include "content/child/child_histogram_message_filter.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/metrics/histogram_delta_serialization.h" 11 #include "base/metrics/histogram_delta_serialization.h"
12 #include "base/metrics/persistent_histogram_allocator.h"
13 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
14 #include "content/child/child_process.h" 13 #include "content/child/child_process.h"
15 #include "content/common/child_process_messages.h" 14 #include "content/common/child_process_messages.h"
16 #include "ipc/ipc_sender.h" 15 #include "ipc/ipc_sender.h"
17 16
18 namespace content { 17 namespace content {
19 18
20 ChildHistogramMessageFilter::ChildHistogramMessageFilter() 19 ChildHistogramMessageFilter::ChildHistogramMessageFilter()
21 : sender_(NULL), 20 : sender_(NULL),
22 io_task_runner_(ChildProcess::current()->io_task_runner()) { 21 io_task_runner_(ChildProcess::current()->io_task_runner()) {
23 } 22 }
24 23
25 ChildHistogramMessageFilter::~ChildHistogramMessageFilter() { 24 ChildHistogramMessageFilter::~ChildHistogramMessageFilter() {
26 } 25 }
27 26
28 void ChildHistogramMessageFilter::OnFilterAdded(IPC::Sender* sender) { 27 void ChildHistogramMessageFilter::OnFilterAdded(IPC::Sender* sender) {
29 sender_ = sender; 28 sender_ = sender;
30 } 29 }
31 30
32 void ChildHistogramMessageFilter::OnFilterRemoved() { 31 void ChildHistogramMessageFilter::OnFilterRemoved() {
33 } 32 }
34 33
35 bool ChildHistogramMessageFilter::OnMessageReceived( 34 bool ChildHistogramMessageFilter::OnMessageReceived(
36 const IPC::Message& message) { 35 const IPC::Message& message) {
37 bool handled = true; 36 bool handled = true;
38 IPC_BEGIN_MESSAGE_MAP(ChildHistogramMessageFilter, message) 37 IPC_BEGIN_MESSAGE_MAP(ChildHistogramMessageFilter, message)
39 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetHistogramMemory, 38 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildHistogramData,
40 OnSetHistogramMemory)
41 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildNonPersistentHistogramData,
42 OnGetChildHistogramData) 39 OnGetChildHistogramData)
43 IPC_MESSAGE_UNHANDLED(handled = false) 40 IPC_MESSAGE_UNHANDLED(handled = false)
44 IPC_END_MESSAGE_MAP() 41 IPC_END_MESSAGE_MAP()
45 return handled; 42 return handled;
46 } 43 }
47 44
48 void ChildHistogramMessageFilter::OnSetHistogramMemory(
49 const base::SharedMemoryHandle& memory_handle,
50 int memory_size) {
51 // This message must be received only once. Multiple calls to create a global
52 // allocator will cause a CHECK() failure.
53 base::GlobalHistogramAllocator::CreateWithSharedMemoryHandle(memory_handle,
54 memory_size);
55
56 base::PersistentHistogramAllocator* global_allocator =
57 base::GlobalHistogramAllocator::Get();
58 if (global_allocator)
59 global_allocator->CreateTrackingHistograms(global_allocator->Name());
60 }
61
62 void ChildHistogramMessageFilter::SendHistograms(int sequence_number) { 45 void ChildHistogramMessageFilter::SendHistograms(int sequence_number) {
63 io_task_runner_->PostTask( 46 io_task_runner_->PostTask(
64 FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistograms, 47 FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistograms,
65 this, sequence_number)); 48 this, sequence_number));
66 } 49 }
67 50
68 void ChildHistogramMessageFilter::OnGetChildHistogramData(int sequence_number) { 51 void ChildHistogramMessageFilter::OnGetChildHistogramData(int sequence_number) {
69 UploadAllHistograms(sequence_number); 52 UploadAllHistograms(sequence_number);
70 } 53 }
71 54
(...skipping 12 matching lines...) Expand all
84 new ChildProcessHostMsg_ChildHistogramData(sequence_number, deltas)); 67 new ChildProcessHostMsg_ChildHistogramData(sequence_number, deltas));
85 68
86 #ifndef NDEBUG 69 #ifndef NDEBUG
87 static int count = 0; 70 static int count = 0;
88 count++; 71 count++;
89 LOCAL_HISTOGRAM_COUNTS("Histogram.ChildProcessHistogramSentCount", count); 72 LOCAL_HISTOGRAM_COUNTS("Histogram.ChildProcessHistogramSentCount", count);
90 #endif 73 #endif
91 } 74 }
92 75
93 } // namespace content 76 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_histogram_message_filter.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698