OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | |
6 #define CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/basictypes.h" | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "base/metrics/histogram.h" | |
16 #include "base/process.h" | |
17 #include "chrome/common/metrics/histogram_sender.h" | |
18 #include "content/public/renderer/render_process_observer.h" | |
19 | |
20 class RendererHistogramSnapshots : public HistogramSender, | |
21 public content::RenderProcessObserver { | |
22 public: | |
23 RendererHistogramSnapshots(); | |
24 virtual ~RendererHistogramSnapshots(); | |
25 | |
26 // Send the histogram data. | |
27 void SendHistograms(int sequence_number); | |
28 | |
29 private: | |
30 // RenderProcessObserver implementation. | |
31 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | |
32 | |
33 void OnGetRendererHistograms(int sequence_number); | |
34 | |
35 // Maintain a map of histogram names to the sample stats we've sent. | |
36 typedef std::map<std::string, base::Histogram::SampleSet> LoggedSampleMap; | |
37 typedef std::vector<std::string> HistogramPickledList; | |
38 | |
39 // Extract snapshot data and then send it off the the Browser process. | |
40 // Send only a delta to what we have already sent. | |
41 void UploadAllHistrograms(int sequence_number); | |
42 | |
43 base::WeakPtrFactory<RendererHistogramSnapshots> weak_factory_; | |
44 | |
45 // HistogramSender interface (override) methods. | |
46 virtual void TransmitHistogramDelta( | |
47 const base::Histogram& histogram, | |
48 const base::Histogram::SampleSet& snapshot) OVERRIDE; | |
49 virtual void InconsistencyDetected(int problem) OVERRIDE; | |
50 virtual void UniqueInconsistencyDetected(int problem) OVERRIDE; | |
51 virtual void SnapshotProblemResolved(int amount) OVERRIDE; | |
52 | |
53 // Collection of histograms to send to the browser. | |
54 HistogramPickledList pickled_histograms_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(RendererHistogramSnapshots); | |
57 }; | |
58 | |
59 #endif // CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | |
OLD | NEW |