| 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 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 ListValue* list) { | 1179 ListValue* list) { |
| 1180 list->Clear(); | 1180 list->Clear(); |
| 1181 size_t start = 0; | 1181 size_t start = 0; |
| 1182 if (local_list.size() > kMaxLocalListSize) | 1182 if (local_list.size() > kMaxLocalListSize) |
| 1183 start = local_list.size() - kMaxLocalListSize; | 1183 start = local_list.size() - kMaxLocalListSize; |
| 1184 DCHECK(start <= local_list.size()); | 1184 DCHECK(start <= local_list.size()); |
| 1185 if (local_list.size() == start) | 1185 if (local_list.size() == start) |
| 1186 return; | 1186 return; |
| 1187 | 1187 |
| 1188 // Store size at the beginning of the list. | 1188 // Store size at the beginning of the list. |
| 1189 list->Append(Value::CreateIntegerValue(local_list.size() - start)); | 1189 list->Append(base::NumberValue::New( |
| 1190 static_cast<int>(local_list.size() - start))); |
| 1190 | 1191 |
| 1191 base::MD5Context ctx; | 1192 base::MD5Context ctx; |
| 1192 base::MD5Init(&ctx); | 1193 base::MD5Init(&ctx); |
| 1193 std::string encoded_log; | 1194 std::string encoded_log; |
| 1194 for (std::vector<std::string>::const_iterator it = local_list.begin() + start; | 1195 for (std::vector<std::string>::const_iterator it = local_list.begin() + start; |
| 1195 it != local_list.end(); ++it) { | 1196 it != local_list.end(); ++it) { |
| 1196 // We encode the compressed log as Value::CreateStringValue() expects to | 1197 // We encode the compressed log as base::StringValue::New() expects to |
| 1197 // take a valid UTF8 string. | 1198 // take a valid UTF8 string. |
| 1198 if (!base::Base64Encode(*it, &encoded_log)) { | 1199 if (!base::Base64Encode(*it, &encoded_log)) { |
| 1199 MakeStoreStatusHistogram(ENCODE_FAIL); | 1200 MakeStoreStatusHistogram(ENCODE_FAIL); |
| 1200 list->Clear(); | 1201 list->Clear(); |
| 1201 return; | 1202 return; |
| 1202 } | 1203 } |
| 1203 base::MD5Update(&ctx, encoded_log); | 1204 base::MD5Update(&ctx, encoded_log); |
| 1204 list->Append(Value::CreateStringValue(encoded_log)); | 1205 list->Append(base::StringValue::New(encoded_log)); |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 // Append hash to the end of the list. | 1208 // Append hash to the end of the list. |
| 1208 base::MD5Digest digest; | 1209 base::MD5Digest digest; |
| 1209 base::MD5Final(&digest, &ctx); | 1210 base::MD5Final(&digest, &ctx); |
| 1210 list->Append(Value::CreateStringValue(base::MD5DigestToBase16(digest))); | 1211 list->Append(base::StringValue::New(base::MD5DigestToBase16(digest))); |
| 1211 DCHECK(list->GetSize() >= 3); // Minimum of 3 elements (size, data, hash). | 1212 DCHECK(list->GetSize() >= 3); // Minimum of 3 elements (size, data, hash). |
| 1212 MakeStoreStatusHistogram(STORE_SUCCESS); | 1213 MakeStoreStatusHistogram(STORE_SUCCESS); |
| 1213 } | 1214 } |
| 1214 | 1215 |
| 1215 void MetricsService::StoreUnsentLogs() { | 1216 void MetricsService::StoreUnsentLogs() { |
| 1216 if (state_ < INITIAL_LOG_READY) | 1217 if (state_ < INITIAL_LOG_READY) |
| 1217 return; // We never Recalled the prior unsent logs. | 1218 return; // We never Recalled the prior unsent logs. |
| 1218 | 1219 |
| 1219 PrefService* local_state = g_browser_process->local_state(); | 1220 PrefService* local_state = g_browser_process->local_state(); |
| 1220 DCHECK(local_state); | 1221 DCHECK(local_state); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 thread_id = base::PlatformThread::CurrentId(); | 1694 thread_id = base::PlatformThread::CurrentId(); |
| 1694 return base::PlatformThread::CurrentId() == thread_id; | 1695 return base::PlatformThread::CurrentId() == thread_id; |
| 1695 } | 1696 } |
| 1696 | 1697 |
| 1697 #if defined(OS_CHROMEOS) | 1698 #if defined(OS_CHROMEOS) |
| 1698 void MetricsService::StartExternalMetrics() { | 1699 void MetricsService::StartExternalMetrics() { |
| 1699 external_metrics_ = new chromeos::ExternalMetrics; | 1700 external_metrics_ = new chromeos::ExternalMetrics; |
| 1700 external_metrics_->Start(); | 1701 external_metrics_->Start(); |
| 1701 } | 1702 } |
| 1702 #endif | 1703 #endif |
| OLD | NEW |