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

Side by Side Diff: components/metrics/metrics_log_manager.cc

Issue 239093004: Move part of metrics from chrome/common to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding TBR section for owners of minor changes. Created 6 years, 7 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
OLDNEW
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 "chrome/common/metrics/metrics_log_manager.h" 5 #include "components/metrics/metrics_log_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/timer/elapsed_timer.h" 12 #include "base/timer/elapsed_timer.h"
13 #include "chrome/common/metrics/metrics_log_base.h" 13 #include "components/metrics/metrics_log_base.h"
14
15 namespace metrics {
14 16
15 MetricsLogManager::SerializedLog::SerializedLog() {} 17 MetricsLogManager::SerializedLog::SerializedLog() {}
16 MetricsLogManager::SerializedLog::~SerializedLog() {} 18 MetricsLogManager::SerializedLog::~SerializedLog() {}
17 19
18 bool MetricsLogManager::SerializedLog::IsEmpty() const { 20 bool MetricsLogManager::SerializedLog::IsEmpty() const {
19 return log_text_.empty(); 21 return log_text_.empty();
20 } 22 }
21 23
22 void MetricsLogManager::SerializedLog::SwapLogText(std::string* log_text) { 24 void MetricsLogManager::SerializedLog::SwapLogText(std::string* log_text) {
23 log_text_.swap(*log_text); 25 log_text_.swap(*log_text);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (store_type == PROVISIONAL_STORE) { 138 if (store_type == PROVISIONAL_STORE) {
137 last_provisional_store_index_ = destination_list->size() - 1; 139 last_provisional_store_index_ = destination_list->size() - 1;
138 last_provisional_store_type_ = log_type; 140 last_provisional_store_type_ = log_type;
139 } 141 }
140 } 142 }
141 143
142 void MetricsLogManager::DiscardLastProvisionalStore() { 144 void MetricsLogManager::DiscardLastProvisionalStore() {
143 if (last_provisional_store_index_ == -1) 145 if (last_provisional_store_index_ == -1)
144 return; 146 return;
145 std::vector<SerializedLog>* source_list = 147 std::vector<SerializedLog>* source_list =
146 (last_provisional_store_type_ == MetricsLogBase::ONGOING_LOG) ? 148 (last_provisional_store_type_ == MetricsLogBase::ONGOING_LOG)
147 &unsent_ongoing_logs_ : &unsent_initial_logs_; 149 ? &unsent_ongoing_logs_
150 : &unsent_initial_logs_;
148 DCHECK_LT(static_cast<unsigned int>(last_provisional_store_index_), 151 DCHECK_LT(static_cast<unsigned int>(last_provisional_store_index_),
149 source_list->size()); 152 source_list->size());
150 source_list->erase(source_list->begin() + last_provisional_store_index_); 153 source_list->erase(source_list->begin() + last_provisional_store_index_);
151 last_provisional_store_index_ = -1; 154 last_provisional_store_index_ = -1;
152 } 155 }
153 156
154 void MetricsLogManager::PersistUnsentLogs() { 157 void MetricsLogManager::PersistUnsentLogs() {
155 DCHECK(log_serializer_.get()); 158 DCHECK(log_serializer_.get());
156 if (!log_serializer_.get()) 159 if (!log_serializer_.get())
157 return; 160 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed()); 197 UMA_HISTOGRAM_TIMES("UMA.LoadLogsTime", timer.Elapsed());
195 198
196 unsent_logs_loaded_ = true; 199 unsent_logs_loaded_ = true;
197 } 200 }
198 201
199 void MetricsLogManager::CompressCurrentLog(SerializedLog* compressed_log) { 202 void MetricsLogManager::CompressCurrentLog(SerializedLog* compressed_log) {
200 std::string log_text; 203 std::string log_text;
201 current_log_->GetEncodedLog(&log_text); 204 current_log_->GetEncodedLog(&log_text);
202 compressed_log->SwapLogText(&log_text); 205 compressed_log->SwapLogText(&log_text);
203 } 206 }
207
208 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698