OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | 5 #ifndef CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ |
6 #define CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | 6 #define CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | |
10 #include <map> | 9 #include <map> |
11 #include <set> | |
12 #include <string> | 10 #include <string> |
13 #include <vector> | 11 #include <vector> |
14 | 12 |
15 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
16 #include "base/histogram.h" | 14 #include "base/histogram.h" |
17 #include "base/process.h" | 15 #include "base/process.h" |
18 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
19 #include "base/task.h" | 17 #include "base/task.h" |
20 | 18 |
21 class RendererHistogramSnapshots { | 19 class RendererHistogramSnapshots { |
22 public: | 20 public: |
23 RendererHistogramSnapshots(); | 21 RendererHistogramSnapshots(); |
24 | 22 ~RendererHistogramSnapshots(); |
25 ~RendererHistogramSnapshots() {} | |
26 | 23 |
27 // Send the histogram data. | 24 // Send the histogram data. |
28 void SendHistograms(int sequence_number); | 25 void SendHistograms(int sequence_number); |
29 | 26 |
30 // Maintain a map of histogram names to the sample stats we've sent. | 27 // Maintain a map of histogram names to the sample stats we've sent. |
31 typedef std::map<std::string, Histogram::SampleSet> LoggedSampleMap; | 28 typedef std::map<std::string, Histogram::SampleSet> LoggedSampleMap; |
32 typedef std::vector<std::string> HistogramPickledList; | 29 typedef std::vector<std::string> HistogramPickledList; |
33 | 30 |
34 private: | 31 private: |
35 // Extract snapshot data and then send it off the the Browser process. | 32 // Extract snapshot data and then send it off the the Browser process. |
36 // Send only a delta to what we have already sent. | 33 // Send only a delta to what we have already sent. |
37 void UploadAllHistrograms(int sequence_number); | 34 void UploadAllHistrograms(int sequence_number); |
38 void UploadHistrogram(const Histogram& histogram, | 35 void UploadHistrogram(const Histogram& histogram, |
39 HistogramPickledList* histograms); | 36 HistogramPickledList* histograms); |
40 void UploadHistogramDelta(const Histogram& histogram, | 37 void UploadHistogramDelta(const Histogram& histogram, |
41 const Histogram::SampleSet& snapshot, | 38 const Histogram::SampleSet& snapshot, |
42 HistogramPickledList* histograms); | 39 HistogramPickledList* histograms); |
43 | 40 |
44 ScopedRunnableMethodFactory<RendererHistogramSnapshots> | 41 ScopedRunnableMethodFactory<RendererHistogramSnapshots> |
45 renderer_histogram_snapshots_factory_; | 42 renderer_histogram_snapshots_factory_; |
46 | 43 |
47 // For histograms, record what we've already logged (as a sample for each | 44 // For histograms, record what we've already logged (as a sample for each |
48 // histogram) so that we can send only the delta with the next log. | 45 // histogram) so that we can send only the delta with the next log. |
49 LoggedSampleMap logged_samples_; | 46 LoggedSampleMap logged_samples_; |
50 | 47 |
51 DISALLOW_COPY_AND_ASSIGN(RendererHistogramSnapshots); | 48 DISALLOW_COPY_AND_ASSIGN(RendererHistogramSnapshots); |
52 }; | 49 }; |
53 | 50 |
54 #endif // CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | 51 #endif // CHROME_RENDERER_RENDERER_HISTOGRAM_SNAPSHOTS_H_ |
OLD | NEW |