summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_descriptors.h15
-rw-r--r--chrome/common/chrome_switches.cc6
-rw-r--r--chrome/common/chrome_switches.h3
-rw-r--r--chrome/common/ipc_channel.h7
-rw-r--r--chrome/common/ipc_channel_posix.cc25
-rw-r--r--chrome/common/ipc_channel_posix.h2
-rw-r--r--chrome/common/ipc_channel_proxy.cc5
-rw-r--r--chrome/common/ipc_channel_proxy.h2
-rw-r--r--chrome/common/ipc_tests.cc21
-rw-r--r--chrome/common/process_watcher_posix.cc15
10 files changed, 53 insertions, 48 deletions
diff --git a/chrome/common/chrome_descriptors.h b/chrome/common/chrome_descriptors.h
new file mode 100644
index 0000000..3d6be45
--- /dev/null
+++ b/chrome/common/chrome_descriptors.h
@@ -0,0 +1,15 @@
+// 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_COMMON_CHROME_DESCRIPTORS_H_
+#define CHROME_COMMON_CHROME_DESCRIPTORS_H_
+
+// This is a list of global descriptor keys to be used with the
+// base::GlobalDescriptors object (see base/global_descriptors_posix.h)
+enum {
+ kPrimaryIPCChannel = 0,
+ kCrashDumpSignal = 1,
+};
+
+#endif // CHROME_COMMON_CHROME_DESCRIPTORS_H_
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index b12e31c..c57b0bb 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -63,6 +63,9 @@ const wchar_t kHomePage[] = L"homepage";
// Causes the process to run as renderer instead of as browser.
const wchar_t kRendererProcess[] = L"renderer";
+// Causes the process to run as a renderer zygote.
+const wchar_t kZygoteProcess[] = L"zygote";
+
// Path to the exe to run for the renderer and plugin subprocesses.
const wchar_t kBrowserSubprocessPath[] = L"browser-subprocess-path";
@@ -490,6 +493,9 @@ const wchar_t kNoDefaultBrowserCheck[] = L"no-default-browser-check";
// Enables the benchmarking extensions.
const wchar_t kEnableBenchmarking[] = L"enable-benchmarking";
+// The prefix used when starting the zygote process. (i.e. 'gdb --args')
+const wchar_t kZygoteCmdPrefix[] = L"zygote-cmd-prefix";
+
// Enables using ThumbnailStore instead of ThumbnailDatabase for setting and
// getting thumbnails for the new tab page.
const wchar_t kThumbnailStore[] = L"thumbnail-store";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 03f1f11..8d3785a 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -26,6 +26,7 @@ extern const wchar_t kProcessChannelID[];
extern const wchar_t kTestingChannelID[];
extern const wchar_t kHomePage[];
extern const wchar_t kRendererProcess[];
+extern const wchar_t kZygoteProcess[];
extern const wchar_t kBrowserSubprocessPath[];
extern const wchar_t kPluginProcess[];
extern const wchar_t kWorkerProcess[];
@@ -185,6 +186,8 @@ extern const wchar_t kEnableBenchmarking[];
extern const wchar_t kNoDefaultBrowserCheck[];
+extern const wchar_t kZygoteCmdPrefix[];
+
extern const wchar_t kThumbnailStore[];
extern const wchar_t kTryChromeAgain[];
diff --git a/chrome/common/ipc_channel.h b/chrome/common/ipc_channel.h
index f619508..85b35fa 100644
--- a/chrome/common/ipc_channel.h
+++ b/chrome/common/ipc_channel.h
@@ -87,14 +87,13 @@ class Channel : public Message::Sender {
#if defined(OS_POSIX)
// On POSIX an IPC::Channel wraps a socketpair(), this method returns the
- // FD # for the client end of the socket and the equivalent FD# to use for
- // mapping it into the Child process.
+ // FD # for the client end of the socket.
// This method may only be called on the server side of a channel.
//
// If the kTestingChannelID flag is specified on the command line then
// a named FIFO is used as the channel transport mechanism rather than a
- // socketpair() in which case this method returns -1 for both parameters.
- void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
+ // socketpair() in which case this method returns -1.
+ int GetClientFileDescriptor() const;
#endif // defined(OS_POSIX)
private:
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc
index 52cad9d..babc16c 100644
--- a/chrome/common/ipc_channel_posix.cc
+++ b/chrome/common/ipc_channel_posix.cc
@@ -17,15 +17,16 @@
#include "base/command_line.h"
#include "base/eintr_wrapper.h"
+#include "base/global_descriptors_posix.h"
#include "base/lock.h"
#include "base/logging.h"
#include "base/process_util.h"
-#include "base/reserved_file_descriptors.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "base/singleton.h"
#include "base/stats_counters.h"
#include "chrome/common/chrome_counters.h"
+#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/file_descriptor_set_posix.h"
#include "chrome/common/ipc_logging.h"
@@ -40,7 +41,7 @@ namespace IPC {
//
// When creating a child subprocess, the parent side of the fork
// arranges it such that the initial control channel ends up on the
-// magic file descriptor kClientChannelFd in the child. Future
+// magic file descriptor kPrimaryIPCChannel in the child. Future
// connections (file descriptors) can then be passed via that
// connection via sendmsg().
@@ -50,7 +51,7 @@ namespace {
// The PipeMap class works around this quirk related to unit tests:
//
// When running as a server, we install the client socket in a
-// specific file descriptor number (@kClientChannelFd). However, we
+// specific file descriptor number (@kPrimaryIPCChannel). However, we
// also have to support the case where we are running unittests in the
// same process. (We do not support forking without execing.)
//
@@ -58,7 +59,7 @@ namespace {
// The IPC server object will install a mapping in PipeMap from the
// name which it was given to the client pipe. When forking the client, the
// GetClientFileDescriptorMapping will ensure that the socket is installed in
-// the magic slot (@kClientChannelFd). The client will search for the
+// the magic slot (@kPrimaryIPCChannel). The client will search for the
// mapping, but it won't find any since we are in a new process. Thus the
// magic fd number is returned. Once the client connects, the server will
// close its copy of the client socket and remove the mapping.
@@ -124,10 +125,7 @@ int ChannelNameToClientFD(const std::string& channel_id) {
// If we don't find an entry, we assume that the correct value has been
// inserted in the magic slot.
- // kClientChannelFd is the file descriptor number that a client process
- // expects to find its IPC socket; see reserved_file_descriptors.h.
-
- return kClientChannelFd;
+ return Singleton<base::GlobalDescriptors>()->Get(kPrimaryIPCChannel);
}
//------------------------------------------------------------------------------
@@ -671,11 +669,8 @@ bool Channel::ChannelImpl::Send(Message* message) {
return true;
}
-void Channel::ChannelImpl::GetClientFileDescriptorMapping(int *src_fd,
- int *dest_fd) const {
- DCHECK(mode_ == MODE_SERVER);
- *src_fd = client_pipe_;
- *dest_fd = kClientChannelFd;
+int Channel::ChannelImpl::GetClientFileDescriptor() const {
+ return client_pipe_;
}
// Called by libevent when we can read from th pipe without blocking.
@@ -803,8 +798,8 @@ bool Channel::Send(Message* message) {
return channel_impl_->Send(message);
}
-void Channel::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const {
- return channel_impl_->GetClientFileDescriptorMapping(src_fd, dest_fd);
+int Channel::GetClientFileDescriptor() const {
+ return channel_impl_->GetClientFileDescriptor();
}
} // namespace IPC
diff --git a/chrome/common/ipc_channel_posix.h b/chrome/common/ipc_channel_posix.h
index 414730a..ed3d727 100644
--- a/chrome/common/ipc_channel_posix.h
+++ b/chrome/common/ipc_channel_posix.h
@@ -29,7 +29,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
void Close();
void set_listener(Listener* listener) { listener_ = listener; }
bool Send(Message* message);
- void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
+ int GetClientFileDescriptor() const;
private:
bool CreatePipe(const std::string& channel_id, Mode mode);
diff --git a/chrome/common/ipc_channel_proxy.cc b/chrome/common/ipc_channel_proxy.cc
index 6e8919a3..c77ee7e 100644
--- a/chrome/common/ipc_channel_proxy.cc
+++ b/chrome/common/ipc_channel_proxy.cc
@@ -289,11 +289,10 @@ void ChannelProxy::RemoveFilter(MessageFilter* filter) {
// See the TODO regarding lazy initialization of the channel in
// ChannelProxy::Init().
// We assume that IPC::Channel::GetClientFileDescriptorMapping() is thread-safe.
-void ChannelProxy::GetClientFileDescriptorMapping(int *src_fd,
- int *dest_fd) const {
+int ChannelProxy::GetClientFileDescriptor() const {
Channel *channel = context_.get()->channel_;
DCHECK(channel); // Channel must have been created first.
- channel->GetClientFileDescriptorMapping(src_fd, dest_fd);
+ return channel->GetClientFileDescriptor();
}
#endif
diff --git a/chrome/common/ipc_channel_proxy.h b/chrome/common/ipc_channel_proxy.h
index a395b1f..8adcb5b 100644
--- a/chrome/common/ipc_channel_proxy.h
+++ b/chrome/common/ipc_channel_proxy.h
@@ -121,7 +121,7 @@ class ChannelProxy : public Message::Sender {
// Calls through to the underlying channel's methods.
// TODO(playmobil): For now this is only implemented in the case of
// create_pipe_now = true, we need to figure this out for the latter case.
- void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
+ int GetClientFileDescriptor() const;
#endif // defined(OS_POSIX)
protected:
diff --git a/chrome/common/ipc_tests.cc b/chrome/common/ipc_tests.cc
index d347fb5..c2e0baa 100644
--- a/chrome/common/ipc_tests.cc
+++ b/chrome/common/ipc_tests.cc
@@ -21,11 +21,16 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug_on_start.h"
+#if defined(OS_POSIX)
+#include "base/at_exit.h"
+#include "base/global_descriptors_posix.h"
+#endif
#include "base/perftimer.h"
#include "base/perf_test_suite.h"
#include "base/test_suite.h"
#include "base/thread.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/ipc_channel.h"
#include "chrome/common/ipc_channel_proxy.h"
#include "chrome/common/ipc_message_utils.h"
@@ -86,11 +91,9 @@ base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
base::file_handle_mapping_vector fds_to_map;
- int src_fd;
- int dest_fd;
- channel->GetClientFileDescriptorMapping(&src_fd, &dest_fd);
- if (src_fd > -1) {
- fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd));
+ const int ipcfd = channel->GetClientFileDescriptor();
+ if (ipcfd > -1) {
+ fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3));
}
base::ProcessHandle ret = NULL;
@@ -258,11 +261,9 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDebugChildren);
base::file_handle_mapping_vector fds_to_map;
- int src_fd;
- int dest_fd;
- chan.GetClientFileDescriptorMapping(&src_fd, &dest_fd);
- if (src_fd > -1) {
- fds_to_map.push_back(std::pair<int,int>(src_fd, dest_fd));
+ const int ipcfd = chan.GetClientFileDescriptor();
+ if (ipcfd > -1) {
+ fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3));
}
base::ProcessHandle process_handle = MultiProcessTest::SpawnChild(
diff --git a/chrome/common/process_watcher_posix.cc b/chrome/common/process_watcher_posix.cc
index 497b80b..f1ae4f4 100644
--- a/chrome/common/process_watcher_posix.cc
+++ b/chrome/common/process_watcher_posix.cc
@@ -11,7 +11,6 @@
#include "base/eintr_wrapper.h"
#include "base/platform_thread.h"
-#include "base/zygote_manager.h"
// Return true if the given child is dead. This will also reap the process.
// Doesn't block.
@@ -70,20 +69,8 @@ class BackgroundReaper : public PlatformThread::Delegate {
// static
void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) {
// If the child is already dead, then there's nothing to do
- const int result = HANDLE_EINTR(waitpid(process, NULL, WNOHANG));
- if (result > 0)
+ if (IsChildDead(process))
return;
- if (result == -1) {
-#if defined(OS_LINUX)
- // If it wasn't our child, maybe it was the zygote manager's child
- base::ZygoteManager* zm = base::ZygoteManager::Get();
- if (zm) {
- zm->EnsureProcessTerminated(process);
- return;
- }
-#endif // defined(OS_LINUX)
- NOTREACHED();
- }
BackgroundReaper* reaper = new BackgroundReaper(process);
PlatformThread::CreateNonJoinable(0, reaper);