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