summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/mach_broker_mac.cc2
-rw-r--r--chrome/browser/memory_details.h2
-rw-r--r--chrome/browser/metrics/metrics_service.cc2
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc2
-rw-r--r--chrome/browser/service/service_process_control.cc2
-rw-r--r--chrome/browser/task_manager/task_manager_resource_providers.cc56
-rw-r--r--chrome/browser/task_manager/task_manager_resource_providers.h6
-rw-r--r--chrome/chrome_common.gypi4
-rw-r--r--chrome/common/child_process_host.cc231
-rw-r--r--chrome/common/child_process_host.h126
-rw-r--r--chrome/common/child_process_info.cc191
-rw-r--r--chrome/common/child_process_info.h141
-rw-r--r--chrome/common/debug_flags.h2
-rw-r--r--chrome/common/sandbox_policy.cc2
-rw-r--r--chrome/common/service_process_util.cc2
-rw-r--r--chrome/common/service_process_util_mac.mm2
-rw-r--r--chrome/service/service_child_process_host.h4
-rw-r--r--chrome/test/automation/proxy_launcher.cc2
18 files changed, 72 insertions, 707 deletions
diff --git a/chrome/browser/mach_broker_mac.cc b/chrome/browser/mach_broker_mac.cc
index e311895..f7707c7 100644
--- a/chrome/browser/mach_broker_mac.cc
+++ b/chrome/browser/mach_broker_mac.cc
@@ -11,10 +11,10 @@
#include "base/sys_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/common/child_process_info.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_process_host.h"
+#include "content/common/child_process_info.h"
#include "content/common/notification_service.h"
namespace {
diff --git a/chrome/browser/memory_details.h b/chrome/browser/memory_details.h
index 9333b56..81d5796 100644
--- a/chrome/browser/memory_details.h
+++ b/chrome/browser/memory_details.h
@@ -11,7 +11,7 @@
#include "base/process_util.h"
#include "base/ref_counted.h"
#include "base/string16.h"
-#include "chrome/common/child_process_info.h"
+#include "content/common/child_process_info.h"
// We collect data about each browser process. A browser may
// have multiple processes (of course!). Even IE has multiple
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index b3d24f3..a09ebf2 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -174,13 +174,13 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/common/child_process_info.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/guid.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "content/browser/renderer_host/render_process_host.h"
+#include "content/common/child_process_info.h"
#include "content/common/notification_service.h"
#include "libxml/xmlwriter.h"
#include "webkit/plugins/npapi/plugin_list.h"
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 31679d0..c58eef8 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -49,7 +49,6 @@
#include "chrome/browser/visitedlink/visitedlink_master.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/child_process_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/gpu_messages.h"
@@ -90,6 +89,7 @@
#include "content/browser/renderer_host/socket_stream_dispatcher_host.h"
#include "content/browser/speech/speech_input_dispatcher_host.h"
#include "content/browser/worker_host/worker_message_filter.h"
+#include "content/common/child_process_info.h"
#include "content/common/child_process_messages.h"
#include "content/common/notification_service.h"
#include "content/common/resource_messages.h"
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc
index 07ef872..bc9f344 100644
--- a/chrome/browser/service/service_process_control.cc
+++ b/chrome/browser/service/service_process_control.cc
@@ -13,11 +13,11 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/upgrade_detector.h"
-#include "chrome/common/child_process_host.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/service_messages.h"
#include "chrome/common/service_process_util.h"
#include "content/browser/browser_thread.h"
+#include "content/common/child_process_host.h"
#include "content/common/notification_service.h"
#include "ui/base/ui_base_switches.h"
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc
index 1917d00..e2e5d14 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager/task_manager_resource_providers.cc
@@ -642,7 +642,7 @@ TaskManagerChildProcessResource::~TaskManagerChildProcessResource() {
// TaskManagerResource methods:
string16 TaskManagerChildProcessResource::GetTitle() const {
if (title_.empty())
- title_ = child_process_.GetLocalizedTitle();
+ title_ = GetLocalizedTitle();
return title_;
}
@@ -693,6 +693,60 @@ void TaskManagerChildProcessResource::SetSupportNetworkUsage() {
network_usage_support_ = true;
}
+string16 TaskManagerChildProcessResource::GetLocalizedTitle() const {
+ string16 title = WideToUTF16Hack(child_process_.name());
+ if (child_process_.type() == ChildProcessInfo::PLUGIN_PROCESS &&
+ title.empty()) {
+ title = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME);
+ }
+
+ // Explicitly mark name as LTR if there is no strong RTL character,
+ // to avoid the wrong concatenation result similar to "!Yahoo! Mail: the
+ // best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew
+ // or Arabic word for "plugin".
+ base::i18n::AdjustStringForLocaleDirection(&title);
+
+ switch (child_process_.type()) {
+ case ChildProcessInfo::UTILITY_PROCESS:
+ return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX);
+
+ case ChildProcessInfo::PROFILE_IMPORT_PROCESS:
+ return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX);
+
+ case ChildProcessInfo::GPU_PROCESS:
+ return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_GPU_PREFIX);
+
+ case ChildProcessInfo::NACL_BROKER_PROCESS:
+ return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NACL_BROKER_PREFIX);
+
+ case ChildProcessInfo::PLUGIN_PROCESS:
+ case ChildProcessInfo::PPAPI_PLUGIN_PROCESS: {
+ return l10n_util::GetStringFUTF16(
+ IDS_TASK_MANAGER_PLUGIN_PREFIX, title,
+ WideToUTF16Hack(child_process_.version()));
+ }
+
+ case ChildProcessInfo::NACL_LOADER_PROCESS:
+ return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NACL_PREFIX, title);
+
+ case ChildProcessInfo::WORKER_PROCESS:
+ return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title);
+
+ // These types don't need display names or get them from elsewhere.
+ case ChildProcessInfo::BROWSER_PROCESS:
+ case ChildProcessInfo::RENDER_PROCESS:
+ case ChildProcessInfo::ZYGOTE_PROCESS:
+ case ChildProcessInfo::SANDBOX_HELPER_PROCESS:
+ NOTREACHED();
+ break;
+
+ case ChildProcessInfo::UNKNOWN_PROCESS:
+ NOTREACHED() << "Need localized name for child process type.";
+ }
+
+ return title;
+}
+
////////////////////////////////////////////////////////////////////////////////
// TaskManagerChildProcessResourceProvider class
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.h b/chrome/browser/task_manager/task_manager_resource_providers.h
index c1ce1eb..2f2972e 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.h
+++ b/chrome/browser/task_manager/task_manager_resource_providers.h
@@ -13,9 +13,9 @@
#include "base/compiler_specific.h"
#include "base/process_util.h"
#include "chrome/browser/task_manager/task_manager.h"
-#include "chrome/common/child_process_info.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
+#include "content/common/child_process_info.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
class BackgroundContents;
@@ -224,6 +224,10 @@ class TaskManagerChildProcessResource : public TaskManager::Resource {
int process_id() const { return pid_; }
private:
+ // Returns a localized title for the child process. For example, a plugin
+ // process would be "Plug-in: Flash" when name is "Flash".
+ string16 GetLocalizedTitle() const;
+
ChildProcessInfo child_process_;
int pid_;
mutable string16 title_;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index f1a6c1c..fa8295b 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -31,8 +31,6 @@
'common/auto_start_linux.h',
'common/autofill_messages.h',
'common/bindings_policy.h',
- 'common/child_process_info.cc',
- 'common/child_process_info.h',
'common/child_process_logging.h',
'common/child_process_logging_linux.cc',
'common/child_process_logging_mac.mm',
@@ -219,8 +217,6 @@
'common/automation_messages_internal.h',
'common/badge_util.cc',
'common/badge_util.h',
- 'common/child_process_host.cc',
- 'common/child_process_host.h',
'common/chrome_descriptors.h',
'common/chrome_plugin_api.h',
'common/chrome_plugin_lib.cc',
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
deleted file mode 100644
index 8fa711b..0000000
--- a/chrome/common/child_process_host.cc
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/child_process_host.h"
-
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/metrics/histogram.h"
-#include "base/path_service.h"
-#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
-#include "chrome/common/child_process_info.h"
-#include "content/common/child_process_messages.h"
-#include "content/common/content_paths.h"
-#include "content/common/content_switches.h"
-#include "ipc/ipc_logging.h"
-
-#if defined(OS_LINUX)
-#include "base/linux_util.h"
-#endif // OS_LINUX
-
-ChildProcessHost::ChildProcessHost()
- : ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
- opening_channel_(false) {
-}
-
-ChildProcessHost::~ChildProcessHost() {
- for (size_t i = 0; i < filters_.size(); ++i) {
- filters_[i]->OnChannelClosing();
- filters_[i]->OnFilterRemoved();
- }
-}
-
-void ChildProcessHost::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
- filters_.push_back(filter);
-
- if (channel_.get())
- filter->OnFilterAdded(channel_.get());
-}
-
-// static
-FilePath ChildProcessHost::GetChildPath(bool allow_self) {
- FilePath child_path;
-
- child_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
- switches::kBrowserSubprocessPath);
- if (!child_path.empty())
- return child_path;
-
-#if defined(OS_LINUX)
- // Use /proc/self/exe rather than our known binary path so updates
- // can't swap out the binary from underneath us.
- // When running under Valgrind, forking /proc/self/exe ends up forking the
- // Valgrind executable, which then crashes. However, it's almost safe to
- // assume that the updates won't happen while testing with Valgrind tools.
- if (allow_self && !RunningOnValgrind())
- return FilePath("/proc/self/exe");
-#endif
-
- // On most platforms, the child executable is the same as the current
- // executable.
- PathService::Get(content::CHILD_PROCESS_EXE, &child_path);
- return child_path;
-}
-
-#if defined(OS_WIN)
-// static
-void ChildProcessHost::PreCacheFont(LOGFONT font) {
- // If a child process is running in a sandbox, GetTextMetrics()
- // can sometimes fail. If a font has not been loaded
- // previously, GetTextMetrics() will try to load the font
- // from the font file. However, the sandboxed process does
- // not have permissions to access any font files and
- // the call fails. So we make the browser pre-load the
- // font for us by using a dummy call to GetTextMetrics of
- // the same font.
-
- // Maintain a circular queue for the fonts and DCs to be cached.
- // font_index maintains next available location in the queue.
- static const int kFontCacheSize = 32;
- static HFONT fonts[kFontCacheSize] = {0};
- static HDC hdcs[kFontCacheSize] = {0};
- static size_t font_index = 0;
-
- UMA_HISTOGRAM_COUNTS_100("Memory.CachedFontAndDC",
- fonts[kFontCacheSize-1] ? kFontCacheSize : static_cast<int>(font_index));
-
- HDC hdc = GetDC(NULL);
- HFONT font_handle = CreateFontIndirect(&font);
- DCHECK(NULL != font_handle);
-
- HGDIOBJ old_font = SelectObject(hdc, font_handle);
- DCHECK(NULL != old_font);
-
- TEXTMETRIC tm;
- BOOL ret = GetTextMetrics(hdc, &tm);
- DCHECK(ret);
-
- if (fonts[font_index] || hdcs[font_index]) {
- // We already have too many fonts, we will delete one and take it's place.
- DeleteObject(fonts[font_index]);
- ReleaseDC(NULL, hdcs[font_index]);
- }
-
- fonts[font_index] = font_handle;
- hdcs[font_index] = hdc;
- font_index = (font_index + 1) % kFontCacheSize;
-}
-#endif // OS_WIN
-
-
-bool ChildProcessHost::CreateChannel() {
- channel_id_ = ChildProcessInfo::GenerateRandomChannelID(this);
- channel_.reset(new IPC::Channel(
- channel_id_, IPC::Channel::MODE_SERVER, &listener_));
- if (!channel_->Connect())
- return false;
-
- for (size_t i = 0; i < filters_.size(); ++i)
- filters_[i]->OnFilterAdded(channel_.get());
-
- // Make sure these messages get sent first.
-#if defined(IPC_MESSAGE_LOG_ENABLED)
- bool enabled = IPC::Logging::GetInstance()->Enabled();
- Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled));
-#endif
-
- Send(new ChildProcessMsg_AskBeforeShutdown());
-
- opening_channel_ = true;
-
- return true;
-}
-
-void ChildProcessHost::InstanceCreated() {
- Notify(NotificationType::CHILD_INSTANCE_CREATED);
-}
-
-bool ChildProcessHost::OnMessageReceived(const IPC::Message& msg) {
- return false;
-}
-
-void ChildProcessHost::OnChannelConnected(int32 peer_pid) {
-}
-
-void ChildProcessHost::OnChannelError() {
-}
-
-bool ChildProcessHost::Send(IPC::Message* message) {
- if (!channel_.get()) {
- delete message;
- return false;
- }
- return channel_->Send(message);
-}
-
-void ChildProcessHost::OnChildDied() {
- delete this;
-}
-
-void ChildProcessHost::ShutdownStarted() {
-}
-
-void ChildProcessHost::Notify(NotificationType type) {
-}
-
-ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
- : host_(host) {
-}
-
-bool ChildProcessHost::ListenerHook::OnMessageReceived(
- const IPC::Message& msg) {
-#ifdef IPC_MESSAGE_LOG_ENABLED
- IPC::Logging* logger = IPC::Logging::GetInstance();
- if (msg.type() == IPC_LOGGING_ID) {
- logger->OnReceivedLoggingMessage(msg);
- return true;
- }
-
- if (logger->Enabled())
- logger->OnPreDispatchMessage(msg);
-#endif
-
- bool handled = false;
- for (size_t i = 0; i < host_->filters_.size(); ++i) {
- if (host_->filters_[i]->OnMessageReceived(msg)) {
- handled = true;
- break;
- }
- }
-
- if (!handled && msg.type() == ChildProcessHostMsg_ShutdownRequest::ID) {
- if (host_->CanShutdown())
- host_->Send(new ChildProcessMsg_Shutdown());
- handled = true;
- }
-
- if (!handled)
- handled = host_->OnMessageReceived(msg);
-
-#ifdef IPC_MESSAGE_LOG_ENABLED
- if (logger->Enabled())
- logger->OnPostDispatchMessage(msg, host_->channel_id_);
-#endif
- return handled;
-}
-
-void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
- host_->opening_channel_ = false;
- host_->OnChannelConnected(peer_pid);
- // Notify in the main loop of the connection.
- host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED);
-
- for (size_t i = 0; i < host_->filters_.size(); ++i)
- host_->filters_[i]->OnChannelConnected(peer_pid);
-}
-
-void ChildProcessHost::ListenerHook::OnChannelError() {
- host_->opening_channel_ = false;
- host_->OnChannelError();
-
- for (size_t i = 0; i < host_->filters_.size(); ++i)
- host_->filters_[i]->OnChannelError();
-
- // This will delete host_, which will also destroy this!
- host_->OnChildDied();
-}
-
-void ChildProcessHost::ForceShutdown() {
- Send(new ChildProcessMsg_Shutdown());
-}
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
deleted file mode 100644
index 08f585e..0000000
--- a/chrome/common/child_process_host.h
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_CHILD_PROCESS_HOST_H_
-#define CHROME_COMMON_CHILD_PROCESS_HOST_H_
-#pragma once
-
-#include <string>
-#include <vector>
-
-#include "build/build_config.h"
-
-#if defined(OS_WIN)
-#include <windows.h>
-#endif // defined(OS_WIN)
-
-#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
-#include "chrome/common/notification_type.h"
-#include "ipc/ipc_channel_proxy.h"
-
-class CommandLine;
-class FilePath;
-
-namespace IPC {
-class Message;
-}
-
-// Provides common functionality for hosting a child process and processing IPC
-// messages between the host and the child process. Subclasses are responsible
-// for the actual launching and terminating of the child processes.
-class ChildProcessHost : public IPC::Channel::Listener,
- public IPC::Message::Sender {
- public:
- virtual ~ChildProcessHost();
-
- // Returns the pathname to be used for a child process. If a subprocess
- // pathname was specified on the command line, that will be used. Otherwise,
- // the default child process pathname will be returned. On most platforms,
- // this will be the same as the currently-executing process.
- //
- // The argument allow_self is used on Linux to indicate that we allow us to
- // fork from /proc/self/exe rather than using the "real" app path. This
- // prevents autoupdate from confusing us if it changes the file out from
- // under us. You will generally want to set this to true, except when there
- // is an override to the command line (for example, we're forking a renderer
- // in gdb). In this case, you'd use GetChildPath to get the real executable
- // file name, and then prepend the GDB command to the command line.
- //
- // On failure, returns an empty FilePath.
- static FilePath GetChildPath(bool allow_self);
-
-#if defined(OS_WIN)
- // See comments in the cc file. This is a common hack needed for a process
- // hosting a sandboxed child process. Hence it lives in this file.
- static void PreCacheFont(LOGFONT font);
-#endif // defined(OS_WIN)
-
- // IPC::Message::Sender implementation.
- virtual bool Send(IPC::Message* message);
-
- protected:
- ChildProcessHost();
-
- // Adds an IPC message filter. A reference will be kept to the filter.
- void AddFilter(IPC::ChannelProxy::MessageFilter* filter);
-
- // Derived classes return true if it's ok to shut down the child process.
- virtual bool CanShutdown() = 0;
-
- // Send the shutdown message to the child process.
- // Does not check if CanShutdown is true.
- virtual void ForceShutdown();
-
- // Creates the IPC channel. Returns true iff it succeeded.
- virtual bool CreateChannel();
-
- // Notifies us that an instance has been created on this child process.
- virtual void InstanceCreated();
-
- // IPC::Channel::Listener implementation:
- virtual bool OnMessageReceived(const IPC::Message& msg);
- virtual void OnChannelConnected(int32 peer_pid);
- virtual void OnChannelError();
-
- bool opening_channel() { return opening_channel_; }
- const std::string& channel_id() { return channel_id_; }
- IPC::Channel* channel() { return channel_.get(); }
-
- // Called when the child process goes away.
- virtual void OnChildDied();
- // Notifies the derived class that we told the child process to kill itself.
- virtual void ShutdownStarted();
- // Subclasses can implement specific notification methods.
- virtual void Notify(NotificationType type);
-
- private:
- // By using an internal class as the IPC::Channel::Listener, we can intercept
- // OnMessageReceived/OnChannelConnected and do our own processing before
- // calling the subclass' implementation.
- class ListenerHook : public IPC::Channel::Listener {
- public:
- explicit ListenerHook(ChildProcessHost* host);
- virtual bool OnMessageReceived(const IPC::Message& msg);
- virtual void OnChannelConnected(int32 peer_pid);
- virtual void OnChannelError();
- private:
- ChildProcessHost* host_;
- };
-
- ListenerHook listener_;
-
- bool opening_channel_; // True while we're waiting the channel to be opened.
- scoped_ptr<IPC::Channel> channel_;
- std::string channel_id_;
-
- // Holds all the IPC message filters. Since this object lives on the IO
- // thread, we don't have a IPC::ChannelProxy and so we manage filters
- // manually.
- std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_;
-
- DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
-};
-
-#endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_
diff --git a/chrome/common/child_process_info.cc b/chrome/common/child_process_info.cc
deleted file mode 100644
index 9084646..0000000
--- a/chrome/common/child_process_info.cc
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/child_process_info.h"
-
-#include <limits>
-
-#include "base/atomicops.h"
-#include "base/i18n/rtl.h"
-#include "base/logging.h"
-#include "base/process_util.h"
-#include "base/rand_util.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-ChildProcessInfo::ChildProcessInfo(ProcessType type, int id) :
- type_(type),
- renderer_type_(RENDERER_UNKNOWN) {
- if (id == -1)
- id_ = GenerateChildProcessUniqueId();
- else
- id_ = id;
-}
-
-ChildProcessInfo::ChildProcessInfo(const ChildProcessInfo& original)
- : type_(original.type_),
- renderer_type_(original.renderer_type_),
- name_(original.name_),
- version_(original.version_),
- id_(original.id_),
- process_(original.process_) {
-}
-
-ChildProcessInfo::~ChildProcessInfo() {
-}
-
-ChildProcessInfo& ChildProcessInfo::operator=(
- const ChildProcessInfo& original) {
- if (&original != this) {
- type_ = original.type_;
- renderer_type_ = original.renderer_type_;
- name_ = original.name_;
- version_ = original.version_;
- id_ = original.id_;
- process_ = original.process_;
- }
- return *this;
-}
-
-// static
-std::string ChildProcessInfo::GetTypeNameInEnglish(
- ChildProcessInfo::ProcessType type) {
- switch (type) {
- case BROWSER_PROCESS:
- return "Browser";
- case RENDER_PROCESS:
- return "Tab";
- case PLUGIN_PROCESS:
- return "Plug-in";
- case WORKER_PROCESS:
- return "Web Worker";
- case UTILITY_PROCESS:
- return "Utility";
- case PROFILE_IMPORT_PROCESS:
- return "Profile Import helper";
- case ZYGOTE_PROCESS:
- return "Zygote";
- case SANDBOX_HELPER_PROCESS:
- return "Sandbox helper";
- case NACL_LOADER_PROCESS:
- return "Native Client module";
- case NACL_BROKER_PROCESS:
- return "Native Client broker";
- case GPU_PROCESS:
- return "GPU";
- case PPAPI_PLUGIN_PROCESS:
- return "Pepper Plugin";
- case UNKNOWN_PROCESS:
- default:
- DCHECK(false) << "Unknown child process type!";
- return "Unknown";
- }
-}
-
-// static
-std::string ChildProcessInfo::GetRendererTypeNameInEnglish(
- ChildProcessInfo::RendererProcessType type) {
- switch (type) {
- case RENDERER_NORMAL:
- return "Tab";
- case RENDERER_CHROME:
- return "Tab (Chrome)";
- case RENDERER_EXTENSION:
- return "Extension";
- case RENDERER_DEVTOOLS:
- return "Devtools";
- case RENDERER_INTERSTITIAL:
- return "Interstitial";
- case RENDERER_NOTIFICATION:
- return "Notification";
- case RENDERER_BACKGROUND_APP:
- return "Background App";
- case RENDERER_UNKNOWN:
- default:
- NOTREACHED() << "Unknown renderer process type!";
- return "Unknown";
- }
-}
-
-// static
-std::string ChildProcessInfo::GetFullTypeNameInEnglish(
- ChildProcessInfo::ProcessType type,
- ChildProcessInfo::RendererProcessType rtype) {
- if (type == RENDER_PROCESS)
- return GetRendererTypeNameInEnglish(rtype);
- return GetTypeNameInEnglish(type);
-}
-
-
-string16 ChildProcessInfo::GetLocalizedTitle() const {
- string16 title = WideToUTF16Hack(name_);
- if (type_ == ChildProcessInfo::PLUGIN_PROCESS && title.empty())
- title = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME);
-
- // Explicitly mark name as LTR if there is no strong RTL character,
- // to avoid the wrong concatenation result similar to "!Yahoo! Mail: the
- // best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew
- // or Arabic word for "plugin".
- base::i18n::AdjustStringForLocaleDirection(&title);
-
- switch (type_) {
- case ChildProcessInfo::UTILITY_PROCESS:
- return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX);
-
- case ChildProcessInfo::PROFILE_IMPORT_PROCESS:
- return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX);
-
- case ChildProcessInfo::GPU_PROCESS:
- return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_GPU_PREFIX);
-
- case ChildProcessInfo::NACL_BROKER_PROCESS:
- return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NACL_BROKER_PREFIX);
-
- case ChildProcessInfo::PLUGIN_PROCESS:
- case ChildProcessInfo::PPAPI_PLUGIN_PROCESS:
- return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PLUGIN_PREFIX,
- title,
- WideToUTF16Hack(version_));
-
- case ChildProcessInfo::NACL_LOADER_PROCESS:
- return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NACL_PREFIX, title);
-
- case ChildProcessInfo::WORKER_PROCESS:
- return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title);
-
- // These types don't need display names or get them from elsewhere.
- case BROWSER_PROCESS:
- case RENDER_PROCESS:
- case ZYGOTE_PROCESS:
- case SANDBOX_HELPER_PROCESS:
- NOTREACHED();
- break;
-
- case UNKNOWN_PROCESS:
- NOTREACHED() << "Need localized name for child process type.";
- }
-
- return title;
-}
-
-std::string ChildProcessInfo::GenerateRandomChannelID(void* instance) {
- // Note: the string must start with the current process id, this is how
- // child processes determine the pid of the parent.
- // Build the channel ID. This is composed of a unique identifier for the
- // parent browser process, an identifier for the child instance, and a random
- // component. We use a random component so that a hacked child process can't
- // cause denial of service by causing future named pipe creation to fail.
- return base::StringPrintf("%d.%p.%d",
- base::GetCurrentProcId(), instance,
- base::RandInt(0, std::numeric_limits<int>::max()));
-}
-
-// static
-int ChildProcessInfo::GenerateChildProcessUniqueId() {
- // This function must be threadsafe.
- static base::subtle::Atomic32 last_unique_child_id = 0;
- return base::subtle::NoBarrier_AtomicIncrement(&last_unique_child_id, 1);
-}
diff --git a/chrome/common/child_process_info.h b/chrome/common/child_process_info.h
deleted file mode 100644
index 8d4e60e..0000000
--- a/chrome/common/child_process_info.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_CHILD_PROCESS_INFO_H_
-#define CHROME_COMMON_CHILD_PROCESS_INFO_H_
-#pragma once
-
-#include <string>
-
-#include "base/process.h"
-#include "base/string16.h"
-
-// Holds information about a child process.
-class ChildProcessInfo {
- public:
- // NOTE: Do not remove or reorder the elements in this enum, and only add new
- // items at the end. We depend on these specific values in a histogram.
- enum ProcessType {
- UNKNOWN_PROCESS = 1,
- BROWSER_PROCESS,
- RENDER_PROCESS,
- PLUGIN_PROCESS,
- WORKER_PROCESS,
- NACL_LOADER_PROCESS,
- UTILITY_PROCESS,
- PROFILE_IMPORT_PROCESS,
- ZYGOTE_PROCESS,
- SANDBOX_HELPER_PROCESS,
- NACL_BROKER_PROCESS,
- GPU_PROCESS,
- PPAPI_PLUGIN_PROCESS
- };
-
- // NOTE: Do not remove or reorder the elements in this enum, and only add new
- // items at the end. We depend on these specific values in a histogram.
- enum RendererProcessType {
- RENDERER_UNKNOWN = 0,
- RENDERER_NORMAL,
- RENDERER_CHROME, // WebUI (chrome:// URL)
- RENDERER_EXTENSION, // chrome-extension://
- RENDERER_DEVTOOLS, // Web inspector
- RENDERER_INTERSTITIAL, // malware/phishing interstitial
- RENDERER_NOTIFICATION, // HTML notification bubble
- RENDERER_BACKGROUND_APP // hosted app background page
- };
-
- ChildProcessInfo(const ChildProcessInfo& original);
- virtual ~ChildProcessInfo();
-
- ChildProcessInfo& operator=(const ChildProcessInfo& original);
-
- // Returns the type of the process.
- ProcessType type() const { return type_; }
-
- // Returns the renderer subtype of this process.
- // Only valid if the type() is RENDER_PROCESS.
- RendererProcessType renderer_type() const { return renderer_type_; }
-
- // 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.
- std::wstring name() const { return name_; }
-
- // Returns the version of the exe, this only appliest to plugins. Otherwise
- // the string is empty.
- std::wstring version() const { return version_; }
-
- // Getter to the process handle.
- base::ProcessHandle handle() const { return process_.handle(); }
-
- // Getter to the process ID.
- int pid() const { return process_.pid(); }
-
- // The unique identifier for this child process. This identifier is NOT a
- // process ID, and will be unique for all types of child process for
- // one run of the browser.
- int id() const { return id_; }
-
- void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); }
-
- // Returns an English name of the process type, should only be used for non
- // user-visible strings, or debugging pages like about:memory.
- static std::string GetFullTypeNameInEnglish(ProcessType type,
- RendererProcessType rtype);
- static std::string GetTypeNameInEnglish(ProcessType type);
- static std::string GetRendererTypeNameInEnglish(RendererProcessType type);
-
- // Returns a localized title for the child process. For example, a plugin
- // process would be "Plug-in: Flash" when name is "Flash".
- string16 GetLocalizedTitle() const;
-
- // We define the < operator so that the ChildProcessInfo can be used as a key
- // in a std::map.
- bool operator <(const ChildProcessInfo& rhs) const {
- if (process_.handle() != rhs.process_.handle())
- return process_ .handle() < rhs.process_.handle();
- return false;
- }
-
- bool operator ==(const ChildProcessInfo& rhs) const {
- return process_.handle() == rhs.process_.handle();
- }
-
- // Generates a unique channel name for a child renderer/plugin process.
- // The "instance" pointer value is baked into the channel id.
- static std::string GenerateRandomChannelID(void* instance);
-
- // Returns a unique ID to identify a child process. On construction, this
- // function will be used to generate the id_, but it is also used to generate
- // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs
- // must be unique for all child processes.
- //
- // This function is threadsafe since RenderProcessHost is on the UI thread,
- // but normally this will be used on the IO thread.
- static int GenerateChildProcessUniqueId();
-
- protected:
- // Derived objects need to use this constructor so we know what type we are.
- // If the caller has already generated a unique ID for this child process,
- // it should pass it as the second argument. Otherwise, -1 should be passed
- // and a unique ID will be automatically generated.
- ChildProcessInfo(ProcessType type, int id);
-
- void set_type(ProcessType type) { type_ = type; }
- void set_renderer_type(RendererProcessType type) { renderer_type_ = type; }
- void set_name(const std::wstring& name) { name_ = name; }
- void set_version(const std::wstring& ver) { version_ = ver; }
- void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); }
-
- private:
- ProcessType type_;
- RendererProcessType renderer_type_;
- std::wstring name_;
- std::wstring version_;
- int id_;
-
- // The handle to the process.
- mutable base::Process process_;
-};
-
-#endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_
diff --git a/chrome/common/debug_flags.h b/chrome/common/debug_flags.h
index 9671e47..2f68aee 100644
--- a/chrome/common/debug_flags.h
+++ b/chrome/common/debug_flags.h
@@ -6,7 +6,7 @@
#define CHROME_COMMON_DEBUG_FLAGS_H__
#pragma once
-#include "chrome/common/child_process_info.h"
+#include "content/common/child_process_info.h"
class CommandLine;
diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc
index ca6efd0..319f181 100644
--- a/chrome/common/sandbox_policy.cc
+++ b/chrome/common/sandbox_policy.cc
@@ -17,11 +17,11 @@
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/win/windows_version.h"
-#include "chrome/common/child_process_info.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/debug_flags.h"
+#include "content/common/child_process_info.h"
#include "sandbox/src/sandbox.h"
static sandbox::BrokerServices* g_broker_services = NULL;
diff --git a/chrome/common/service_process_util.cc b/chrome/common/service_process_util.cc
index 89e9e9a..8120a28 100644
--- a/chrome/common/service_process_util.cc
+++ b/chrome/common/service_process_util.cc
@@ -17,12 +17,12 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/version.h"
-#include "chrome/common/child_process_host.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/service_process_util.h"
+#include "content/common/child_process_host.h"
#if !defined(OS_MACOSX)
diff --git a/chrome/common/service_process_util_mac.mm b/chrome/common/service_process_util_mac.mm
index 0f5746f..75b4b2a 100644
--- a/chrome/common/service_process_util_mac.mm
+++ b/chrome/common/service_process_util_mac.mm
@@ -18,10 +18,10 @@
#include "base/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/version.h"
-#include "chrome/common/child_process_host.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "content/common/child_process_host.h"
#include "third_party/GTM/Foundation/GTMServiceManagement.h"
namespace {
diff --git a/chrome/service/service_child_process_host.h b/chrome/service/service_child_process_host.h
index b69d3db..6834a0d 100644
--- a/chrome/service/service_child_process_host.h
+++ b/chrome/service/service_child_process_host.h
@@ -7,8 +7,8 @@
#pragma once
#include "base/process.h"
-#include "chrome/common/child_process_host.h"
-#include "chrome/common/child_process_info.h"
+#include "content/common/child_process_host.h"
+#include "content/common/child_process_info.h"
// Plugins/workers and other child processes that live on the IO thread should
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index 0539c7e..e6cd724 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -15,7 +15,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/common/automation_constants.h"
-#include "chrome/common/child_process_info.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/debug_flags.h"
@@ -26,6 +25,7 @@
#include "chrome/test/test_switches.h"
#include "chrome/test/automation/automation_proxy.h"
#include "chrome/test/ui/ui_test.h"
+#include "content/common/child_process_info.h"
namespace {