Index: base/metrics/statistics_recorder.cc |
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc |
index fb069a5cdac94c619a16f8c9350587e12c219c65..85408e1fa496dec8dae7574213a3f3b21a1b123d 100644 |
--- a/base/metrics/statistics_recorder.cc |
+++ b/base/metrics/statistics_recorder.cc |
@@ -14,9 +14,6 @@ |
#include "base/synchronization/lock.h" |
#include "base/values.h" |
-using std::list; |
-using std::string; |
- |
namespace { |
// Initialize histogram statistics gathering system. |
base::LazyInstance<base::StatisticsRecorder>::Leaky g_statistics_recorder_ = |
@@ -59,7 +56,7 @@ HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate( |
if (histograms_ == NULL) { |
histogram_to_return = histogram; |
} else { |
- const string& name = histogram->histogram_name(); |
+ const std::string& name = histogram->histogram_name(); |
HistogramMap::iterator it = histograms_->find(name); |
if (histograms_->end() == it) { |
(*histograms_)[name] = histogram; |
@@ -96,22 +93,18 @@ const BucketRanges* StatisticsRecorder::RegisterOrDeleteDuplicateRanges( |
return ranges; |
} |
- list<const BucketRanges*>* checksum_matching_list; |
+ std::list<const BucketRanges*>* checksum_matching_list; |
RangesMap::iterator ranges_it = ranges_->find(ranges->checksum()); |
if (ranges_->end() == ranges_it) { |
// Add a new matching list to map. |
- checksum_matching_list = new list<const BucketRanges*>(); |
+ checksum_matching_list = new std::list<const BucketRanges*>(); |
ANNOTATE_LEAKING_OBJECT_PTR(checksum_matching_list); |
(*ranges_)[ranges->checksum()] = checksum_matching_list; |
} else { |
checksum_matching_list = ranges_it->second; |
} |
- list<const BucketRanges*>::iterator checksum_matching_list_it; |
- for (checksum_matching_list_it = checksum_matching_list->begin(); |
- checksum_matching_list_it != checksum_matching_list->end(); |
- ++checksum_matching_list_it) { |
- const BucketRanges* existing_ranges = *checksum_matching_list_it; |
+ for (const BucketRanges* existing_ranges : *checksum_matching_list) { |
if (existing_ranges->Equals(ranges)) { |
if (existing_ranges == ranges) { |
return ranges; |
@@ -135,10 +128,8 @@ void StatisticsRecorder::WriteHTMLGraph(const std::string& query, |
Histograms snapshot; |
GetSnapshot(query, &snapshot); |
- for (Histograms::iterator it = snapshot.begin(); |
- it != snapshot.end(); |
- ++it) { |
- (*it)->WriteHTMLGraph(output); |
+ for (const HistogramBase* histogram : snapshot) { |
+ histogram->WriteHTMLGraph(output); |
output->append("<br><hr><br>"); |
} |
} |
@@ -155,10 +146,8 @@ void StatisticsRecorder::WriteGraph(const std::string& query, |
Histograms snapshot; |
GetSnapshot(query, &snapshot); |
- for (Histograms::iterator it = snapshot.begin(); |
- it != snapshot.end(); |
- ++it) { |
- (*it)->WriteAscii(output); |
+ for (const HistogramBase* histogram : snapshot) { |
+ histogram->WriteAscii(output); |
output->append("\n"); |
} |
} |
@@ -179,14 +168,13 @@ std::string StatisticsRecorder::ToJSON(const std::string& query) { |
GetSnapshot(query, &snapshot); |
output += "\"histograms\":["; |
bool first_histogram = true; |
- for (Histograms::const_iterator it = snapshot.begin(); it != snapshot.end(); |
- ++it) { |
+ for (const HistogramBase* histogram : snapshot) { |
if (first_histogram) |
first_histogram = false; |
else |
output += ","; |
std::string json; |
- (*it)->WriteJSON(&json); |
+ histogram->WriteJSON(&json); |
output += json; |
} |
output += "]}"; |
@@ -201,11 +189,9 @@ void StatisticsRecorder::GetHistograms(Histograms* output) { |
if (histograms_ == NULL) |
return; |
- for (HistogramMap::iterator it = histograms_->begin(); |
- histograms_->end() != it; |
- ++it) { |
- DCHECK_EQ(it->first, it->second->histogram_name()); |
- output->push_back(it->second); |
+ for (const auto& entry : *histograms_) { |
+ DCHECK_EQ(entry.first, entry.second->histogram_name()); |
+ output->push_back(entry.second); |
} |
} |
@@ -218,15 +204,9 @@ void StatisticsRecorder::GetBucketRanges( |
if (ranges_ == NULL) |
return; |
- for (RangesMap::iterator it = ranges_->begin(); |
- ranges_->end() != it; |
- ++it) { |
- list<const BucketRanges*>* ranges_list = it->second; |
- list<const BucketRanges*>::iterator ranges_list_it; |
- for (ranges_list_it = ranges_list->begin(); |
- ranges_list_it != ranges_list->end(); |
- ++ranges_list_it) { |
- output->push_back(*ranges_list_it); |
+ for (const auto& entry : *ranges_) { |
+ for (const auto& range_entry : *entry.second) { |
+ output->push_back(range_entry); |
} |
} |
} |
@@ -254,11 +234,9 @@ void StatisticsRecorder::GetSnapshot(const std::string& query, |
if (histograms_ == NULL) |
return; |
- for (HistogramMap::iterator it = histograms_->begin(); |
- histograms_->end() != it; |
- ++it) { |
- if (it->first.find(query) != std::string::npos) |
- snapshot->push_back(it->second); |
+ for (const auto& entry : *histograms_) { |
+ if (entry.first.find(query) != std::string::npos) |
+ snapshot->push_back(entry.second); |
} |
} |
@@ -286,7 +264,7 @@ StatisticsRecorder::StatisticsRecorder() { |
// static |
void StatisticsRecorder::DumpHistogramsToVlog(void* instance) { |
- string output; |
+ std::string output; |
StatisticsRecorder::WriteGraph(std::string(), &output); |
VLOG(1) << output; |
} |