summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_provider.cc2
-rw-r--r--chrome/browser/browser.cc2
-rw-r--r--chrome/browser/browser_child_process_host.cc (renamed from chrome/browser/child_process_host.cc)179
-rw-r--r--chrome/browser/browser_child_process_host.h109
-rw-r--r--chrome/browser/browser_process_impl.cc4
-rw-r--r--chrome/browser/child_process_host.h161
-rw-r--r--chrome/browser/gpu_process_host.cc4
-rw-r--r--chrome/browser/gpu_process_host.h4
-rw-r--r--chrome/browser/io_thread.cc4
-rw-r--r--chrome/browser/memory_details.cc4
-rw-r--r--chrome/browser/memory_details_linux.cc2
-rw-r--r--chrome/browser/memory_details_mac.cc2
-rw-r--r--chrome/browser/memory_details_win.cc2
-rw-r--r--chrome/browser/nacl_host/nacl_broker_host_win.cc4
-rw-r--r--chrome/browser/nacl_host/nacl_broker_host_win.h4
-rw-r--r--chrome/browser/nacl_host/nacl_broker_service_win.cc3
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc14
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.h4
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc2
-rw-r--r--chrome/browser/plugin_process_host.cc4
-rw-r--r--chrome/browser/plugin_process_host.h4
-rw-r--r--chrome/browser/plugin_service.cc4
-rw-r--r--chrome/browser/profile_import_process_host.cc2
-rw-r--r--chrome/browser/profile_import_process_host.h10
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc3
-rw-r--r--chrome/browser/task_manager_resource_providers.cc4
-rw-r--r--chrome/browser/utility_process_host.cc2
-rw-r--r--chrome/browser/utility_process_host.h6
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc4
-rw-r--r--chrome/browser/worker_host/worker_process_host.h4
-rw-r--r--chrome/browser/worker_host/worker_service.cc20
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/child_process_host.cc143
-rw-r--r--chrome/common/child_process_host.h111
36 files changed, 473 insertions, 368 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 25091a2..7edc7c3 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1795,7 +1795,7 @@ void AutomationProvider::GetBrowserInfo(Browser* browser,
// Add all child processes in a list of dictionaries, one dictionary item
// per child process.
ListValue* child_processes = new ListValue;
- for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
+ for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
// Only add processes which are already started, since we need their handle.
if ((*iter)->handle() != base::kNullProcessHandle) {
ChildProcessInfo* info = *iter;
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index d14636b..832516c 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -95,8 +95,8 @@
#if defined(OS_WIN)
#include "app/win_util.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/cert_store.h"
-#include "chrome/browser/child_process_host.h"
#include "chrome/browser/download/save_package.h"
#include "chrome/browser/ssl/ssl_error_info.h"
#include "chrome/browser/shell_integration.h"
diff --git a/chrome/browser/child_process_host.cc b/chrome/browser/browser_child_process_host.cc
index 773f927..d700475 100644
--- a/chrome/browser/child_process_host.cc
+++ b/chrome/browser/browser_child_process_host.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "base/command_line.h"
-#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/histogram.h"
#include "base/logging.h"
@@ -21,7 +20,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_type.h"
#include "chrome/common/plugin_messages.h"
#include "chrome/common/process_watcher.h"
#include "chrome/common/result_codes.h"
@@ -43,7 +41,7 @@ extern std::string posix_guid;
namespace {
-typedef std::list<ChildProcessHost*> ChildProcessList;
+typedef std::list<BrowserChildProcessHost*> ChildProcessList;
// The NotificationTask is used to notify about plugin process connection/
// disconnection. It is needed because the notifications in the
@@ -68,17 +66,16 @@ class ChildNotificationTask : public Task {
} // namespace
-ChildProcessHost::ChildProcessHost(
+BrowserChildProcessHost::BrowserChildProcessHost(
ProcessType type, ResourceDispatcherHost* resource_dispatcher_host)
: Receiver(type, -1),
- ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
- resource_dispatcher_host_(resource_dispatcher_host),
- opening_channel_(false) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(client_(this)),
+ resource_dispatcher_host_(resource_dispatcher_host) {
Singleton<ChildProcessList>::get()->push_back(this);
}
-ChildProcessHost::~ChildProcessHost() {
+BrowserChildProcessHost::~BrowserChildProcessHost() {
Singleton<ChildProcessList>::get()->remove(this);
if (resource_dispatcher_host_)
@@ -86,36 +83,8 @@ ChildProcessHost::~ChildProcessHost() {
}
// 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_MACOSX)
- // On the Mac, the child executable lives at a predefined location within
- // the app bundle's versioned directory.
- return chrome::GetVersionedDirectory().
- Append(chrome::kHelperProcessExecutablePath);
-#endif
-
-#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.
- if (allow_self)
- return FilePath("/proc/self/exe");
-#endif
-
- // On most platforms, the child executable is the same as the current
- // executable.
- PathService::Get(base::FILE_EXE, &child_path);
- return child_path;
-}
-
-// static
-void ChildProcessHost::SetCrashReporterCommandLine(CommandLine* command_line) {
+void BrowserChildProcessHost::SetCrashReporterCommandLine(
+ CommandLine* command_line) {
#if defined(USE_LINUX_BREAKPAD)
const bool unattended = (getenv(env_vars::kHeadless) != NULL);
if (unattended || GoogleUpdateSettings::GetCollectStatsConsent()) {
@@ -132,13 +101,13 @@ void ChildProcessHost::SetCrashReporterCommandLine(CommandLine* command_line) {
}
// static
-void ChildProcessHost::TerminateAll() {
+void BrowserChildProcessHost::TerminateAll() {
// Make a copy since the ChildProcessHost dtor mutates the original list.
ChildProcessList copy = *(Singleton<ChildProcessList>::get());
STLDeleteElements(&copy);
}
-void ChildProcessHost::Launch(
+void BrowserChildProcessHost::Launch(
#if defined(OS_WIN)
const FilePath& exposed_dir,
#elif defined(OS_POSIX)
@@ -152,46 +121,31 @@ void ChildProcessHost::Launch(
#elif defined(OS_POSIX)
use_zygote,
environ,
- channel_->GetClientFileDescriptor(),
+ channel()->GetClientFileDescriptor(),
#endif
cmd_line,
- &listener_));
+ &client_));
}
-bool ChildProcessHost::CreateChannel() {
- channel_id_ = GenerateRandomChannelID(this);
- channel_.reset(new IPC::Channel(
- channel_id_, IPC::Channel::MODE_SERVER, &listener_));
- if (!channel_->Connect())
- return false;
-
- opening_channel_ = true;
-
- return true;
+bool BrowserChildProcessHost::Send(IPC::Message* msg) {
+ return SendOnChannel(msg);
}
-void ChildProcessHost::InstanceCreated() {
- Notify(NotificationType::CHILD_INSTANCE_CREATED);
-}
-
-bool ChildProcessHost::Send(IPC::Message* msg) {
- if (!channel_.get()) {
- delete msg;
- return false;
- }
- return channel_->Send(msg);
+void BrowserChildProcessHost::ForceShutdown() {
+ Singleton<ChildProcessList>::get()->remove(this);
+ ChildProcessHost::ForceShutdown();
}
-void ChildProcessHost::Notify(NotificationType type) {
+void BrowserChildProcessHost::Notify(NotificationType type) {
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE, new ChildNotificationTask(type, this));
}
-bool ChildProcessHost::DidChildCrash() {
+bool BrowserChildProcessHost::DidChildCrash() {
return child_process_->DidProcessCrash();
}
-void ChildProcessHost::OnChildDied() {
+void BrowserChildProcessHost::OnChildDied() {
if (handle() != base::kNullProcessHandle) {
bool did_crash = DidChildCrash();
if (did_crash) {
@@ -203,98 +157,48 @@ void ChildProcessHost::OnChildDied() {
// Notify in the main loop of the disconnection.
Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED);
}
-
- delete this;
-}
-
-ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
- : host_(host) {
+ ChildProcessHost::OnChildDied();
}
-void ChildProcessHost::ListenerHook::OnMessageReceived(
+bool BrowserChildProcessHost::InterceptMessageFromChild(
const IPC::Message& msg) {
-#ifdef IPC_MESSAGE_LOG_ENABLED
- IPC::Logging* logger = IPC::Logging::current();
- if (msg.type() == IPC_LOGGING_ID) {
- logger->OnReceivedLoggingMessage(msg);
- return;
- }
-
- if (logger->Enabled())
- logger->OnPreDispatchMessage(msg);
-#endif
-
bool msg_is_ok = true;
bool handled = false;
-
- if (host_->resource_dispatcher_host_) {
- handled = host_->resource_dispatcher_host_->OnMessageReceived(
- msg, host_, &msg_is_ok);
+ if (resource_dispatcher_host_) {
+ handled = resource_dispatcher_host_->OnMessageReceived(
+ msg, this, &msg_is_ok);
}
-
- if (!handled) {
- if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) {
- // Must remove the process from the list now, in case it gets used for a
- // new instance before our watcher tells us that the process terminated.
- Singleton<ChildProcessList>::get()->remove(host_);
- if (host_->CanShutdown())
- host_->Send(new PluginProcessMsg_Shutdown());
- } else {
- host_->OnMessageReceived(msg);
- }
+ if (!handled && (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID)) {
+ // Must remove the process from the list now, in case it gets used for a
+ // new instance before our watcher tells us that the process terminated.
+ Singleton<ChildProcessList>::get()->remove(this);
}
-
if (!msg_is_ok)
- base::KillProcess(host_->handle(), ResultCodes::KILLED_BAD_MESSAGE, false);
-
-#ifdef IPC_MESSAGE_LOG_ENABLED
- if (logger->Enabled())
- logger->OnPostDispatchMessage(msg, host_->channel_id_);
-#endif
+ base::KillProcess(handle(), ResultCodes::KILLED_BAD_MESSAGE, false);
+ return handled;
}
-void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
- host_->opening_channel_ = false;
- host_->OnChannelConnected(peer_pid);
-
-#if defined(IPC_MESSAGE_LOG_ENABLED)
- bool enabled = IPC::Logging::current()->Enabled();
- host_->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
-#endif
-
- host_->Send(new PluginProcessMsg_AskBeforeShutdown());
-
- // Notify in the main loop of the connection.
- host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED);
-}
-
-void ChildProcessHost::ListenerHook::OnChannelError() {
- host_->opening_channel_ = false;
- host_->OnChannelError();
-
- // This will delete host_, which will also destroy this!
- host_->OnChildDied();
+BrowserChildProcessHost::ClientHook::ClientHook(BrowserChildProcessHost* host)
+ : host_(host) {
}
-void ChildProcessHost::ListenerHook::OnProcessLaunched() {
+void BrowserChildProcessHost::ClientHook::OnProcessLaunched() {
if (!host_->child_process_->GetHandle()) {
- delete this;
+ host_->OnChildDied();
return;
}
-
host_->set_handle(host_->child_process_->GetHandle());
host_->OnProcessLaunched();
}
-
-ChildProcessHost::Iterator::Iterator()
+BrowserChildProcessHost::Iterator::Iterator()
: all_(true), type_(UNKNOWN_PROCESS) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
"ChildProcessInfo::Iterator must be used on the IO thread.";
iterator_ = Singleton<ChildProcessList>::get()->begin();
}
-ChildProcessHost::Iterator::Iterator(ProcessType type)
+BrowserChildProcessHost::Iterator::Iterator(ProcessType type)
: all_(false), type_(type) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
"ChildProcessInfo::Iterator must be used on the IO thread.";
@@ -303,7 +207,7 @@ ChildProcessHost::Iterator::Iterator(ProcessType type)
++(*this);
}
-ChildProcessHost* ChildProcessHost::Iterator::operator++() {
+BrowserChildProcessHost* BrowserChildProcessHost::Iterator::operator++() {
do {
++iterator_;
if (Done())
@@ -318,11 +222,6 @@ ChildProcessHost* ChildProcessHost::Iterator::operator++() {
return NULL;
}
-bool ChildProcessHost::Iterator::Done() {
+bool BrowserChildProcessHost::Iterator::Done() {
return iterator_ == Singleton<ChildProcessList>::get()->end();
}
-
-void ChildProcessHost::ForceShutdown() {
- Singleton<ChildProcessList>::get()->remove(this);
- Send(new PluginProcessMsg_Shutdown());
-}
diff --git a/chrome/browser/browser_child_process_host.h b/chrome/browser/browser_child_process_host.h
new file mode 100644
index 0000000..20a8f6b
--- /dev/null
+++ b/chrome/browser/browser_child_process_host.h
@@ -0,0 +1,109 @@
+// Copyright (c) 2009 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_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_
+#define CHROME_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_
+
+#include <list>
+
+#include "chrome/browser/child_process_launcher.h"
+#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
+#include "chrome/common/child_process_host.h"
+
+
+// Plugins/workers and other child processes that live on the IO thread should
+// derive from this class.
+//
+// [Browser]RenderProcessHost is the main exception that doesn't derive from
+// this class. That project lives on the UI thread.
+class BrowserChildProcessHost : public ResourceDispatcherHost::Receiver,
+ public ChildProcessHost,
+ public ChildProcessLauncher::Client {
+ public:
+ virtual ~BrowserChildProcessHost();
+
+ // Prepares command_line for crash reporting as appropriate. On Linux and
+ // Mac, a command-line flag to enable crash reporting in the child process
+ // will be appended if needed, because the child process may not have access
+ // to the data that determines the status of crash reporting in the
+ // currently-executing process. This function is a no-op on Windows.
+ static void SetCrashReporterCommandLine(CommandLine* command_line);
+
+ // Terminates all child processes and deletes each ChildProcessHost instance.
+ static void TerminateAll();
+
+ // ResourceDispatcherHost::Receiver implementation:
+ virtual bool Send(IPC::Message* msg);
+
+ // The Iterator class allows iteration through either all child processes, or
+ // ones of a specific type, depending on which constructor is used. Note that
+ // this should be done from the IO thread and that the iterator should not be
+ // kept around as it may be invalidated on subsequent event processing in the
+ // event loop.
+ class Iterator {
+ public:
+ Iterator();
+ explicit Iterator(ProcessType type);
+ BrowserChildProcessHost* operator->() { return *iterator_; }
+ BrowserChildProcessHost* operator*() { return *iterator_; }
+ BrowserChildProcessHost* operator++();
+ bool Done();
+
+ private:
+ bool all_;
+ ProcessType type_;
+ std::list<BrowserChildProcessHost*>::iterator iterator_;
+ };
+
+ protected:
+ // The resource_dispatcher_host may be NULL to indicate none is needed for
+ // this process type.
+ BrowserChildProcessHost(ProcessType type,
+ ResourceDispatcherHost* resource_dispatcher_host);
+
+ // Derived classes call this to launch the child process asynchronously.
+ void Launch(
+#if defined(OS_WIN)
+ const FilePath& exposed_dir,
+#elif defined(OS_POSIX)
+ bool use_zygote,
+ const base::environment_vector& environ,
+#endif
+ CommandLine* cmd_line);
+
+ // ChildProcessLauncher::Client implementation.
+ virtual void OnProcessLaunched() { }
+
+ // Derived classes can override this to know if the process crashed.
+ virtual void OnProcessCrashed() {}
+
+ virtual bool DidChildCrash();
+
+ // Overrides from ChildProcessHost
+ virtual void OnChildDied();
+ virtual bool InterceptMessageFromChild(const IPC::Message& msg);
+ virtual void Notify(NotificationType type);
+ // Extends the base class implementation and removes this host from
+ // the host list. Calls ChildProcessHost::ForceShutdown
+ virtual void ForceShutdown();
+
+ private:
+ // By using an internal class as the ChildProcessLauncher::Client, we can
+ // intercept OnProcessLaunched and do our own processing before
+ // calling the subclass' implementation.
+ class ClientHook : public ChildProcessLauncher::Client {
+ public:
+ explicit ClientHook(BrowserChildProcessHost* host);
+ virtual void OnProcessLaunched();
+ private:
+ BrowserChildProcessHost* host_;
+ };
+ ClientHook client_;
+ // May be NULL if this current process has no resource dispatcher host.
+ ResourceDispatcherHost* resource_dispatcher_host_;
+ scoped_ptr<ChildProcessLauncher> child_process_;
+};
+
+#endif // CHROME_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_
+
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 52421ff..6f93446 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -14,11 +14,11 @@
#include "base/thread.h"
#include "base/waitable_event.h"
#include "chrome/browser/appcache/chrome_appcache_service.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_main.h"
#include "chrome/browser/browser_process_sub_thread.h"
#include "chrome/browser/browser_trial.h"
-#include "chrome/browser/child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/debugger/debugger_wrapper.h"
#include "chrome/browser/debugger/devtools_manager.h"
@@ -509,7 +509,7 @@ void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
void BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses(bool enabled) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- ChildProcessHost::Iterator i; // default constr references a singleton
+ BrowserChildProcessHost::Iterator i; // default constr references a singleton
while (!i.Done()) {
i->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
++i;
diff --git a/chrome/browser/child_process_host.h b/chrome/browser/child_process_host.h
deleted file mode 100644
index b4f661b..0000000
--- a/chrome/browser/child_process_host.h
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright (c) 2009 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_BROWSER_CHILD_PROCESS_HOST_H_
-#define CHROME_BROWSER_CHILD_PROCESS_HOST_H_
-
-#include <list>
-#include <string>
-
-// Must be included early (e.g. before chrome/common/plugin_messages.h)
-#include "ipc/ipc_logging.h"
-
-#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
-#include "chrome/browser/child_process_launcher.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "ipc/ipc_channel.h"
-
-class CommandLine;
-class NotificationType;
-
-// Plugins/workers and other child processes that live on the IO thread should
-// derive from this class.
-//
-// [Browser]RenderProcessHost is the main exception that doesn't derive from
-// this class. That project lives on the UI thread.
-class ChildProcessHost : public ResourceDispatcherHost::Receiver,
- public IPC::Channel::Listener,
- public ChildProcessLauncher::Client {
- 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);
-
- // Prepares command_line for crash reporting as appropriate. On Linux and
- // Mac, a command-line flag to enable crash reporting in the child process
- // will be appended if needed, because the child process may not have access
- // to the data that determines the status of crash reporting in the
- // currently-executing process. This function is a no-op on Windows.
- static void SetCrashReporterCommandLine(CommandLine* command_line);
-
- // Terminates all child processes and deletes each ChildProcessHost instance.
- static void TerminateAll();
-
- // ResourceDispatcherHost::Receiver implementation:
- virtual bool Send(IPC::Message* msg);
-
- // The Iterator class allows iteration through either all child processes, or
- // ones of a specific type, depending on which constructor is used. Note that
- // this should be done from the IO thread and that the iterator should not be
- // kept around as it may be invalidated on subsequent event processing in the
- // event loop.
- class Iterator {
- public:
- Iterator();
- explicit Iterator(ProcessType type);
- ChildProcessHost* operator->() { return *iterator_; }
- ChildProcessHost* operator*() { return *iterator_; }
- ChildProcessHost* operator++();
- bool Done();
-
- private:
- bool all_;
- ProcessType type_;
- std::list<ChildProcessHost*>::iterator iterator_;
- };
-
- protected:
- // The resource_dispatcher_host may be NULL to indicate none is needed for
- // this process type.
- ChildProcessHost(ProcessType type,
- ResourceDispatcherHost* resource_dispatcher_host);
-
- // Derived classes call this to launch the child process asynchronously.
- void Launch(
-#if defined(OS_WIN)
- const FilePath& exposed_dir,
-#elif defined(OS_POSIX)
- bool use_zygote,
- const base::environment_vector& environ,
-#endif
- CommandLine* cmd_line);
-
- // 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, and remove this host from
- // the host list. Does not check if CanShutdown is true.
- void ForceShutdown();
-
- // Creates the IPC channel. Returns true iff it succeeded.
- bool CreateChannel();
-
- // Notifies us that an instance has been created on this child process.
- void InstanceCreated();
-
- // IPC::Channel::Listener implementation:
- virtual void OnMessageReceived(const IPC::Message& msg) { }
- virtual void OnChannelConnected(int32 peer_pid) { }
- virtual void OnChannelError() { }
-
- // ChildProcessLauncher::Client implementation.
- virtual void OnProcessLaunched() {}
-
- // Derived classes can override this to know if the process crashed.
- virtual void OnProcessCrashed() {}
-
- bool opening_channel() { return opening_channel_; }
- const std::string& channel_id() { return channel_id_; }
-
- virtual bool DidChildCrash();
-
- // Called when the child process goes away.
- virtual void OnChildDied();
-
- private:
- // Sends the given notification to the notification service on the UI thread.
- void Notify(NotificationType type);
-
- // 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 ChildProcessLauncher::Client {
- public:
- explicit ListenerHook(ChildProcessHost* host);
- virtual void OnMessageReceived(const IPC::Message& msg);
- virtual void OnChannelConnected(int32 peer_pid);
- virtual void OnChannelError();
- virtual void OnProcessLaunched();
- private:
- ChildProcessHost* host_;
- };
-
- ListenerHook listener_;
-
- // May be NULL if this current process has no resource dispatcher host.
- ResourceDispatcherHost* resource_dispatcher_host_;
-
- bool opening_channel_; // True while we're waiting the channel to be opened.
- scoped_ptr<IPC::Channel> channel_;
- std::string channel_id_;
- scoped_ptr<ChildProcessLauncher> child_process_;
-};
-
-#endif // CHROME_BROWSER_CHILD_PROCESS_HOST_H_
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc
index e18326b..efe347b 100644
--- a/chrome/browser/gpu_process_host.cc
+++ b/chrome/browser/gpu_process_host.cc
@@ -46,7 +46,7 @@ static GpuProcessHost* sole_instance_ = NULL;
} // anonymous namespace
GpuProcessHost::GpuProcessHost()
- : ChildProcessHost(GPU_PROCESS, NULL),
+ : BrowserChildProcessHost(GPU_PROCESS, NULL),
initialized_(false),
initialized_successfully_(false) {
DCHECK_EQ(sole_instance_, static_cast<GpuProcessHost*>(NULL));
@@ -117,7 +117,7 @@ bool GpuProcessHost::Send(IPC::Message* msg) {
if (!EnsureInitialized())
return false;
- return ChildProcessHost::Send(msg);
+ return BrowserChildProcessHost::Send(msg);
}
void GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h
index 9638f11..2085846 100644
--- a/chrome/browser/gpu_process_host.h
+++ b/chrome/browser/gpu_process_host.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "gfx/native_widget_types.h"
@@ -21,7 +21,7 @@ struct ChannelHandle;
class Message;
}
-class GpuProcessHost : public ChildProcessHost {
+class GpuProcessHost : public BrowserChildProcessHost {
public:
// Getter for the singleton. This will return NULL on failure.
static GpuProcessHost* Get();
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 13adde9..c451b25 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -139,9 +139,9 @@ void IOThread::Init() {
void IOThread::CleanUp() {
// If any child processes are still running, terminate them and
- // and delete the ChildProcessHost instances to release whatever
+ // and delete the BrowserChildProcessHost instances to release whatever
// IO thread only resources they are referencing.
- ChildProcessHost::TerminateAll();
+ BrowserChildProcessHost::TerminateAll();
// Not initialized in Init(). May not be initialized.
if (predictor_) {
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index 7c9a7d0..5106912 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -8,7 +8,7 @@
#include "base/file_version_info.h"
#include "base/process_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/renderer_host/backing_store_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
@@ -53,7 +53,7 @@ void MemoryDetails::CollectChildInfoOnIOThread() {
std::vector<ProcessMemoryInformation> child_info;
// Collect the list of child processes.
- for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
+ for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
ProcessMemoryInformation info;
info.pid = base::GetProcId(iter->handle());
if (!info.pid)
diff --git a/chrome/browser/memory_details_linux.cc b/chrome/browser/memory_details_linux.cc
index 8ba1863..bc230f1 100644
--- a/chrome/browser/memory_details_linux.cc
+++ b/chrome/browser/memory_details_linux.cc
@@ -13,8 +13,8 @@
#include "base/file_version_info.h"
#include "base/string_util.h"
#include "base/process_util.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/zygote_host_linux.h"
#include "chrome/common/chrome_constants.h"
diff --git a/chrome/browser/memory_details_mac.cc b/chrome/browser/memory_details_mac.cc
index bf58193..48e758b 100644
--- a/chrome/browser/memory_details_mac.cc
+++ b/chrome/browser/memory_details_mac.cc
@@ -16,8 +16,8 @@
#include "base/process_util.h"
#include "base/thread.h"
#include "chrome/app/chrome_version_info.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/process_info_snapshot.h"
#include "chrome/browser/renderer_host/backing_store_manager.h"
diff --git a/chrome/browser/memory_details_win.cc b/chrome/browser/memory_details_win.cc
index 84497ba..082bde5 100644
--- a/chrome/browser/memory_details_win.cc
+++ b/chrome/browser/memory_details_win.cc
@@ -9,7 +9,7 @@
#include "base/file_version_info.h"
#include "base/string_util.h"
#include "chrome/app/chrome_version_info.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/renderer_host/backing_store_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.cc b/chrome/browser/nacl_host/nacl_broker_host_win.cc
index eefbccd..f479030 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.cc
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.cc
@@ -17,7 +17,7 @@
NaClBrokerHost::NaClBrokerHost(
ResourceDispatcherHost* resource_dispatcher_host)
- : ChildProcessHost(NACL_BROKER_PROCESS, resource_dispatcher_host),
+ : BrowserChildProcessHost(NACL_BROKER_PROCESS, resource_dispatcher_host),
stopping_(false) {
}
@@ -50,7 +50,7 @@ bool NaClBrokerHost::Init() {
cmd_line->AppendSwitchWithValue(switches::kProcessChannelID,
ASCIIToWide(channel_id()));
- ChildProcessHost::Launch(FilePath(), cmd_line);
+ BrowserChildProcessHost::Launch(FilePath(), cmd_line);
return true;
}
diff --git a/chrome/browser/nacl_host/nacl_broker_host_win.h b/chrome/browser/nacl_host/nacl_broker_host_win.h
index 0bdc228..8668328 100644
--- a/chrome/browser/nacl_host/nacl_broker_host_win.h
+++ b/chrome/browser/nacl_host/nacl_broker_host_win.h
@@ -7,10 +7,10 @@
#include "base/basictypes.h"
#include "base/process.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "ipc/ipc_message.h"
-class NaClBrokerHost : public ChildProcessHost {
+class NaClBrokerHost : public BrowserChildProcessHost {
public:
explicit NaClBrokerHost(ResourceDispatcherHost* resource_dispatcher_host);
~NaClBrokerHost();
diff --git a/chrome/browser/nacl_host/nacl_broker_service_win.cc b/chrome/browser/nacl_host/nacl_broker_service_win.cc
index d1f7923..d5524ad 100644
--- a/chrome/browser/nacl_host/nacl_broker_service_win.cc
+++ b/chrome/browser/nacl_host/nacl_broker_service_win.cc
@@ -72,7 +72,8 @@ void NaClBrokerService::OnLoaderDied() {
}
NaClBrokerHost* NaClBrokerService::GetBrokerHost() {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::NACL_BROKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(
+ ChildProcessInfo::NACL_BROKER_PROCESS);
!iter.Done();
++iter) {
NaClBrokerHost* broker_host = static_cast<NaClBrokerHost*>(*iter);
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index f28d31a..fb844d8 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -28,7 +28,7 @@
NaClProcessHost::NaClProcessHost(
ResourceDispatcherHost *resource_dispatcher_host,
const std::wstring& url)
- : ChildProcessHost(NACL_LOADER_PROCESS, resource_dispatcher_host),
+ : BrowserChildProcessHost(NACL_LOADER_PROCESS, resource_dispatcher_host),
resource_dispatcher_host_(resource_dispatcher_host),
reply_msg_(NULL),
descriptor_(0),
@@ -99,12 +99,12 @@ bool NaClProcessHost::LaunchSelLdr() {
return NaClBrokerService::GetInstance()->LaunchLoader(this,
ASCIIToWide(channel_id()));
} else {
- ChildProcessHost::Launch(FilePath(), cmd_line);
+ BrowserChildProcessHost::Launch(FilePath(), cmd_line);
}
#elif defined(OS_POSIX)
- ChildProcessHost::Launch(true, // use_zygote
- base::environment_vector(),
- cmd_line);
+ BrowserChildProcessHost::Launch(true, // use_zygote
+ base::environment_vector(),
+ cmd_line);
#endif
return true;
@@ -118,14 +118,14 @@ void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) {
bool NaClProcessHost::DidChildCrash() {
if (running_on_wow64_)
return base::DidProcessCrash(NULL, handle());
- return ChildProcessHost::DidChildCrash();
+ return BrowserChildProcessHost::DidChildCrash();
}
void NaClProcessHost::OnChildDied() {
#if defined(OS_WIN)
NaClBrokerService::GetInstance()->OnLoaderDied();
#endif
- ChildProcessHost::OnChildDied();
+ BrowserChildProcessHost::OnChildDied();
}
void NaClProcessHost::OnProcessLaunched() {
diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h
index b09d471..cae117b 100644
--- a/chrome/browser/nacl_host/nacl_process_host.h
+++ b/chrome/browser/nacl_host/nacl_process_host.h
@@ -8,7 +8,7 @@
#include "build/build_config.h"
#include "base/ref_counted.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/common/nacl_types.h"
#include "native_client/src/shared/imc/nacl_imc.h"
@@ -20,7 +20,7 @@ class ResourceMessageFilter;
// when requested by the renderer.
// After that, most of the communication is directly between NaCl plugin
// running in the renderer and NaCl processes.
-class NaClProcessHost : public ChildProcessHost {
+class NaClProcessHost : public BrowserChildProcessHost {
public:
NaClProcessHost(ResourceDispatcherHost *resource_dispatcher_host,
const std::wstring& url);
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 103c0f1..56418da 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -8,7 +8,7 @@
#include "app/resource_bundle.h"
#include "base/thread.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/notifications/notification.h"
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index 409d6c0..5becc27 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -285,7 +285,7 @@ void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id,
#endif // defined(TOOLKIT_USES_GTK)
PluginProcessHost::PluginProcessHost()
- : ChildProcessHost(
+ : BrowserChildProcessHost(
PLUGIN_PROCESS,
PluginService::GetInstance()->resource_dispatcher_host()),
ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL))
@@ -456,7 +456,7 @@ bool PluginProcessHost::Init(const WebPluginInfo& info,
void PluginProcessHost::ForceShutdown() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
Send(new PluginProcessMsg_NotifyRenderersOfPendingShutdown());
- ChildProcessHost::ForceShutdown();
+ BrowserChildProcessHost::ForceShutdown();
}
void PluginProcessHost::OnProcessLaunched() {
diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h
index 3f7e661..a9c8bb6 100644
--- a/chrome/browser/plugin_process_host.h
+++ b/chrome/browser/plugin_process_host.h
@@ -15,7 +15,7 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/net/resolve_proxy_msg_helper.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "gfx/native_widget_types.h"
@@ -34,7 +34,7 @@ class GURL;
// starting the plugin process when a plugin is created that doesn't already
// have a process. After that, most of the communication is directly between
// the renderer and plugin processes.
-class PluginProcessHost : public ChildProcessHost,
+class PluginProcessHost : public BrowserChildProcessHost,
public ResolveProxyMsgHelper::Delegate {
public:
PluginProcessHost();
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index 7b863d4..de8cc30 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -44,7 +44,7 @@
static void NotifyPluginsOfActivation() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
!iter.Done(); ++iter) {
PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
plugin->OnAppActivation();
@@ -189,7 +189,7 @@ PluginProcessHost* PluginService::FindPluginProcess(
return NULL;
}
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
!iter.Done(); ++iter) {
PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
if (plugin->info().path == plugin_path)
diff --git a/chrome/browser/profile_import_process_host.cc b/chrome/browser/profile_import_process_host.cc
index ffe0395..84a2684 100644
--- a/chrome/browser/profile_import_process_host.cc
+++ b/chrome/browser/profile_import_process_host.cc
@@ -19,7 +19,7 @@ ProfileImportProcessHost::ProfileImportProcessHost(
ResourceDispatcherHost* resource_dispatcher,
ImportProcessClient* import_process_client,
ChromeThread::ID thread_id)
- : ChildProcessHost(PROFILE_IMPORT_PROCESS, resource_dispatcher),
+ : BrowserChildProcessHost(PROFILE_IMPORT_PROCESS, resource_dispatcher),
import_process_client_(import_process_client),
thread_id_(thread_id) {
}
diff --git a/chrome/browser/profile_import_process_host.h b/chrome/browser/profile_import_process_host.h
index c4d06e7..878d972 100644
--- a/chrome/browser/profile_import_process_host.h
+++ b/chrome/browser/profile_import_process_host.h
@@ -12,7 +12,7 @@
#include "base/ref_counted.h"
#include "base/task.h"
#include "base/values.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/importer/importer_data_types.h"
@@ -26,7 +26,7 @@ struct PasswordForm;
// Browser-side host to a profile import process. This class lives only on
// the IO thread. It passes messages back to the |thread_id_| thread through
// a client object.
-class ProfileImportProcessHost : public ChildProcessHost {
+class ProfileImportProcessHost : public BrowserChildProcessHost {
public:
// An interface that must be implemented by consumers of the profile import
@@ -87,8 +87,8 @@ class ProfileImportProcessHost : public ChildProcessHost {
DISALLOW_COPY_AND_ASSIGN(ImportProcessClient);
};
- // |resource_dispatcher| is used in the base ChildProcessHost class to manage
- // IPC requests.
+ // |resource_dispatcher| is used in the base BrowserChildProcessHost class to
+ // manage IPC requests.
// |import_process_client| implements callbacks which are triggered by
// incoming IPC messages. This client creates an interface between IPC
// messages received by the ProfileImportProcessHost and the internal
@@ -124,7 +124,7 @@ class ProfileImportProcessHost : public ChildProcessHost {
// ImportProcessClient.
void OnMessageReceived(const IPC::Message& message);
- // Overridden from ChildProcessHost:
+ // Overridden from BrowserChildProcessHost:
virtual void OnProcessCrashed();
virtual bool CanShutdown() { return true; }
virtual URLRequestContext* GetRequestContext(
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index d624bda..eee113a 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -22,8 +22,8 @@
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "base/thread.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/child_process_host.h"
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extension_message_service.h"
@@ -471,7 +471,7 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
field_trial_states);
}
- ChildProcessHost::SetCrashReporterCommandLine(command_line);
+ BrowserChildProcessHost::SetCrashReporterCommandLine(command_line);
FilePath user_data_dir =
browser_command_line.GetSwitchValuePath(switches::kUserDataDir);
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index 675aa1b..f4cbd24 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -181,7 +181,8 @@ class NotifyPluginProcessHostTask : public Task {
DWORD plugin_process_id;
bool found_starting_plugin_process = false;
GetWindowThreadProcessId(window_, &plugin_process_id);
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(
+ ChildProcessInfo::PLUGIN_PROCESS);
!iter.Done(); ++iter) {
PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
if (!plugin->handle()) {
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index bfe4ea0..6dfbc0c 100644
--- a/chrome/browser/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager_resource_providers.cc
@@ -16,9 +16,9 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_list.h"
-#include "chrome/browser/child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_process_manager.h"
@@ -488,7 +488,7 @@ void TaskManagerChildProcessResourceProvider::AddToTaskManager(
// The ChildProcessInfo::Iterator has to be used from the IO thread.
void TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo() {
- for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
+ for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) {
// Only add processes which are already started, since we need their handle.
if ((*iter)->handle() != base::kNullProcessHandle)
existing_child_process_info_.push_back(**iter);
diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc
index 6dbf3ba..6a4a7fd 100644
--- a/chrome/browser/utility_process_host.cc
+++ b/chrome/browser/utility_process_host.cc
@@ -17,7 +17,7 @@
UtilityProcessHost::UtilityProcessHost(ResourceDispatcherHost* rdh,
Client* client,
ChromeThread::ID client_thread_id)
- : ChildProcessHost(UTILITY_PROCESS, rdh),
+ : BrowserChildProcessHost(UTILITY_PROCESS, rdh),
client_(client),
client_thread_id_(client_thread_id) {
}
diff --git a/chrome/browser/utility_process_host.h b/chrome/browser/utility_process_host.h
index faeec97..122d5a0 100644
--- a/chrome/browser/utility_process_host.h
+++ b/chrome/browser/utility_process_host.h
@@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/task.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/common/extensions/update_manifest.h"
#include "ipc/ipc_channel.h"
@@ -24,7 +24,7 @@ class ListValue;
// This class acts as the browser-side host to a utility child process. A
// utility process is a short-lived sandboxed process that is created to run
// a specific task. This class lives solely on the IO thread.
-class UtilityProcessHost : public ChildProcessHost {
+class UtilityProcessHost : public BrowserChildProcessHost {
public:
// An interface to be implemented by consumers of the utility process to
// get results back. All functions are called on the thread passed along
@@ -121,7 +121,7 @@ class UtilityProcessHost : public ChildProcessHost {
// IPC messages:
void OnMessageReceived(const IPC::Message& message);
- // ChildProcessHost:
+ // BrowserChildProcessHost:
virtual void OnProcessCrashed();
virtual bool CanShutdown() { return true; }
virtual URLRequestContext* GetRequestContext(
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index ccb7e78..762a0c5 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -58,7 +58,7 @@ class WorkerCrashTask : public Task {
WorkerProcessHost::WorkerProcessHost(
ResourceDispatcherHost* resource_dispatcher_host,
ChromeURLRequestContext *request_context)
- : ChildProcessHost(WORKER_PROCESS, resource_dispatcher_host),
+ : BrowserChildProcessHost(WORKER_PROCESS, resource_dispatcher_host),
request_context_(request_context),
appcache_dispatcher_host_(
new AppCacheDispatcherHost(request_context)) {
@@ -322,7 +322,7 @@ CallbackWithReturnValue<int>::Type* WorkerProcessHost::GetNextRouteIdCallback(
// We don't keep callbacks for senders associated with workers, so figure out
// what kind of sender this is, and cast it to the correct class to get the
// callback.
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
if (static_cast<IPC::Message::Sender*>(worker) == sender)
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index edcfb05..6e95b3f 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/ref_counted.h"
-#include "chrome/browser/child_process_host.h"
+#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/worker_host/worker_document_set.h"
#include "googleurl/src/gurl.h"
@@ -31,7 +31,7 @@ struct ViewHostMsg_CreateWorker_Params;
// WorkerProcessHost per worker process. Currently each worker runs in its own
// process, but that may change. However, we do assume [by storing a
// ChromeURLRequestContext] that a WorkerProcessHost serves a single Profile.
-class WorkerProcessHost : public ChildProcessHost {
+class WorkerProcessHost : public BrowserChildProcessHost {
public:
// Contains information about each worker instance, needed to forward messages
diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc
index 73848d6..60fa03d 100644
--- a/chrome/browser/worker_host/worker_service.cc
+++ b/chrome/browser/worker_host/worker_service.cc
@@ -262,7 +262,7 @@ bool WorkerService::LookupSharedWorker(
void WorkerService::DocumentDetached(IPC::Message::Sender* sender,
unsigned long long document_id) {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
worker->DocumentDetached(sender, document_id);
@@ -309,7 +309,7 @@ void WorkerService::CancelCreateDedicatedWorker(IPC::Message::Sender* sender,
// There could be a race condition where the WebWorkerProxy told us to cancel
// the worker right as we sent it a message say it's been created. Look at
// the running workers.
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
for (WorkerProcessHost::Instances::const_iterator instance =
@@ -330,7 +330,7 @@ void WorkerService::CancelCreateDedicatedWorker(IPC::Message::Sender* sender,
void WorkerService::ForwardMessage(const IPC::Message& message,
IPC::Message::Sender* sender) {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
if (worker->FilterMessage(message, sender))
@@ -344,7 +344,7 @@ WorkerProcessHost* WorkerService::GetProcessForDomain(const GURL& url) {
int num_processes = 0;
std::string domain =
net::RegistryControlledDomainService::GetDomainAndRegistry(url);
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
num_processes++;
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
@@ -366,7 +366,7 @@ WorkerProcessHost* WorkerService::GetProcessForDomain(const GURL& url) {
WorkerProcessHost* WorkerService::GetProcessToFillUpCores() {
int num_processes = 0;
- ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
for (; !iter.Done(); ++iter)
num_processes++;
@@ -378,7 +378,7 @@ WorkerProcessHost* WorkerService::GetProcessToFillUpCores() {
WorkerProcessHost* WorkerService::GetLeastLoadedWorker() {
WorkerProcessHost* smallest = NULL;
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
if (!smallest || worker->instances().size() < smallest->instances().size())
@@ -419,7 +419,7 @@ bool WorkerService::TabCanCreateWorkerProcess(int renderer_id,
int total_workers = 0;
int workers_per_tab = 0;
*hit_total_worker_limit = false;
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
for (WorkerProcessHost::Instances::const_iterator cur_instance =
@@ -457,7 +457,7 @@ void WorkerService::Observe(NotificationType type,
}
void WorkerService::SenderShutdown(IPC::Message::Sender* sender) {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
worker->SenderShutdown(sender);
@@ -512,7 +512,7 @@ void WorkerService::WorkerProcessDestroyed(WorkerProcessHost* process) {
const WorkerProcessHost::WorkerInstance* WorkerService::FindWorkerInstance(
int worker_process_id) {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
if (iter->id() != worker_process_id)
continue;
@@ -528,7 +528,7 @@ const WorkerProcessHost::WorkerInstance* WorkerService::FindWorkerInstance(
WorkerProcessHost::WorkerInstance*
WorkerService::FindSharedWorkerInstance(const GURL& url, const string16& name,
bool off_the_record) {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
!iter.Done(); ++iter) {
WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
for (WorkerProcessHost::Instances::iterator instance_iter =
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index cb894aa..9d87d9e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -256,6 +256,8 @@
'browser/browser_accessibility_win.h',
'browser/browser_accessibility_manager_win.cc',
'browser/browser_accessibility_manager_win.h',
+ 'browser/browser_child_process_host.cc',
+ 'browser/browser_child_process_host.h',
'browser/browser_init.cc',
'browser/browser_init.h',
'browser/browser_list_gtk.cc',
@@ -316,8 +318,6 @@
'browser/cert_store.h',
'browser/character_encoding.cc',
'browser/character_encoding.h',
- 'browser/child_process_host.cc',
- 'browser/child_process_host.h',
'browser/child_process_launcher.cc',
'browser/child_process_launcher.h',
'browser/child_process_security_policy.cc',
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 240280e..08c643a 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -186,6 +186,8 @@
'common/appcache/appcache_dispatcher.h',
'common/automation_constants.cc',
'common/automation_constants.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
new file mode 100644
index 0000000..04316502
--- /dev/null
+++ b/chrome/common/child_process_host.cc
@@ -0,0 +1,143 @@
+// 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/path_service.h"
+#include "chrome/common/child_process_info.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths_internal.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/plugin_messages.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() {
+}
+
+// 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_MACOSX)
+ // On the Mac, the child executable lives at a predefined location within
+ // the app bundle's versioned directory.
+ return chrome::GetVersionedDirectory().
+ Append(chrome::kHelperProcessExecutablePath);
+#endif
+
+#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.
+ if (allow_self)
+ return FilePath("/proc/self/exe");
+#endif
+
+ // On most platforms, the child executable is the same as the current
+ // executable.
+ PathService::Get(base::FILE_EXE, &child_path);
+ return child_path;
+}
+
+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;
+
+ opening_channel_ = true;
+
+ return true;
+}
+
+void ChildProcessHost::InstanceCreated() {
+ Notify(NotificationType::CHILD_INSTANCE_CREATED);
+}
+
+bool ChildProcessHost::SendOnChannel(IPC::Message* msg) {
+ if (!channel_.get()) {
+ delete msg;
+ return false;
+ }
+ return channel_->Send(msg);
+}
+
+void ChildProcessHost::OnChildDied() {
+ delete this;
+}
+
+ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
+ : host_(host) {
+}
+
+void ChildProcessHost::ListenerHook::OnMessageReceived(
+ const IPC::Message& msg) {
+#ifdef IPC_MESSAGE_LOG_ENABLED
+ IPC::Logging* logger = IPC::Logging::current();
+ if (msg.type() == IPC_LOGGING_ID) {
+ logger->OnReceivedLoggingMessage(msg);
+ return;
+ }
+
+ if (logger->Enabled())
+ logger->OnPreDispatchMessage(msg);
+#endif
+
+ bool handled = host_->InterceptMessageFromChild(msg);
+
+ if (!handled) {
+ if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) {
+ if (host_->CanShutdown())
+ host_->SendOnChannel(new PluginProcessMsg_Shutdown());
+ } else {
+ host_->OnMessageReceived(msg);
+ }
+ }
+
+#ifdef IPC_MESSAGE_LOG_ENABLED
+ if (logger->Enabled())
+ logger->OnPostDispatchMessage(msg, host_->channel_id_);
+#endif
+}
+
+void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
+ host_->opening_channel_ = false;
+ host_->OnChannelConnected(peer_pid);
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ bool enabled = IPC::Logging::current()->Enabled();
+ host_->SendOnChannel(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
+#endif
+
+ host_->SendOnChannel(new PluginProcessMsg_AskBeforeShutdown());
+
+ // Notify in the main loop of the connection.
+ host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED);
+}
+
+void ChildProcessHost::ListenerHook::OnChannelError() {
+ host_->opening_channel_ = false;
+ host_->OnChannelError();
+
+ // This will delete host_, which will also destroy this!
+ host_->OnChildDied();
+}
+
+void ChildProcessHost::ForceShutdown() {
+ SendOnChannel(new PluginProcessMsg_Shutdown());
+}
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
new file mode 100644
index 0000000..980ad7d
--- /dev/null
+++ b/chrome/common/child_process_host.h
@@ -0,0 +1,111 @@
+// 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_
+
+#include <list>
+#include <string>
+
+// Must be included early (e.g. before chrome/common/plugin_messages.h)
+#include "ipc/ipc_logging.h"
+
+#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "base/scoped_ptr.h"
+#include "chrome/common/notification_type.h"
+#include "ipc/ipc_channel.h"
+
+class CommandLine;
+
+// 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:
+ 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);
+
+ protected:
+ ChildProcessHost();
+
+ // A helper method to send an IPC message to the child on the channel.
+ // It behavies just like IPC::Message::Sender::Send. The implementor takes
+ // ownership of the given Message regardless of whether or not this method
+ // succeeds. This class does not implement IPC::Message::Sender to prevent
+ // conflicts with subclasses which indirectly could inherit from
+ // IPC::Message::Sender.
+ bool SendOnChannel(IPC::Message* msg);
+
+ // 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 void 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();
+ // Allows the derived implementation to intercept a message before it is
+ // handed to the IPC::Channel::Listener::OnMessageReceived implementation.
+ virtual bool InterceptMessageFromChild(const IPC::Message& msg) {
+ return false;
+ }
+ // 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 void 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_;
+};
+
+#endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_
+