OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It | 10 // A MetricsService instance is typically created at application startup. It |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 std::string encoded_log; | 1127 std::string encoded_log; |
1128 std::string decoded_log; | 1128 std::string decoded_log; |
1129 for (ListValue::const_iterator it = list.begin() + 1; | 1129 for (ListValue::const_iterator it = list.begin() + 1; |
1130 it != list.end() - 1; ++it) { // Last element is the checksum. | 1130 it != list.end() - 1; ++it) { // Last element is the checksum. |
1131 valid = (*it)->GetAsString(&encoded_log); | 1131 valid = (*it)->GetAsString(&encoded_log); |
1132 if (!valid) { | 1132 if (!valid) { |
1133 local_list->clear(); | 1133 local_list->clear(); |
1134 return MakeRecallStatusHistogram(LOG_STRING_CORRUPTION); | 1134 return MakeRecallStatusHistogram(LOG_STRING_CORRUPTION); |
1135 } | 1135 } |
1136 | 1136 |
1137 base::MD5Update(&ctx, encoded_log.data(), encoded_log.length()); | 1137 base::MD5Update(&ctx, encoded_log); |
1138 | 1138 |
1139 if (!base::Base64Decode(encoded_log, &decoded_log)) { | 1139 if (!base::Base64Decode(encoded_log, &decoded_log)) { |
1140 local_list->clear(); | 1140 local_list->clear(); |
1141 return MakeRecallStatusHistogram(DECODE_FAIL); | 1141 return MakeRecallStatusHistogram(DECODE_FAIL); |
1142 } | 1142 } |
1143 local_list->push_back(decoded_log); | 1143 local_list->push_back(decoded_log); |
1144 } | 1144 } |
1145 | 1145 |
1146 // Verify checksum. | 1146 // Verify checksum. |
1147 base::MD5Digest digest; | 1147 base::MD5Digest digest; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 std::string encoded_log; | 1193 std::string encoded_log; |
1194 for (std::vector<std::string>::const_iterator it = local_list.begin() + start; | 1194 for (std::vector<std::string>::const_iterator it = local_list.begin() + start; |
1195 it != local_list.end(); ++it) { | 1195 it != local_list.end(); ++it) { |
1196 // We encode the compressed log as Value::CreateStringValue() expects to | 1196 // We encode the compressed log as Value::CreateStringValue() expects to |
1197 // take a valid UTF8 string. | 1197 // take a valid UTF8 string. |
1198 if (!base::Base64Encode(*it, &encoded_log)) { | 1198 if (!base::Base64Encode(*it, &encoded_log)) { |
1199 MakeStoreStatusHistogram(ENCODE_FAIL); | 1199 MakeStoreStatusHistogram(ENCODE_FAIL); |
1200 list->Clear(); | 1200 list->Clear(); |
1201 return; | 1201 return; |
1202 } | 1202 } |
1203 base::MD5Update(&ctx, encoded_log.data(), encoded_log.length()); | 1203 base::MD5Update(&ctx, encoded_log); |
1204 list->Append(Value::CreateStringValue(encoded_log)); | 1204 list->Append(Value::CreateStringValue(encoded_log)); |
1205 } | 1205 } |
1206 | 1206 |
1207 // Append hash to the end of the list. | 1207 // Append hash to the end of the list. |
1208 base::MD5Digest digest; | 1208 base::MD5Digest digest; |
1209 base::MD5Final(&digest, &ctx); | 1209 base::MD5Final(&digest, &ctx); |
1210 list->Append(Value::CreateStringValue(base::MD5DigestToBase16(digest))); | 1210 list->Append(Value::CreateStringValue(base::MD5DigestToBase16(digest))); |
1211 DCHECK(list->GetSize() >= 3); // Minimum of 3 elements (size, data, hash). | 1211 DCHECK(list->GetSize() >= 3); // Minimum of 3 elements (size, data, hash). |
1212 MakeStoreStatusHistogram(STORE_SUCCESS); | 1212 MakeStoreStatusHistogram(STORE_SUCCESS); |
1213 } | 1213 } |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 thread_id = base::PlatformThread::CurrentId(); | 1691 thread_id = base::PlatformThread::CurrentId(); |
1692 return base::PlatformThread::CurrentId() == thread_id; | 1692 return base::PlatformThread::CurrentId() == thread_id; |
1693 } | 1693 } |
1694 | 1694 |
1695 #if defined(OS_CHROMEOS) | 1695 #if defined(OS_CHROMEOS) |
1696 void MetricsService::StartExternalMetrics() { | 1696 void MetricsService::StartExternalMetrics() { |
1697 external_metrics_ = new chromeos::ExternalMetrics; | 1697 external_metrics_ = new chromeos::ExternalMetrics; |
1698 external_metrics_->Start(); | 1698 external_metrics_->Start(); |
1699 } | 1699 } |
1700 #endif | 1700 #endif |
OLD | NEW |