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

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

Issue 7583016: wstring: remove wstrings from ChildProcessInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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_service.h ('k') | chrome/browser/nacl_host/nacl_process_host.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) 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 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 // log data is available. 1496 // log data is available.
1497 HandleIdleSinceLastTransmission(false); 1497 HandleIdleSinceLastTransmission(false);
1498 } 1498 }
1499 #endif // OS_CHROMEOS 1499 #endif // OS_CHROMEOS
1500 1500
1501 void MetricsService::LogChildProcessChange( 1501 void MetricsService::LogChildProcessChange(
1502 int type, 1502 int type,
1503 const NotificationSource& source, 1503 const NotificationSource& source,
1504 const NotificationDetails& details) { 1504 const NotificationDetails& details) {
1505 Details<ChildProcessInfo> child_details(details); 1505 Details<ChildProcessInfo> child_details(details);
1506 const std::wstring& child_name = child_details->name(); 1506 const string16& child_name = child_details->name();
1507 1507
1508 if (child_process_stats_buffer_.find(child_name) == 1508 if (child_process_stats_buffer_.find(child_name) ==
1509 child_process_stats_buffer_.end()) { 1509 child_process_stats_buffer_.end()) {
1510 child_process_stats_buffer_[child_name] = 1510 child_process_stats_buffer_[child_name] =
1511 ChildProcessStats(child_details->type()); 1511 ChildProcessStats(child_details->type());
1512 } 1512 }
1513 1513
1514 ChildProcessStats& stats = child_process_stats_buffer_[child_name]; 1514 ChildProcessStats& stats = child_process_stats_buffer_[child_name];
1515 switch (type) { 1515 switch (type) {
1516 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: 1516 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 1598
1599 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter); 1599 DictionaryValue* plugin_dict = static_cast<DictionaryValue*>(*value_iter);
1600 std::string plugin_name; 1600 std::string plugin_name;
1601 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); 1601 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name);
1602 if (plugin_name.empty()) { 1602 if (plugin_name.empty()) {
1603 NOTREACHED(); 1603 NOTREACHED();
1604 continue; 1604 continue;
1605 } 1605 }
1606 1606
1607 // TODO(viettrungluu): remove conversions 1607 // TODO(viettrungluu): remove conversions
1608 if (child_process_stats_buffer_.find(UTF8ToWide(plugin_name)) == 1608 string16 name16 = UTF8ToUTF16(plugin_name);
1609 child_process_stats_buffer_.end()) 1609 if (child_process_stats_buffer_.find(name16) ==
1610 child_process_stats_buffer_.end()) {
1610 continue; 1611 continue;
1612 }
1611 1613
1612 ChildProcessStats stats = 1614 ChildProcessStats stats = child_process_stats_buffer_[name16];
1613 child_process_stats_buffer_[UTF8ToWide(plugin_name)];
1614 if (stats.process_launches) { 1615 if (stats.process_launches) {
1615 int launches = 0; 1616 int launches = 0;
1616 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); 1617 plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
1617 launches += stats.process_launches; 1618 launches += stats.process_launches;
1618 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches); 1619 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, launches);
1619 } 1620 }
1620 if (stats.process_crashes) { 1621 if (stats.process_crashes) {
1621 int crashes = 0; 1622 int crashes = 0;
1622 plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes); 1623 plugin_dict->GetInteger(prefs::kStabilityPluginCrashes, &crashes);
1623 crashes += stats.process_crashes; 1624 crashes += stats.process_crashes;
1624 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes); 1625 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, crashes);
1625 } 1626 }
1626 if (stats.instances) { 1627 if (stats.instances) {
1627 int instances = 0; 1628 int instances = 0;
1628 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances); 1629 plugin_dict->GetInteger(prefs::kStabilityPluginInstances, &instances);
1629 instances += stats.instances; 1630 instances += stats.instances;
1630 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); 1631 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances);
1631 } 1632 }
1632 1633
1633 child_process_stats_buffer_.erase(UTF8ToWide(plugin_name)); 1634 child_process_stats_buffer_.erase(name16);
1634 } 1635 }
1635 1636
1636 // Now go through and add dictionaries for plugins that didn't already have 1637 // Now go through and add dictionaries for plugins that didn't already have
1637 // reports in Local State. 1638 // reports in Local State.
1638 for (std::map<std::wstring, ChildProcessStats>::iterator cache_iter = 1639 for (std::map<string16, ChildProcessStats>::iterator cache_iter =
1639 child_process_stats_buffer_.begin(); 1640 child_process_stats_buffer_.begin();
1640 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { 1641 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) {
1641 ChildProcessStats stats = cache_iter->second; 1642 ChildProcessStats stats = cache_iter->second;
1642 1643
1643 // Insert only plugins information into the plugins list. 1644 // Insert only plugins information into the plugins list.
1644 if (ChildProcessInfo::PLUGIN_PROCESS != stats.process_type) 1645 if (ChildProcessInfo::PLUGIN_PROCESS != stats.process_type)
1645 continue; 1646 continue;
1646 1647
1647 // TODO(viettrungluu): remove conversion 1648 // TODO(viettrungluu): remove conversion
1648 std::string plugin_name = WideToUTF8(cache_iter->first); 1649 std::string plugin_name = UTF16ToUTF8(cache_iter->first);
1649 1650
1650 DictionaryValue* plugin_dict = new DictionaryValue; 1651 DictionaryValue* plugin_dict = new DictionaryValue;
1651 1652
1652 plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name); 1653 plugin_dict->SetString(prefs::kStabilityPluginName, plugin_name);
1653 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1654 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches,
1654 stats.process_launches); 1655 stats.process_launches);
1655 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 1656 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes,
1656 stats.process_crashes); 1657 stats.process_crashes);
1657 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 1658 plugin_dict->SetInteger(prefs::kStabilityPluginInstances,
1658 stats.instances); 1659 stats.instances);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 thread_id = base::PlatformThread::CurrentId(); 1693 thread_id = base::PlatformThread::CurrentId();
1693 return base::PlatformThread::CurrentId() == thread_id; 1694 return base::PlatformThread::CurrentId() == thread_id;
1694 } 1695 }
1695 1696
1696 #if defined(OS_CHROMEOS) 1697 #if defined(OS_CHROMEOS)
1697 void MetricsService::StartExternalMetrics() { 1698 void MetricsService::StartExternalMetrics() {
1698 external_metrics_ = new chromeos::ExternalMetrics; 1699 external_metrics_ = new chromeos::ExternalMetrics;
1699 external_metrics_->Start(); 1700 external_metrics_->Start();
1700 } 1701 }
1701 #endif 1702 #endif
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/nacl_host/nacl_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698