OLD | NEW |
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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 std::string base64_result; | 34 std::string base64_result; |
35 if (!list_value.GetString(index, &base64_result)) | 35 if (!list_value.GetString(index, &base64_result)) |
36 return false; | 36 return false; |
37 return base::Base64Decode(base64_result, result); | 37 return base::Base64Decode(base64_result, result); |
38 } | 38 } |
39 | 39 |
40 // Base64-encodes |str| and appends the result to |list_value|. | 40 // Base64-encodes |str| and appends the result to |list_value|. |
41 void AppendBase64String(const std::string& str, base::ListValue* list_value) { | 41 void AppendBase64String(const std::string& str, base::ListValue* list_value) { |
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->Append(base::Value::CreateStringValue(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 (!GzipCompress(log_data, &compressed_log_data)) { |
53 NOTREACHED(); | 53 NOTREACHED(); |
54 return; | 54 return; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 return MakeRecallStatusHistogram(CHECKSUM_STRING_CORRUPTION); | 289 return MakeRecallStatusHistogram(CHECKSUM_STRING_CORRUPTION); |
290 } | 290 } |
291 if (recovered_md5 != base::MD5DigestToBase16(digest)) { | 291 if (recovered_md5 != base::MD5DigestToBase16(digest)) { |
292 list_.clear(); | 292 list_.clear(); |
293 return MakeRecallStatusHistogram(CHECKSUM_CORRUPTION); | 293 return MakeRecallStatusHistogram(CHECKSUM_CORRUPTION); |
294 } | 294 } |
295 return MakeRecallStatusHistogram(RECALL_SUCCESS); | 295 return MakeRecallStatusHistogram(RECALL_SUCCESS); |
296 } | 296 } |
297 | 297 |
298 } // namespace metrics | 298 } // namespace metrics |
OLD | NEW |