OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/browser/histogram_message_filter.h" | 5 #include "content/browser/histogram_message_filter.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 HistogramController::GetInstance()->OnHistogramDataCollected( | 42 HistogramController::GetInstance()->OnHistogramDataCollected( |
43 sequence_number, pickled_histograms); | 43 sequence_number, pickled_histograms); |
44 } | 44 } |
45 | 45 |
46 void HistogramMessageFilter::OnGetBrowserHistogram( | 46 void HistogramMessageFilter::OnGetBrowserHistogram( |
47 const std::string& name, | 47 const std::string& name, |
48 std::string* histogram_json) { | 48 std::string* histogram_json) { |
49 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 49 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
50 // Security: Only allow access to browser histograms when running in the | 50 // Security: Only allow access to browser histograms when running in the |
51 // context of a test. | 51 // context of a test. |
52 bool using_dom_controller = | 52 bool using_stats_collection_controller = |
53 CommandLine::ForCurrentProcess()->HasSwitch( | 53 CommandLine::ForCurrentProcess()->HasSwitch( |
54 switches::kDomAutomationController); | 54 switches::kStatsCollectionController); |
55 bool reduced_security = | 55 bool reduced_security = |
56 CommandLine::ForCurrentProcess()->HasSwitch( | 56 CommandLine::ForCurrentProcess()->HasSwitch( |
57 switches::kReduceSecurityForDomAutomationTests); | 57 switches::kReduceSecurityForStatsCollectionTests); |
58 | 58 |
59 if (!using_dom_controller || !reduced_security) { | 59 if (!using_stats_collection_controller || !reduced_security) { |
60 LOG(ERROR) << "Attempt at reading browser histogram without specifying " | 60 LOG(ERROR) << "Attempt at reading browser histogram without specifying " |
61 << "--" << switches::kDomAutomationController << " and " | 61 << "--" << switches::kStatsCollectionController << " and " |
62 << "--" << switches::kReduceSecurityForDomAutomationTests | 62 << "--" << switches::kReduceSecurityForStatsCollectionTests |
63 << " switches."; | 63 << " switches."; |
64 return; | 64 return; |
65 } | 65 } |
66 base::HistogramBase* histogram = | 66 base::HistogramBase* histogram = |
67 base::StatisticsRecorder::FindHistogram(name); | 67 base::StatisticsRecorder::FindHistogram(name); |
68 if (!histogram) { | 68 if (!histogram) { |
69 *histogram_json = "{}"; | 69 *histogram_json = "{}"; |
70 } else { | 70 } else { |
71 histogram->WriteJSON(histogram_json); | 71 histogram->WriteJSON(histogram_json); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 } // namespace content | 75 } // namespace content |
OLD | NEW |