OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/renderer_histogram_snapshots.h" | 5 #include "chrome/renderer/renderer_histogram_snapshots.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
| 9 #include "base/bind.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
13 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
14 | 15 |
15 // TODO(raman): Before renderer shuts down send final snapshot lists. | 16 // TODO(raman): Before renderer shuts down send final snapshot lists. |
16 | 17 |
17 using base::Histogram; | 18 using base::Histogram; |
18 using base::StatisticsRecorder; | 19 using base::StatisticsRecorder; |
19 using content::RenderThread; | 20 using content::RenderThread; |
20 | 21 |
21 RendererHistogramSnapshots::RendererHistogramSnapshots() | 22 RendererHistogramSnapshots::RendererHistogramSnapshots() |
22 : ALLOW_THIS_IN_INITIALIZER_LIST( | 23 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
23 renderer_histogram_snapshots_factory_(this)) { | |
24 } | 24 } |
25 | 25 |
26 RendererHistogramSnapshots::~RendererHistogramSnapshots() { | 26 RendererHistogramSnapshots::~RendererHistogramSnapshots() { |
27 } | 27 } |
28 | 28 |
29 // Send data quickly! | 29 // Send data quickly! |
30 void RendererHistogramSnapshots::SendHistograms(int sequence_number) { | 30 void RendererHistogramSnapshots::SendHistograms(int sequence_number) { |
31 RenderThread::Get()->GetMessageLoop()->PostTask(FROM_HERE, | 31 RenderThread::Get()->GetMessageLoop()->PostTask( |
32 renderer_histogram_snapshots_factory_.NewRunnableMethod( | 32 FROM_HERE, base::Bind(&RendererHistogramSnapshots::UploadAllHistrograms, |
33 &RendererHistogramSnapshots::UploadAllHistrograms, sequence_number)); | 33 weak_factory_.GetWeakPtr(), sequence_number)); |
34 } | 34 } |
35 | 35 |
36 bool RendererHistogramSnapshots::OnControlMessageReceived( | 36 bool RendererHistogramSnapshots::OnControlMessageReceived( |
37 const IPC::Message& message) { | 37 const IPC::Message& message) { |
38 bool handled = true; | 38 bool handled = true; |
39 IPC_BEGIN_MESSAGE_MAP(RendererHistogramSnapshots, message) | 39 IPC_BEGIN_MESSAGE_MAP(RendererHistogramSnapshots, message) |
40 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererHistograms, | 40 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererHistograms, |
41 OnGetRendererHistograms) | 41 OnGetRendererHistograms) |
42 IPC_MESSAGE_UNHANDLED(handled = false) | 42 IPC_MESSAGE_UNHANDLED(handled = false) |
43 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void RendererHistogramSnapshots::UniqueInconsistencyDetected(int problem) { | 83 void RendererHistogramSnapshots::UniqueInconsistencyDetected(int problem) { |
84 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesRendererUnique", | 84 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesRendererUnique", |
85 problem, Histogram::NEVER_EXCEEDED_VALUE); | 85 problem, Histogram::NEVER_EXCEEDED_VALUE); |
86 } | 86 } |
87 | 87 |
88 void RendererHistogramSnapshots::SnapshotProblemResolved(int amount) { | 88 void RendererHistogramSnapshots::SnapshotProblemResolved(int amount) { |
89 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotRenderer", | 89 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotRenderer", |
90 std::abs(amount)); | 90 std::abs(amount)); |
91 } | 91 } |
92 | 92 |
OLD | NEW |