Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome_frame/chrome_frame_histograms.cc

Issue 7276037: Remove NPAPI support from Chrome Frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_frame_histograms.h ('k') | chrome_frame/chrome_frame_npapi.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "chrome_frame/chrome_frame_histograms.h"
6
7 #include "base/metrics/histogram.h"
8 #include "base/lazy_instance.h"
9 #include "base/logging.h"
10 #include "base/message_loop.h"
11
12 using base::Histogram;
13 using base::StatisticsRecorder;
14
15 // Initialize histogram statistics gathering system.
16 base::LazyInstance<StatisticsRecorder>
17 g_statistics_recorder_(base::LINKER_INITIALIZED);
18
19 ChromeFrameHistogramSnapshots::ChromeFrameHistogramSnapshots() {
20 // Ensure that an instance of the StatisticsRecorder object is created.
21 g_statistics_recorder_.Get();
22 }
23
24 ChromeFrameHistogramSnapshots::HistogramPickledList
25 ChromeFrameHistogramSnapshots::GatherAllHistograms() {
26
27 base::AutoLock auto_lock(lock_);
28
29 StatisticsRecorder::Histograms histograms;
30 StatisticsRecorder::GetHistograms(&histograms);
31
32 HistogramPickledList pickled_histograms;
33
34 for (StatisticsRecorder::Histograms::iterator it = histograms.begin();
35 histograms.end() != it;
36 it++) {
37 (*it)->SetFlags(Histogram::kIPCSerializationSourceFlag);
38 GatherHistogram(**it, &pickled_histograms);
39 }
40
41 return pickled_histograms;
42 }
43
44 void ChromeFrameHistogramSnapshots::GatherHistogram(
45 const Histogram& histogram,
46 HistogramPickledList* pickled_histograms) {
47
48 // Get up-to-date snapshot of sample stats.
49 Histogram::SampleSet snapshot;
50 histogram.SnapshotSample(&snapshot);
51 const std::string& histogram_name = histogram.histogram_name();
52
53 // Check if we already have a log of this histogram and if not create an
54 // empty set.
55 LoggedSampleMap::iterator it = logged_samples_.find(histogram_name);
56 Histogram::SampleSet* already_logged;
57 if (logged_samples_.end() == it) {
58 // Add new entry.
59 already_logged = &logged_samples_[histogram.histogram_name()];
60 already_logged->Resize(histogram); // Complete initialization.
61 } else {
62 already_logged = &(it->second);
63 // Deduct any stats we've already logged from our snapshot.
64 snapshot.Subtract(*already_logged);
65 }
66
67 // Snapshot now contains only a delta to what we've already_logged.
68 if (snapshot.TotalCount() > 0) {
69 GatherHistogramDelta(histogram, snapshot, pickled_histograms);
70 // Add new data into our running total.
71 already_logged->Add(snapshot);
72 }
73 }
74
75 void ChromeFrameHistogramSnapshots::GatherHistogramDelta(
76 const Histogram& histogram,
77 const Histogram::SampleSet& snapshot,
78 HistogramPickledList* pickled_histograms) {
79
80 DCHECK(0 != snapshot.TotalCount());
81 snapshot.CheckSize(histogram);
82
83 std::string histogram_info =
84 Histogram::SerializeHistogramInfo(histogram, snapshot);
85 pickled_histograms->push_back(histogram_info);
86 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_histograms.h ('k') | chrome_frame/chrome_frame_npapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698