summaryrefslogtreecommitdiffstats
path: root/chrome/app
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 23:04:55 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 23:04:55 +0000
commit361e25c6d29fdae737b5ddf846606093b5502187 (patch)
tree3114ddee1266088582391d5be9d0ab7aecbd5b8d /chrome/app
parentc6b652b9298b037d8a18dd241061122200019dba (diff)
downloadchromium_src-361e25c6d29fdae737b5ddf846606093b5502187.zip
chromium_src-361e25c6d29fdae737b5ddf846606093b5502187.tar.gz
chromium_src-361e25c6d29fdae737b5ddf846606093b5502187.tar.bz2
Linux: refactor zygote support
http://code.google.com/p/chromium/wiki/LinuxZygote * Move Chrome specific bits out of base * Move away from the idea of reserved file descriptors (which don't really work with zygotes) * Load resources before forking renderers (means that we don't need communication between the zygote process and the renderers) * Make sure that gdb works against the browser again * Make sure that we have different ASLR between the renderers and the browser. http://codereview.chromium.org/119335 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r--chrome/app/breakpad_linux.cc8
-rw-r--r--chrome/app/chrome_dll_main.cc39
-rw-r--r--chrome/app/chrome_main_uitest.cc5
3 files changed, 32 insertions, 20 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 0ee0bed..ef3dfa2 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -14,13 +14,13 @@
#include "base/file_version_info_linux.h"
#include "base/path_service.h"
#include "base/rand_util.h"
-#include "base/reserved_file_descriptors.h"
#include "breakpad/linux/directory_reader.h"
#include "breakpad/linux/exception_handler.h"
#include "breakpad/linux/linux_libc_support.h"
#include "breakpad/linux/linux_syscall_support.h"
#include "breakpad/linux/memory.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_descriptors.h"
#include "chrome/installer/util/google_update_settings.h"
static const char kUploadURL[] =
@@ -501,13 +501,11 @@ RendererCrashHandler(const void* crash_context, size_t crash_context_size,
}
void EnableRendererCrashDumping() {
- // When the browser forks off our process, it installs the crash signal file
- // descriptor in slot kMagicCrashSignalFd.
-
+ const int fd = Singleton<base::GlobalDescriptors>()->Get(kCrashDumpSignal);
// We deliberately leak this object.
google_breakpad::ExceptionHandler* handler =
new google_breakpad::ExceptionHandler("" /* unused */, NULL, NULL,
- (void*) kMagicCrashSignalFd, true);
+ (void*) fd, true);
handler->set_crash_handler(RendererCrashHandler);
}
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index b6ba22f..33e774c 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -34,6 +34,9 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/debug_util.h"
+#if defined(OS_POSIX)
+#include "base/global_descriptors_posix.h"
+#endif
#include "base/icu_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
@@ -45,9 +48,6 @@
#if defined(OS_WIN)
#include "base/win_util.h"
#endif
-#if defined(OS_LINUX)
-#include "base/zygote_manager.h"
-#endif
#if defined(OS_MACOSX)
#include "chrome/app/breakpad_mac.h"
#elif defined(OS_LINUX)
@@ -57,6 +57,7 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_counters.h"
+#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
@@ -75,6 +76,7 @@ extern int RendererMain(const MainFunctionParams&);
extern int PluginMain(const MainFunctionParams&);
extern int WorkerMain(const MainFunctionParams&);
extern int UtilityMain(const MainFunctionParams&);
+extern int ZygoteMain(const MainFunctionParams&);
#if defined(OS_WIN)
// TODO(erikkay): isn't this already defined somewhere?
@@ -292,21 +294,19 @@ int ChromeMain(int argc, const char** argv) {
// its main event loop to get rid of the cruft.
base::ScopedNSAutoreleasePool autorelease_pool;
+#if defined(OS_POSIX)
+ base::GlobalDescriptors* g_fds = Singleton<base::GlobalDescriptors>::get();
+ g_fds->Set(kPrimaryIPCChannel,
+ kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor);
+#if defined(OS_LINUX)
+ g_fds->Set(kCrashDumpSignal,
+ kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor);
+#endif
+#endif
+
// Initialize the command line.
#if defined(OS_WIN)
CommandLine::Init(0, NULL);
-#elif defined(OS_LINUX)
- base::ZygoteManager* zm = base::ZygoteManager::Get();
- std::vector<std::string>* zargv = NULL;
- if (zm)
- zargv = zm->Start();
- if (zargv) {
- // Forked child.
- CommandLine::Init(*zargv);
- } else {
- // Original process.
- CommandLine::Init(argc, argv);
- }
#else
CommandLine::Init(argc, argv);
#endif
@@ -339,11 +339,13 @@ int ChromeMain(int argc, const char** argv) {
CHECK(sigaction(SIGPIPE, &action, 0) == 0);
#endif // OS_POSIX
} else {
+#if defined(OS_WIN)
std::wstring channel_name =
parsed_command_line.GetSwitchValue(switches::kProcessChannelID);
browser_pid = StringToInt(WideToASCII(channel_name));
DCHECK(browser_pid != 0);
+#endif
#if defined(OS_POSIX)
// When you hit Ctrl-C in a terminal running the browser
@@ -489,6 +491,13 @@ int ChromeMain(int argc, const char** argv) {
#else
NOTIMPLEMENTED();
#endif
+ } else if (process_type == switches::kZygoteProcess) {
+#if defined(OS_LINUX)
+ if (ZygoteMain(main_params))
+ RendererMain(main_params);
+#else
+ NOTIMPLEMENTED();
+#endif
} else if (process_type.empty()) {
#if defined(OS_LINUX)
// Glib type system initialization. Needed at least for gconf,
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc
index 5ce05c2..f229751 100644
--- a/chrome/app/chrome_main_uitest.cc
+++ b/chrome/app/chrome_main_uitest.cc
@@ -18,9 +18,14 @@ TEST_F(ChromeMainTest, AppLaunch) {
if (UITest::in_process_renderer()) {
EXPECT_EQ(1, UITest::GetBrowserProcessCount());
} else {
+#if defined(OS_LINUX)
+ // On Linux we'll have three processes: browser, renderer and zygote.
+ EXPECT_EQ(3, UITest::GetBrowserProcessCount());
+#else
// We should have two instances of the browser process alive -
// one is the Browser and the other is the Renderer.
EXPECT_EQ(2, UITest::GetBrowserProcessCount());
+#endif
}
}