| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_FRAME_HISTOGRAM_SNAPSHOTS_H_ | |
| 6 #define CHROME_FRAME_HISTOGRAM_SNAPSHOTS_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/metrics/histogram.h" | |
| 15 #include "base/process.h" | |
| 16 #include "base/synchronization/lock.h" | |
| 17 #include "base/task.h" | |
| 18 | |
| 19 // This class gathers histogram data in the host browser process and | |
| 20 // serializes the data into a vector of strings to be uploaded to the | |
| 21 // Chrome browser process. It records the histogram data which has been | |
| 22 // logged and only uploads the delta with the next log. | |
| 23 // TODO(iyengar) | |
| 24 // This class does not contain any ChromeFrame specific stuff. It should | |
| 25 // be moved to base. | |
| 26 class ChromeFrameHistogramSnapshots { | |
| 27 public: | |
| 28 // Maintain a map of histogram names to the sample stats we've sent. | |
| 29 typedef std::map<std::string, base::Histogram::SampleSet> LoggedSampleMap; | |
| 30 typedef std::vector<std::string> HistogramPickledList; | |
| 31 | |
| 32 ChromeFrameHistogramSnapshots(); | |
| 33 ~ChromeFrameHistogramSnapshots() {} | |
| 34 | |
| 35 // Extract snapshot data and return it to be sent off to the Chrome browser | |
| 36 // process. | |
| 37 // Return only a delta to what we have already sent. | |
| 38 HistogramPickledList GatherAllHistograms(); | |
| 39 | |
| 40 private: | |
| 41 void GatherHistogram(const base::Histogram& histogram, | |
| 42 HistogramPickledList* histograms); | |
| 43 | |
| 44 void GatherHistogramDelta(const base::Histogram& histogram, | |
| 45 const base::Histogram::SampleSet& snapshot, | |
| 46 HistogramPickledList* histograms); | |
| 47 | |
| 48 // For histograms, record what we've already logged (as a sample for each | |
| 49 // histogram) so that we can send only the delta with the next log. | |
| 50 LoggedSampleMap logged_samples_; | |
| 51 | |
| 52 // Synchronizes the histogram gathering operation. | |
| 53 base::Lock lock_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(ChromeFrameHistogramSnapshots); | |
| 56 }; | |
| 57 | |
| 58 #endif // CHROME_RENDERER_HISTOGRAM_SNAPSHOTS_H_ | |
| OLD | NEW |