Backing out stuff that doesn't work

This commit is contained in:
Ben Turner 2009-08-27 16:05:38 -07:00
parent 5b7e1a569b
commit 7c25b1ea27
7 changed files with 67 additions and 81 deletions

View File

@ -53,6 +53,13 @@ struct RunnableMethodTraits<mozilla::ipc::AsyncChannel>
static void ReleaseCallee(mozilla::ipc::AsyncChannel* obj) { }
};
template<>
struct RunnableMethodTraits<ContentProcessChild>
{
static void RetainCallee(ContentProcessChild* obj) { }
static void ReleaseCallee(ContentProcessChild* obj) { }
};
namespace mozilla {
namespace ipc {
@ -174,7 +181,9 @@ AsyncChannel::OnChannelError()
// Child process, initiate quit sequence.
#ifdef DEBUG
// XXXbent this is totally out of place, but works for now.
XRE_ShutdownChildProcess(mWorkerLoop);
mWorkerLoop->PostTask(FROM_HERE,
NewRunnableMethod(ContentProcessChild::GetSingleton(),
&ContentProcessChild::Quit));
// Must exit the IO loop, which will then join with the UI loop.
MessageLoop::current()->Quit();

View File

@ -76,6 +76,10 @@ tier_external_dirs += gfx/qcms
# tier "gecko" - core components
#
ifdef MOZ_IPC
tier_gecko_dirs += ipc
endif
tier_gecko_dirs += \
js/src/xpconnect \
intl/chardet \

View File

@ -209,6 +209,11 @@
#ifdef MOZ_IPC
#include "base/command_line.h"
#include "base/thread.h"
#include "mozilla/ipc/GeckoThread.h"
using mozilla::ipc::BrowserProcessSubThread;
using mozilla::ipc::GeckoThread;
#endif
#ifdef WINCE
@ -3048,7 +3053,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
MOZ_SPLASHSCREEN_UPDATE(20);
#if defined(MOZ_IPC) && !defined(OS_WIN)
#ifdef MOZ_IPC
// FIXME: this and its constituents leak
char** canonArgs = new char*[gArgc];
@ -3525,6 +3530,27 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
MOZ_SPLASHSCREEN_UPDATE(90);
{
#if 0 && defined(OS_LINUX)
// The lifetime of the BACKGROUND_X11 thread is a subset
// of the IO thread so we start it now.
scoped_ptr<base::Thread> x11Thread(
new BrowserProcessSubThread(BrowserProcessSubThread::BACKGROUND_X11));
if (NS_UNLIKELY(!x11Thread->Start())) {
NS_ERROR("Failed to create chromium's X11 thread!");
return NS_ERROR_FAILURE;
}
#endif
#ifdef MOZ_IPC
scoped_ptr<base::Thread> ipcThread(
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
if (NS_UNLIKELY(!ipcThread->StartWithOptions(options))) {
NS_ERROR("Failed to create chromium's IO thread!");
return NS_ERROR_FAILURE;
}
#endif
NS_TIMELINE_ENTER("appStartup->Run");
rv = appStartup->Run();
NS_TIMELINE_LEAVE("appStartup->Run");

View File

@ -64,6 +64,7 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/thread.h"
#include "chrome/common/child_process.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
@ -73,7 +74,6 @@
#include "mozilla/plugins/PluginThreadChild.h"
#include "ContentProcessThread.h"
#include "ContentProcessParent.h"
#include "ContentProcessChild.h"
#include "mozilla/ipc/TestShellParent.h"
#include "mozilla/ipc/XPCShellEnvironment.h"
@ -82,6 +82,7 @@
#include "mozilla/test/TestThreadChild.h"
#include "mozilla/Monitor.h"
using mozilla::ipc::BrowserProcessSubThread;
using mozilla::ipc::GeckoChildProcessHost;
using mozilla::ipc::GeckoThread;
using mozilla::ipc::ScopedXREEmbed;
@ -89,7 +90,6 @@ using mozilla::ipc::ScopedXREEmbed;
using mozilla::plugins::PluginThreadChild;
using mozilla::dom::ContentProcessThread;
using mozilla::dom::ContentProcessParent;
using mozilla::dom::ContentProcessChild;
using mozilla::ipc::TestShellParent;
using mozilla::ipc::XPCShellEnvironment;
@ -337,11 +337,32 @@ XRE_InitParentProcess(int aArgc,
NS_ENSURE_ARG_POINTER(aArgv);
NS_ENSURE_ARG_POINTER(aArgv[0]);
base::AtExitManager exitManager;
CommandLine::Init(aArgc, aArgv);
MessageLoopForUI mainMessageLoop;
ScopedXREEmbed embed;
{
// Make chromium's IPC thread
#if defined(OS_LINUX)
// The lifetime of the BACKGROUND_X11 thread is a subset of the IO thread so
// we start it now.
scoped_ptr<base::Thread> x11Thread(
new BrowserProcessSubThread(BrowserProcessSubThread::BACKGROUND_X11));
if (NS_UNLIKELY(!x11Thread->Start())) {
NS_ERROR("Failed to create chromium's X11 thread!");
return NS_ERROR_FAILURE;
}
#endif
scoped_ptr<base::Thread> ipcThread(
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
if (NS_UNLIKELY(!ipcThread->StartWithOptions(options))) {
NS_ERROR("Failed to create chromium's IO thread!");
return NS_ERROR_FAILURE;
}
embed.Start();
nsCOMPtr<nsIAppShell> appShell(do_GetService(kAppShellCID));
@ -478,49 +499,13 @@ XRE_RunIPCTestHarness(int aArgc, char* aArgv[])
return 0;
}
template<>
struct RunnableMethodTraits<ContentProcessChild>
{
static void RetainCallee(ContentProcessChild* obj) { }
static void ReleaseCallee(ContentProcessChild* obj) { }
};
void
XRE_ShutdownChildProcess(MessageLoop* aUILoop)
XRE_ShutdownChildProcess()
{
if (aUILoop) {
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
aUILoop->PostTask(FROM_HERE,
NewRunnableMethod(ContentProcessChild::GetSingleton(),
&ContentProcessChild::Quit));
return;
}
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
if (appStartup) {
appStartup->Quit(nsIAppStartup::eForceQuit);
}
}
ContentProcessParent*
XRE_GetContentProcessParent()
{
if (XRE_GetProcessType() == GeckoProcessType_Default) {
return ContentProcessParent::GetSingleton();
}
NS_WARNING("Called XRE_GetContentProcessParent in child process!");
return nsnull;
}
ContentProcessChild*
XRE_GetContentProcessChild()
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
return ContentProcessChild::GetSingleton();
}
NS_WARNING("Called XRE_GetContentProcessChild in parent process!");
return nsnull;
}
#endif

View File

@ -41,8 +41,4 @@ ifdef NS_TRACE_MALLOC
tier_xpcom_dirs = tools/trace-malloc/lib
endif
ifdef MOZ_IPC
tier_xpcom_dirs += ipc
endif
tier_xpcom_dirs += xpcom

View File

@ -150,17 +150,13 @@ NS_DECL_CLASSINFO(nsStringInputStream)
#include "base/command_line.h"
#include "base/message_loop.h"
#include "mozilla/ipc/GeckoThread.h"
using base::AtExitManager;
using mozilla::ipc::BrowserProcessSubThread;
namespace {
static AtExitManager* sExitManager;
static MessageLoop* sMessageLoop;
static bool sCommandLineWasInitialized;
static BrowserProcessSubThread* sIOThread;
} /* anonymous namespace */
#endif
@ -591,18 +587,6 @@ NS_InitXPCOM3(nsIServiceManager* *result,
sMessageLoop = new MessageLoopForUI();
NS_ENSURE_STATE(sMessageLoop);
}
if (!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
scoped_ptr<BrowserProcessSubThread> ioThread(
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
NS_ENSURE_TRUE(ioThread.get(), NS_ERROR_OUT_OF_MEMORY);
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
NS_ENSURE_TRUE(ioThread->StartWithOptions(options), NS_ERROR_FAILURE);
sIOThread = ioThread.release();
}
#endif
NS_LogInit();
@ -978,10 +962,6 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
#endif
#ifdef MOZ_IPC
if (sIOThread) {
delete sIOThread;
sIOThread = nsnull;
}
if (sMessageLoop) {
delete sMessageLoop;
sMessageLoop = nsnull;

View File

@ -473,21 +473,7 @@ XRE_API(int,
XRE_RunIPCTestHarness, (int aArgc,
char* aArgv[]))
class MessageLoop;
XRE_API(void,
XRE_ShutdownChildProcess, (MessageLoop* aUILoop = 0))
namespace mozilla {
namespace dom {
class ContentProcessParent;
class ContentProcessChild;
}
}
XRE_API(mozilla::dom::ContentProcessParent*,
XRE_GetContentProcessParent, ())
XRE_API(mozilla::dom::ContentProcessChild*,
XRE_GetContentProcessChild, ())
XRE_ShutdownChildProcess, ())
#endif // _nsXULAppAPI_h__