Commit 68b9e72b authored by evan@chromium.org's avatar evan@chromium.org

wstring: remove wstrings from ChildProcessInfo

Convert MetricsServices' child_process_stats_buffer_ while
I'm at it.

Review URL: http://codereview.chromium.org/7583016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95680 0039d316-1c4b-4281-b951-d872f2087c98
parent 605abf9a
...@@ -2631,7 +2631,7 @@ class GetChildProcessHostInfoTask : public Task { ...@@ -2631,7 +2631,7 @@ class GetChildProcessHostInfoTask : public Task {
} }
ChildProcessInfo* info = *iter; ChildProcessInfo* info = *iter;
DictionaryValue* item = new DictionaryValue; DictionaryValue* item = new DictionaryValue;
item->SetString("name", WideToUTF16Hack(info->name())); item->SetString("name", info->name());
item->SetString("type", item->SetString("type",
ChildProcessInfo::GetTypeNameInEnglish(info->type())); ChildProcessInfo::GetTypeNameInEnglish(info->type()));
item->SetInteger("pid", base::GetProcId(info->handle())); item->SetInteger("pid", base::GetProcId(info->handle()));
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/importer/firefox_importer_utils.h" #include "chrome/browser/importer/firefox_importer_utils.h"
#include "chrome/browser/importer/profile_import_process_client.h" #include "chrome/browser/importer/profile_import_process_client.h"
...@@ -79,7 +80,7 @@ FilePath ProfileImportProcessHost::GetProfileImportProcessCmd() { ...@@ -79,7 +80,7 @@ FilePath ProfileImportProcessHost::GetProfileImportProcessCmd() {
} }
bool ProfileImportProcessHost::StartProcess() { bool ProfileImportProcessHost::StartProcess() {
set_name(L"profile import process"); set_name(ASCIIToUTF16("profile import process"));
if (!CreateChannel()) if (!CreateChannel())
return false; return false;
......
...@@ -97,7 +97,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() { ...@@ -97,7 +97,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() {
info.type = iter->type(); info.type = iter->type();
info.renderer_type = iter->renderer_type(); info.renderer_type = iter->renderer_type();
info.titles.push_back(WideToUTF16Hack(iter->name())); info.titles.push_back(iter->name());
child_info.push_back(info); child_info.push_back(info);
} }
......
...@@ -1503,7 +1503,7 @@ void MetricsService::LogChildProcessChange( ...@@ -1503,7 +1503,7 @@ void MetricsService::LogChildProcessChange(
const NotificationSource& source, const NotificationSource& source,
const NotificationDetails& details) { const NotificationDetails& details) {
Details<ChildProcessInfo> child_details(details); Details<ChildProcessInfo> child_details(details);
const std::wstring& child_name = child_details->name(); const string16& child_name = child_details->name();
if (child_process_stats_buffer_.find(child_name) == if (child_process_stats_buffer_.find(child_name) ==
child_process_stats_buffer_.end()) { child_process_stats_buffer_.end()) {
...@@ -1605,12 +1605,13 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { ...@@ -1605,12 +1605,13 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
} }
// TODO(viettrungluu): remove conversions // TODO(viettrungluu): remove conversions
if (child_process_stats_buffer_.find(UTF8ToWide(plugin_name)) == string16 name16 = UTF8ToUTF16(plugin_name);
child_process_stats_buffer_.end()) if (child_process_stats_buffer_.find(name16) ==
child_process_stats_buffer_.end()) {
continue; continue;
}
ChildProcessStats stats = ChildProcessStats stats = child_process_stats_buffer_[name16];
child_process_stats_buffer_[UTF8ToWide(plugin_name)];
if (stats.process_launches) { if (stats.process_launches) {
int launches = 0; int launches = 0;
plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches); plugin_dict->GetInteger(prefs::kStabilityPluginLaunches, &launches);
...@@ -1630,12 +1631,12 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { ...@@ -1630,12 +1631,12 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances); plugin_dict->SetInteger(prefs::kStabilityPluginInstances, instances);
} }
child_process_stats_buffer_.erase(UTF8ToWide(plugin_name)); child_process_stats_buffer_.erase(name16);
} }
// Now go through and add dictionaries for plugins that didn't already have // Now go through and add dictionaries for plugins that didn't already have
// reports in Local State. // reports in Local State.
for (std::map<std::wstring, ChildProcessStats>::iterator cache_iter = for (std::map<string16, ChildProcessStats>::iterator cache_iter =
child_process_stats_buffer_.begin(); child_process_stats_buffer_.begin();
cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { cache_iter != child_process_stats_buffer_.end(); ++cache_iter) {
ChildProcessStats stats = cache_iter->second; ChildProcessStats stats = cache_iter->second;
...@@ -1645,7 +1646,7 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { ...@@ -1645,7 +1646,7 @@ void MetricsService::RecordPluginChanges(PrefService* pref) {
continue; continue;
// TODO(viettrungluu): remove conversion // TODO(viettrungluu): remove conversion
std::string plugin_name = WideToUTF8(cache_iter->first); std::string plugin_name = UTF16ToUTF8(cache_iter->first);
DictionaryValue* plugin_dict = new DictionaryValue; DictionaryValue* plugin_dict = new DictionaryValue;
......
...@@ -402,7 +402,7 @@ class MetricsService : public NotificationObserver, ...@@ -402,7 +402,7 @@ class MetricsService : public NotificationObserver,
// Buffer of child process notifications for quick access. See // Buffer of child process notifications for quick access. See
// ChildProcessStats documentation above for more details. // ChildProcessStats documentation above for more details.
struct ChildProcessStats; struct ChildProcessStats;
std::map<std::wstring, ChildProcessStats> child_process_stats_buffer_; std::map<string16, ChildProcessStats> child_process_stats_buffer_;
ScopedRunnableMethodFactory<MetricsService> log_sender_factory_; ScopedRunnableMethodFactory<MetricsService> log_sender_factory_;
ScopedRunnableMethodFactory<MetricsService> state_saver_factory_; ScopedRunnableMethodFactory<MetricsService> state_saver_factory_;
......
...@@ -56,7 +56,7 @@ NaClProcessHost::NaClProcessHost(const std::wstring& url) ...@@ -56,7 +56,7 @@ NaClProcessHost::NaClProcessHost(const std::wstring& url)
internal_(new NaClInternal()), internal_(new NaClInternal()),
running_on_wow64_(false), running_on_wow64_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
set_name(url); set_name(WideToUTF16Hack(url));
#if defined(OS_WIN) #if defined(OS_WIN)
running_on_wow64_ = (base::win::OSInfo::GetInstance()->wow64_status() == running_on_wow64_ = (base::win::OSInfo::GetInstance()->wow64_status() ==
base::win::OSInfo::WOW64_ENABLED); base::win::OSInfo::WOW64_ENABLED);
......
...@@ -772,14 +772,14 @@ void TaskManagerChildProcessResource::SetSupportNetworkUsage() { ...@@ -772,14 +772,14 @@ void TaskManagerChildProcessResource::SetSupportNetworkUsage() {
} }
string16 TaskManagerChildProcessResource::GetLocalizedTitle() const { string16 TaskManagerChildProcessResource::GetLocalizedTitle() const {
string16 title = WideToUTF16Hack(child_process_.name()); string16 title = child_process_.name();
if (child_process_.type() == ChildProcessInfo::PLUGIN_PROCESS && if (child_process_.type() == ChildProcessInfo::PLUGIN_PROCESS &&
title.empty()) { title.empty()) {
title = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME); title = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME);
} }
// Explicitly mark name as LTR if there is no strong RTL character, // Explicitly mark name as LTR if there is no strong RTL character,
// to avoid the wrong concatenation result similar to "!Yahoo! Mail: the // to avoid the wrong concatenation result similar to "!Yahoo Mail: the
// best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew // best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew
// or Arabic word for "plugin". // or Arabic word for "plugin".
base::i18n::AdjustStringForLocaleDirection(&title); base::i18n::AdjustStringForLocaleDirection(&title);
...@@ -801,8 +801,7 @@ string16 TaskManagerChildProcessResource::GetLocalizedTitle() const { ...@@ -801,8 +801,7 @@ string16 TaskManagerChildProcessResource::GetLocalizedTitle() const {
case ChildProcessInfo::PPAPI_PLUGIN_PROCESS: case ChildProcessInfo::PPAPI_PLUGIN_PROCESS:
case ChildProcessInfo::PPAPI_BROKER_PROCESS: { case ChildProcessInfo::PPAPI_BROKER_PROCESS: {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_TASK_MANAGER_PLUGIN_PREFIX, title, IDS_TASK_MANAGER_PLUGIN_PREFIX, title, child_process_.version());
WideToUTF16Hack(child_process_.version()));
} }
case ChildProcessInfo::NACL_LOADER_PROCESS: case ChildProcessInfo::NACL_LOADER_PROCESS:
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/message_loop_proxy.h" #include "base/message_loop_proxy.h"
#include "base/scoped_temp_dir.h" #include "base/scoped_temp_dir.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_utility_messages.h" #include "chrome/common/chrome_utility_messages.h"
#include "ipc/ipc_switches.h" #include "ipc/ipc_switches.h"
...@@ -94,7 +95,7 @@ bool ServiceUtilityProcessHost::StartProcess(bool no_sandbox, ...@@ -94,7 +95,7 @@ bool ServiceUtilityProcessHost::StartProcess(bool no_sandbox,
const FilePath& exposed_dir) { const FilePath& exposed_dir) {
// Name must be set or metrics_service will crash in any test which // Name must be set or metrics_service will crash in any test which
// launches a UtilityProcessHost. // launches a UtilityProcessHost.
set_name(L"utility process"); set_name(ASCIIToUTF16("utility process"));
if (!CreateChannel()) if (!CreateChannel())
return false; return false;
......
...@@ -155,8 +155,8 @@ PluginProcessHost::~PluginProcessHost() { ...@@ -155,8 +155,8 @@ PluginProcessHost::~PluginProcessHost() {
bool PluginProcessHost::Init(const webkit::npapi::WebPluginInfo& info, bool PluginProcessHost::Init(const webkit::npapi::WebPluginInfo& info,
const std::string& locale) { const std::string& locale) {
info_ = info; info_ = info;
set_name(UTF16ToWideHack(info_.name)); set_name(info_.name);
set_version(UTF16ToWideHack(info_.version)); set_version(info_.version);
if (!CreateChannel()) if (!CreateChannel())
return false; return false;
......
...@@ -25,8 +25,8 @@ PpapiBrokerProcessHost::~PpapiBrokerProcessHost() { ...@@ -25,8 +25,8 @@ PpapiBrokerProcessHost::~PpapiBrokerProcessHost() {
bool PpapiBrokerProcessHost::Init(const PepperPluginInfo& info) { bool PpapiBrokerProcessHost::Init(const PepperPluginInfo& info) {
broker_path_ = info.path; broker_path_ = info.path;
set_name(UTF8ToWide(info.name)); set_name(UTF8ToUTF16(info.name));
set_version(UTF8ToWide(info.version)); set_version(UTF8ToUTF16(info.version));
if (!CreateChannel()) if (!CreateChannel())
return false; return false;
......
...@@ -31,8 +31,8 @@ PpapiPluginProcessHost::~PpapiPluginProcessHost() { ...@@ -31,8 +31,8 @@ PpapiPluginProcessHost::~PpapiPluginProcessHost() {
bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
plugin_path_ = info.path; plugin_path_ = info.path;
set_name(UTF8ToWide(info.name)); set_name(UTF8ToUTF16(info.name));
set_version(UTF8ToWide(info.version)); set_version(UTF8ToUTF16(info.version));
if (!CreateChannel()) if (!CreateChannel())
return false; return false;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "content/browser/content_browser_client.h" #include "content/browser/content_browser_client.h"
#include "content/common/content_switches.h" #include "content/common/content_switches.h"
#include "content/common/utility_messages.h" #include "content/common/utility_messages.h"
...@@ -72,7 +73,7 @@ bool UtilityProcessHost::StartProcess() { ...@@ -72,7 +73,7 @@ bool UtilityProcessHost::StartProcess() {
return true; return true;
// Name must be set or metrics_service will crash in any test which // Name must be set or metrics_service will crash in any test which
// launches a UtilityProcessHost. // launches a UtilityProcessHost.
set_name(L"utility process"); set_name(ASCIIToUTF16("utility process"));
if (!CreateChannel()) if (!CreateChannel())
return false; return false;
......
...@@ -485,7 +485,7 @@ void WorkerProcessHost::UpdateTitle() { ...@@ -485,7 +485,7 @@ void WorkerProcessHost::UpdateTitle() {
display_title += *i; display_title += *i;
} }
set_name(ASCIIToWide(display_title)); set_name(ASCIIToUTF16(display_title));
} }
void WorkerProcessHost::DocumentDetached(WorkerMessageFilter* filter, void WorkerProcessHost::DocumentDetached(WorkerMessageFilter* filter,
......
...@@ -60,11 +60,11 @@ class ChildProcessInfo { ...@@ -60,11 +60,11 @@ class ChildProcessInfo {
// Returns the name of the process. i.e. for plugins it might be Flash, while // Returns the name of the process. i.e. for plugins it might be Flash, while
// for workers it might be the domain that it's from. // for workers it might be the domain that it's from.
std::wstring name() const { return name_; } const string16& name() const { return name_; }
// Returns the version of the exe, this only appliest to plugins. Otherwise // Returns the version of the exe, this only appliest to plugins. Otherwise
// the string is empty. // the string is empty.
std::wstring version() const { return version_; } const string16& version() const { return version_; }
// Getter to the process handle. // Getter to the process handle.
base::ProcessHandle handle() const { return process_.handle(); } base::ProcessHandle handle() const { return process_.handle(); }
...@@ -120,15 +120,15 @@ class ChildProcessInfo { ...@@ -120,15 +120,15 @@ class ChildProcessInfo {
void set_type(ProcessType type) { type_ = type; } void set_type(ProcessType type) { type_ = type; }
void set_renderer_type(RendererProcessType type) { renderer_type_ = type; } void set_renderer_type(RendererProcessType type) { renderer_type_ = type; }
void set_name(const std::wstring& name) { name_ = name; } void set_name(const string16& name) { name_ = name; }
void set_version(const std::wstring& ver) { version_ = ver; } void set_version(const string16& ver) { version_ = ver; }
void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); } void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); }
private: private:
ProcessType type_; ProcessType type_;
RendererProcessType renderer_type_; RendererProcessType renderer_type_;
std::wstring name_; string16 name_;
std::wstring version_; string16 version_;
int id_; int id_;
// The handle to the process. // The handle to the process.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment