summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 23:28:46 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 23:28:46 +0000
commitac577490a5c20950f63d655de37058dc41486e99 (patch)
treee5a53f6cad3317c2451f8ef39bf0b19bd8706e79 /chrome/common
parent0f1169993f28f8da9be5a81496fb2e2abf311387 (diff)
downloadchromium_src-ac577490a5c20950f63d655de37058dc41486e99.zip
chromium_src-ac577490a5c20950f63d655de37058dc41486e99.tar.gz
chromium_src-ac577490a5c20950f63d655de37058dc41486e99.tar.bz2
Revert 18109, 18111: Windows UI tests failed.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18112 0039d316-1c4b-4281-b951-d872f2087c98
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, 48 insertions, 53 deletions
diff --git a/chrome/common/chrome_descriptors.h b/chrome/common/chrome_descriptors.h
deleted file mode 100644
index 3d6be45..0000000
--- a/chrome/common/chrome_descriptors.h
+++ /dev/null
@@ -1,15 +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_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 e5bce97..48511d3 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -63,9 +63,6 @@ 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";
@@ -493,9 +490,6 @@ 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 33a0239..8259d72 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -26,7 +26,6 @@ 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[];
@@ -186,8 +185,6 @@ extern const wchar_t kEnableBenchmarking[];
extern const wchar_t kNoDefaultBrowserCheck[];
-extern const wchar_t kZygoteCmdPrefix[];
-
extern const wchar_t kThumbnailStore[];
} // namespace switches
diff --git a/chrome/common/ipc_channel.h b/chrome/common/ipc_channel.h
index 85b35fa..f619508 100644
--- a/chrome/common/ipc_channel.h
+++ b/chrome/common/ipc_channel.h
@@ -87,13 +87,14 @@ 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.
+ // FD # for the client end of the socket and the equivalent FD# to use for
+ // mapping it into the Child process.
// 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.
- int GetClientFileDescriptor() const;
+ // socketpair() in which case this method returns -1 for both parameters.
+ void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
#endif // defined(OS_POSIX)
private:
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc
index babc16c..52cad9d 100644
--- a/chrome/common/ipc_channel_posix.cc
+++ b/chrome/common/ipc_channel_posix.cc
@@ -17,16 +17,15 @@
#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"
@@ -41,7 +40,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 kPrimaryIPCChannel in the child. Future
+// magic file descriptor kClientChannelFd in the child. Future
// connections (file descriptors) can then be passed via that
// connection via sendmsg().
@@ -51,7 +50,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 (@kPrimaryIPCChannel). However, we
+// specific file descriptor number (@kClientChannelFd). However, we
// also have to support the case where we are running unittests in the
// same process. (We do not support forking without execing.)
//
@@ -59,7 +58,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 (@kPrimaryIPCChannel). The client will search for the
+// the magic slot (@kClientChannelFd). 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.
@@ -125,7 +124,10 @@ 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.
- return Singleton<base::GlobalDescriptors>()->Get(kPrimaryIPCChannel);
+ // kClientChannelFd is the file descriptor number that a client process
+ // expects to find its IPC socket; see reserved_file_descriptors.h.
+
+ return kClientChannelFd;
}
//------------------------------------------------------------------------------
@@ -669,8 +671,11 @@ bool Channel::ChannelImpl::Send(Message* message) {
return true;
}
-int Channel::ChannelImpl::GetClientFileDescriptor() const {
- return client_pipe_;
+void Channel::ChannelImpl::GetClientFileDescriptorMapping(int *src_fd,
+ int *dest_fd) const {
+ DCHECK(mode_ == MODE_SERVER);
+ *src_fd = client_pipe_;
+ *dest_fd = kClientChannelFd;
}
// Called by libevent when we can read from th pipe without blocking.
@@ -798,8 +803,8 @@ bool Channel::Send(Message* message) {
return channel_impl_->Send(message);
}
-int Channel::GetClientFileDescriptor() const {
- return channel_impl_->GetClientFileDescriptor();
+void Channel::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const {
+ return channel_impl_->GetClientFileDescriptorMapping(src_fd, dest_fd);
}
} // namespace IPC
diff --git a/chrome/common/ipc_channel_posix.h b/chrome/common/ipc_channel_posix.h
index ed3d727..414730a 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);
- int GetClientFileDescriptor() const;
+ void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) 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 c77ee7e..6e8919a3 100644
--- a/chrome/common/ipc_channel_proxy.cc
+++ b/chrome/common/ipc_channel_proxy.cc
@@ -289,10 +289,11 @@ 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.
-int ChannelProxy::GetClientFileDescriptor() const {
+void ChannelProxy::GetClientFileDescriptorMapping(int *src_fd,
+ int *dest_fd) const {
Channel *channel = context_.get()->channel_;
DCHECK(channel); // Channel must have been created first.
- return channel->GetClientFileDescriptor();
+ channel->GetClientFileDescriptorMapping(src_fd, dest_fd);
}
#endif
diff --git a/chrome/common/ipc_channel_proxy.h b/chrome/common/ipc_channel_proxy.h
index 8adcb5b..a395b1f 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.
- int GetClientFileDescriptor() const;
+ void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
#endif // defined(OS_POSIX)
protected:
diff --git a/chrome/common/ipc_tests.cc b/chrome/common/ipc_tests.cc
index c2e0baa..d347fb5 100644
--- a/chrome/common/ipc_tests.cc
+++ b/chrome/common/ipc_tests.cc
@@ -21,16 +21,11 @@
#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"
@@ -91,9 +86,11 @@ base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
base::file_handle_mapping_vector fds_to_map;
- const int ipcfd = channel->GetClientFileDescriptor();
- if (ipcfd > -1) {
- fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3));
+ 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));
}
base::ProcessHandle ret = NULL;
@@ -261,9 +258,11 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDebugChildren);
base::file_handle_mapping_vector fds_to_map;
- const int ipcfd = chan.GetClientFileDescriptor();
- if (ipcfd > -1) {
- fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3));
+ 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));
}
base::ProcessHandle process_handle = MultiProcessTest::SpawnChild(
diff --git a/chrome/common/process_watcher_posix.cc b/chrome/common/process_watcher_posix.cc
index f1ae4f4..497b80b 100644
--- a/chrome/common/process_watcher_posix.cc
+++ b/chrome/common/process_watcher_posix.cc
@@ -11,6 +11,7 @@
#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.
@@ -69,8 +70,20 @@ class BackgroundReaper : public PlatformThread::Delegate {
// static
void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) {
// If the child is already dead, then there's nothing to do
- if (IsChildDead(process))
+ const int result = HANDLE_EINTR(waitpid(process, NULL, WNOHANG));
+ if (result > 0)
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);