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

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

Issue 1304563003: Move //components/metrics/compression_utils into standalone component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/metrics/persisted_logs.h" 5 #include "components/metrics/persisted_logs.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/prefs/scoped_user_pref_update.h" 13 #include "base/prefs/scoped_user_pref_update.h"
14 #include "base/sha1.h" 14 #include "base/sha1.h"
15 #include "base/timer/elapsed_timer.h" 15 #include "base/timer/elapsed_timer.h"
16 #include "components/metrics/compression_utils.h" 16 #include "components/compression/compression_utils.h"
17 17
18 namespace metrics { 18 namespace metrics {
19 19
20 namespace { 20 namespace {
21 21
22 PersistedLogs::LogReadStatus MakeRecallStatusHistogram( 22 PersistedLogs::LogReadStatus MakeRecallStatusHistogram(
23 PersistedLogs::LogReadStatus status) { 23 PersistedLogs::LogReadStatus status) {
24 UMA_HISTOGRAM_ENUMERATION("PrefService.PersistentLogRecallProtobufs", 24 UMA_HISTOGRAM_ENUMERATION("PrefService.PersistentLogRecallProtobufs",
25 status, PersistedLogs::END_RECALL_STATUS); 25 status, PersistedLogs::END_RECALL_STATUS);
26 return status; 26 return status;
(...skipping 15 matching lines...) Expand all
42 std::string base64_str; 42 std::string base64_str;
43 base::Base64Encode(str, &base64_str); 43 base::Base64Encode(str, &base64_str);
44 list_value->AppendString(base64_str); 44 list_value->AppendString(base64_str);
45 } 45 }
46 46
47 } // namespace 47 } // namespace
48 48
49 void PersistedLogs::LogHashPair::Init(const std::string& log_data) { 49 void PersistedLogs::LogHashPair::Init(const std::string& log_data) {
50 DCHECK(!log_data.empty()); 50 DCHECK(!log_data.empty());
51 51
52 if (!GzipCompress(log_data, &compressed_log_data)) { 52 if (!compression::GzipCompress(log_data, &compressed_log_data)) {
53 NOTREACHED(); 53 NOTREACHED();
54 return; 54 return;
55 } 55 }
56 56
57 UMA_HISTOGRAM_PERCENTAGE( 57 UMA_HISTOGRAM_PERCENTAGE(
58 "UMA.ProtoCompressionRatio", 58 "UMA.ProtoCompressionRatio",
59 static_cast<int>(100 * compressed_log_data.size() / log_data.size())); 59 static_cast<int>(100 * compressed_log_data.size() / log_data.size()));
60 60
61 hash = base::SHA1HashString(log_data); 61 hash = base::SHA1HashString(log_data);
62 } 62 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 !ReadBase64String(list_value, i * 2 + 1, &list_[i].hash)) { 162 !ReadBase64String(list_value, i * 2 + 1, &list_[i].hash)) {
163 list_.clear(); 163 list_.clear();
164 return MakeRecallStatusHistogram(LOG_STRING_CORRUPTION); 164 return MakeRecallStatusHistogram(LOG_STRING_CORRUPTION);
165 } 165 }
166 } 166 }
167 167
168 return MakeRecallStatusHistogram(RECALL_SUCCESS); 168 return MakeRecallStatusHistogram(RECALL_SUCCESS);
169 } 169 }
170 170
171 } // namespace metrics 171 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_service_unittest.cc ('k') | components/metrics/persisted_logs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698