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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 31014: Port DictionaryValue to use string16 instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/page_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 6
7 //------------------------------------------------------------------------------ 7 //------------------------------------------------------------------------------
8 // Description of the life cycle of a instance of MetricsService. 8 // Description of the life cycle of a instance of MetricsService.
9 // 9 //
10 // OVERVIEW 10 // OVERVIEW
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 DCHECK(plugins); 1668 DCHECK(plugins);
1669 1669
1670 for (ListValue::iterator value_iter = plugins->begin(); 1670 for (ListValue::iterator value_iter = plugins->begin();
1671 value_iter != plugins->end(); ++value_iter) { 1671 value_iter != plugins->end(); ++value_iter) {
1672 if (!(*value_iter)->IsType(Value::TYPE_DICTIONARY)) { 1672 if (!(*value_iter)->IsType(Value::TYPE_DICTIONARY)) {
1673 NOTREACHED(); 1673 NOTREACHED();
1674 continue; 1674 continue;
1675 } 1675 }
1676 1676
1677 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); 1677 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter);
1678 std::wstring plugin_name; 1678 string16 plugin_name;
1679 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); 1679 plugin_dict->GetString(WideToUTF16Hack(prefs::kStabilityPluginName),
1680 &plugin_name);
1680 if (plugin_name.empty()) { 1681 if (plugin_name.empty()) {
1681 NOTREACHED(); 1682 NOTREACHED();
1682 continue; 1683 continue;
1683 } 1684 }
1684 1685
1685 if (child_process_stats_buffer_.find(plugin_name) == 1686 if (child_process_stats_buffer_.find(UTF16ToWideHack(plugin_name)) ==
1686 child_process_stats_buffer_.end()) 1687 child_process_stats_buffer_.end())
1687 continue; 1688 continue;
1688 1689
1689 ChildProcessStats stats = child_process_stats_buffer_[plugin_name]; 1690 ChildProcessStats stats =
1691 child_process_stats_buffer_[UTF16ToWideHack(plugin_name)];
1690 if (stats.process_launches) { 1692 if (stats.process_launches) {
1691 int launches = 0; 1693 int launches = 0;
1692 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); 1694 plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
1695 &launches);
1693 launches += stats.process_launches; 1696 launches += stats.process_launches;
1694 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches); 1697 plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
1698 launches);
1695 } 1699 }
1696 if (stats.process_crashes) { 1700 if (stats.process_crashes) {
1697 int crashes = 0; 1701 int crashes = 0;
1698 plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); 1702 plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
1703 &crashes);
1699 crashes += stats.process_crashes; 1704 crashes += stats.process_crashes;
1700 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes); 1705 plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
1706 crashes);
1701 } 1707 }
1702 if (stats.instances) { 1708 if (stats.instances) {
1703 int instances = 0; 1709 int instances = 0;
1704 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); 1710 plugin_dict->GetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
1711 &instances);
1705 instances += stats.instances; 1712 instances += stats.instances;
1706 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); 1713 plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
1714 instances);
1707 } 1715 }
1708 1716
1709 child_process_stats_buffer_.erase(plugin_name); 1717 child_process_stats_buffer_.erase(UTF16ToWideHack(plugin_name));
1710 } 1718 }
1711 1719
1712 // Now go through and add dictionaries for plugins that didn't already have 1720 // Now go through and add dictionaries for plugins that didn't already have
1713 // reports in Local State. 1721 // reports in Local State.
1714 for (std::map<std::wstring, ChildProcessStats>::iterator cache_iter = 1722 for (std::map<std::wstring, ChildProcessStats>::iterator cache_iter =
1715 child_process_stats_buffer_.begin(); 1723 child_process_stats_buffer_.begin();
1716 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { 1724 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) {
1717 std::wstring plugin_name = cache_iter->first; 1725 std::wstring plugin_name = cache_iter->first;
1718 ChildProcessStats stats = cache_iter->second; 1726 ChildProcessStats stats = cache_iter->second;
1719 DictionaryValue* plugin_dict = new DictionaryValue; 1727 DictionaryValue* plugin_dict = new DictionaryValue;
1720 1728
1721 plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); 1729 plugin_dict->SetString(WideToUTF16Hack(prefs::kStabilityPluginName),
1722 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1730 WideToUTF16Hack(plugin_name));
1731 plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginLaunches),
1723 stats.process_launches); 1732 stats.process_launches);
1724 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 1733 plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginCrashes),
1725 stats.process_crashes); 1734 stats.process_crashes);
1726 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 1735 plugin_dict->SetInteger(WideToUTF16Hack(prefs::kStabilityPluginInstances),
1727 stats.instances); 1736 stats.instances);
1728 plugins->Append(plugin_dict); 1737 plugins->Append(plugin_dict);
1729 } 1738 }
1730 child_process_stats_buffer_.clear(); 1739 child_process_stats_buffer_.clear();
1731 } 1740 }
1732 1741
1733 bool MetricsService::CanLogNotification(NotificationType type, 1742 bool MetricsService::CanLogNotification(NotificationType type,
1734 const NotificationSource& source, 1743 const NotificationSource& source,
1735 const NotificationDetails& details) { 1744 const NotificationDetails& details) {
1736 // We simply don't log anything to UMA if there is a single off the record 1745 // We simply don't log anything to UMA if there is a single off the record
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 // The id is most likely an email address. We shouldn't send it to the server. 1837 // The id is most likely an email address. We shouldn't send it to the server.
1829 const std::wstring id_hash = 1838 const std::wstring id_hash =
1830 UTF8ToWide(MetricsLog::CreateBase64Hash(WideToUTF8(profile->GetID()))); 1839 UTF8ToWide(MetricsLog::CreateBase64Hash(WideToUTF8(profile->GetID())));
1831 DCHECK(id_hash.find('.') == std::string::npos); 1840 DCHECK(id_hash.find('.') == std::string::npos);
1832 1841
1833 DictionaryValue* prof_prefs = prefs->GetMutableDictionary( 1842 DictionaryValue* prof_prefs = prefs->GetMutableDictionary(
1834 prefs::kProfileMetrics); 1843 prefs::kProfileMetrics);
1835 DCHECK(prof_prefs); 1844 DCHECK(prof_prefs);
1836 const std::wstring pref_key = std::wstring(prefs::kProfilePrefix) + id_hash + 1845 const std::wstring pref_key = std::wstring(prefs::kProfilePrefix) + id_hash +
1837 L"." + key; 1846 L"." + key;
1838 prof_prefs->SetInteger(pref_key.c_str(), value); 1847 prof_prefs->SetInteger(WideToUTF16Hack(pref_key), value);
1839 } 1848 }
1840 1849
1841 static bool IsSingleThreaded() { 1850 static bool IsSingleThreaded() {
1842 static PlatformThreadId thread_id = 0; 1851 static PlatformThreadId thread_id = 0;
1843 if (!thread_id) 1852 if (!thread_id)
1844 thread_id = PlatformThread::CurrentId(); 1853 thread_id = PlatformThread::CurrentId();
1845 return PlatformThread::CurrentId() == thread_id; 1854 return PlatformThread::CurrentId() == thread_id;
1846 } 1855 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/page_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698