| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser/metrics/metrics_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/md5.h" | 10 #include "base/md5.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 if (plugin_stats_list) { | 376 if (plugin_stats_list) { |
| 377 OPEN_ELEMENT_FOR_SCOPE("plugins"); | 377 OPEN_ELEMENT_FOR_SCOPE("plugins"); |
| 378 for (ListValue::const_iterator iter = plugin_stats_list->begin(); | 378 for (ListValue::const_iterator iter = plugin_stats_list->begin(); |
| 379 iter != plugin_stats_list->end(); ++iter) { | 379 iter != plugin_stats_list->end(); ++iter) { |
| 380 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) { | 380 if (!(*iter)->IsType(Value::TYPE_DICTIONARY)) { |
| 381 NOTREACHED(); | 381 NOTREACHED(); |
| 382 continue; | 382 continue; |
| 383 } | 383 } |
| 384 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); | 384 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*iter); |
| 385 | 385 |
| 386 std::wstring plugin_name; | 386 string16 plugin_name; |
| 387 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); | 387 plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName), |
| 388 &plugin_name); |
| 388 | 389 |
| 389 OPEN_ELEMENT_FOR_SCOPE("pluginstability"); | 390 OPEN_ELEMENT_FOR_SCOPE("pluginstability"); |
| 390 // Use "filename" instead of "name", otherwise we need to update the | 391 // Use "filename" instead of "name", otherwise we need to update the |
| 391 // UMA servers. | 392 // UMA servers. |
| 392 WriteAttribute("filename", CreateBase64Hash(WideToUTF8(plugin_name))); | 393 WriteAttribute("filename", CreateBase64Hash(UTF16ToUTF8(plugin_name))); |
| 393 | 394 |
| 394 int launches = 0; | 395 int launches = 0; |
| 395 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); | 396 plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches), |
| 397 &launches); |
| 396 WriteIntAttribute("launchcount", launches); | 398 WriteIntAttribute("launchcount", launches); |
| 397 | 399 |
| 398 int instances = 0; | 400 int instances = 0; |
| 399 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); | 401 plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances), |
| 402 &instances); |
| 400 WriteIntAttribute("instancecount", instances); | 403 WriteIntAttribute("instancecount", instances); |
| 401 | 404 |
| 402 int crashes = 0; | 405 int crashes = 0; |
| 403 plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); | 406 plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes), |
| 407 &crashes); |
| 404 WriteIntAttribute("crashcount", crashes); | 408 WriteIntAttribute("crashcount", crashes); |
| 405 } | 409 } |
| 406 | 410 |
| 407 pref->ClearPref(prefs::kStabilityPluginStats); | 411 pref->ClearPref(prefs::kStabilityPluginStats); |
| 408 } | 412 } |
| 409 } | 413 } |
| 410 | 414 |
| 411 void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) { | 415 void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) { |
| 412 // The server refuses data that doesn't have certain values. crashcount and | 416 // The server refuses data that doesn't have certain values. crashcount and |
| 413 // launchcount are currently "required" in the "stability" group. | 417 // launchcount are currently "required" in the "stability" group. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 565 |
| 562 if (profile_metrics) | 566 if (profile_metrics) |
| 563 WriteAllProfilesMetrics(*profile_metrics); | 567 WriteAllProfilesMetrics(*profile_metrics); |
| 564 } | 568 } |
| 565 | 569 |
| 566 void MetricsLog::WriteAllProfilesMetrics( | 570 void MetricsLog::WriteAllProfilesMetrics( |
| 567 const DictionaryValue& all_profiles_metrics) { | 571 const DictionaryValue& all_profiles_metrics) { |
| 568 const std::wstring profile_prefix(prefs::kProfilePrefix); | 572 const std::wstring profile_prefix(prefs::kProfilePrefix); |
| 569 for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys(); | 573 for (DictionaryValue::key_iterator i = all_profiles_metrics.begin_keys(); |
| 570 i != all_profiles_metrics.end_keys(); ++i) { | 574 i != all_profiles_metrics.end_keys(); ++i) { |
| 571 const std::wstring& key_name = *i; | 575 const string16 key_name16 = *i; |
| 576 const std::wstring& key_name = UTF16ToWideHack(key_name16); |
| 572 if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) { | 577 if (key_name.compare(0, profile_prefix.size(), profile_prefix) == 0) { |
| 573 DictionaryValue* profile; | 578 DictionaryValue* profile; |
| 574 if (all_profiles_metrics.GetDictionary(key_name, &profile)) | 579 if (all_profiles_metrics.GetDictionary(key_name16, &profile)) |
| 575 WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile); | 580 WriteProfileMetrics(key_name.substr(profile_prefix.size()), *profile); |
| 576 } | 581 } |
| 577 } | 582 } |
| 578 } | 583 } |
| 579 | 584 |
| 580 void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, | 585 void MetricsLog::WriteProfileMetrics(const std::wstring& profileidhash, |
| 581 const DictionaryValue& profile_metrics) { | 586 const DictionaryValue& profile_metrics) { |
| 582 OPEN_ELEMENT_FOR_SCOPE("userprofile"); | 587 OPEN_ELEMENT_FOR_SCOPE("userprofile"); |
| 583 WriteAttribute("profileidhash", WideToUTF8(profileidhash)); | 588 WriteAttribute("profileidhash", WideToUTF8(profileidhash)); |
| 584 for (DictionaryValue::key_iterator i = profile_metrics.begin_keys(); | 589 for (DictionaryValue::key_iterator i = profile_metrics.begin_keys(); |
| 585 i != profile_metrics.end_keys(); ++i) { | 590 i != profile_metrics.end_keys(); ++i) { |
| 586 Value* value; | 591 Value* value; |
| 587 if (profile_metrics.Get(*i, &value)) { | 592 if (profile_metrics.Get(*i, &value)) { |
| 588 DCHECK(*i != L"id"); | 593 DCHECK(*i != ASCIIToUTF16("id")); |
| 589 switch (value->GetType()) { | 594 switch (value->GetType()) { |
| 590 case Value::TYPE_STRING: { | 595 case Value::TYPE_STRING: { |
| 591 std::string string_value; | 596 std::string string_value; |
| 592 if (value->GetAsString(&string_value)) { | 597 if (value->GetAsString(&string_value)) { |
| 593 OPEN_ELEMENT_FOR_SCOPE("profileparam"); | 598 OPEN_ELEMENT_FOR_SCOPE("profileparam"); |
| 594 WriteAttribute("name", WideToUTF8(*i)); | 599 WriteAttribute("name", UTF16ToUTF8(*i)); |
| 595 WriteAttribute("value", string_value); | 600 WriteAttribute("value", string_value); |
| 596 } | 601 } |
| 597 break; | 602 break; |
| 598 } | 603 } |
| 599 | 604 |
| 600 case Value::TYPE_BOOLEAN: { | 605 case Value::TYPE_BOOLEAN: { |
| 601 bool bool_value; | 606 bool bool_value; |
| 602 if (value->GetAsBoolean(&bool_value)) { | 607 if (value->GetAsBoolean(&bool_value)) { |
| 603 OPEN_ELEMENT_FOR_SCOPE("profileparam"); | 608 OPEN_ELEMENT_FOR_SCOPE("profileparam"); |
| 604 WriteAttribute("name", WideToUTF8(*i)); | 609 WriteAttribute("name", UTF16ToUTF8(*i)); |
| 605 WriteIntAttribute("value", bool_value ? 1 : 0); | 610 WriteIntAttribute("value", bool_value ? 1 : 0); |
| 606 } | 611 } |
| 607 break; | 612 break; |
| 608 } | 613 } |
| 609 | 614 |
| 610 case Value::TYPE_INTEGER: { | 615 case Value::TYPE_INTEGER: { |
| 611 int int_value; | 616 int int_value; |
| 612 if (value->GetAsInteger(&int_value)) { | 617 if (value->GetAsInteger(&int_value)) { |
| 613 OPEN_ELEMENT_FOR_SCOPE("profileparam"); | 618 OPEN_ELEMENT_FOR_SCOPE("profileparam"); |
| 614 WriteAttribute("name", WideToUTF8(*i)); | 619 WriteAttribute("name", UTF16ToUTF8(*i)); |
| 615 WriteIntAttribute("value", int_value); | 620 WriteIntAttribute("value", int_value); |
| 616 } | 621 } |
| 617 break; | 622 break; |
| 618 } | 623 } |
| 619 | 624 |
| 620 default: | 625 default: |
| 621 NOTREACHED(); | 626 NOTREACHED(); |
| 622 break; | 627 break; |
| 623 } | 628 } |
| 624 } | 629 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 689 |
| 685 for (size_t i = 0; i < histogram.bucket_count(); i++) { | 690 for (size_t i = 0; i < histogram.bucket_count(); i++) { |
| 686 if (snapshot.counts(i)) { | 691 if (snapshot.counts(i)) { |
| 687 OPEN_ELEMENT_FOR_SCOPE("histogrambucket"); | 692 OPEN_ELEMENT_FOR_SCOPE("histogrambucket"); |
| 688 WriteIntAttribute("min", histogram.ranges(i)); | 693 WriteIntAttribute("min", histogram.ranges(i)); |
| 689 WriteIntAttribute("max", histogram.ranges(i + 1)); | 694 WriteIntAttribute("max", histogram.ranges(i + 1)); |
| 690 WriteIntAttribute("count", snapshot.counts(i)); | 695 WriteIntAttribute("count", snapshot.counts(i)); |
| 691 } | 696 } |
| 692 } | 697 } |
| 693 } | 698 } |
| OLD | NEW |