2009-08-18 12:05:15 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2012-06-27 17:15:32 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2010-08-20 16:24:40 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#endif
|
|
|
|
|
2010-10-08 14:48:37 -07:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
2010-10-08 23:05:50 -07:00
|
|
|
#include "nsQAppInstance.h"
|
2010-10-08 14:48:37 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
#include "ContentChild.h"
|
2010-11-24 06:15:03 -08:00
|
|
|
#include "CrashReporterChild.h"
|
2009-08-12 09:18:08 -07:00
|
|
|
#include "TabChild.h"
|
|
|
|
|
2012-09-04 17:36:16 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "mozilla/dom/ExternalHelperAppChild.h"
|
|
|
|
#include "mozilla/dom/PCrashReporterChild.h"
|
2013-04-15 05:38:48 -07:00
|
|
|
#include "mozilla/dom/DOMStorageIPC.h"
|
2012-09-04 17:36:16 -07:00
|
|
|
#include "mozilla/Hal.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "mozilla/hal_sandbox/PHalChild.h"
|
2013-01-17 12:06:36 -08:00
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
2009-08-12 11:31:48 -07:00
|
|
|
#include "mozilla/ipc/TestShellChild.h"
|
2009-11-06 12:43:39 -08:00
|
|
|
#include "mozilla/ipc/XPCShellEnvironment.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
2012-08-29 05:24:48 -07:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "mozilla/layers/PCompositorChild.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2011-11-02 07:51:39 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-08-12 12:58:35 -07:00
|
|
|
#ifdef MOZ_CONTENT_SANDBOX
|
|
|
|
#include "mozilla/Sandbox.h"
|
|
|
|
#endif
|
2012-12-14 16:01:34 -08:00
|
|
|
#include "mozilla/unused.h"
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
#include "nsIMemoryReporter.h"
|
2012-10-29 17:41:14 -07:00
|
|
|
#include "nsIMemoryInfoDumper.h"
|
2013-01-10 10:16:40 -08:00
|
|
|
#include "nsIMutable.h"
|
2010-07-21 11:42:32 -07:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsTObserverArray.h"
|
|
|
|
#include "nsIObserver.h"
|
2012-08-08 19:58:06 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2010-07-21 11:42:32 -07:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-08-27 10:10:39 -07:00
|
|
|
#include "nsStyleSheetService.h"
|
2009-08-25 16:39:30 -07:00
|
|
|
#include "nsXULAppAPI.h"
|
2010-07-21 11:42:32 -07:00
|
|
|
#include "nsWeakReference.h"
|
2010-09-23 18:39:32 -07:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsIConsoleService.h"
|
2011-09-13 10:53:51 -07:00
|
|
|
#include "nsJSEnvironment.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "SandboxHal.h"
|
2012-04-10 12:57:20 -07:00
|
|
|
#include "nsDebugImpl.h"
|
2013-04-25 17:53:26 -07:00
|
|
|
#include "nsHashPropertyBag.h"
|
2012-08-15 18:46:03 -07:00
|
|
|
#include "nsLayoutStylesheetCache.h"
|
2013-07-03 00:24:32 -07:00
|
|
|
#include "nsIJSRuntimeService.h"
|
2009-08-25 16:07:22 -07:00
|
|
|
|
2012-11-09 01:55:54 -08:00
|
|
|
#include "IHistory.h"
|
2010-07-02 08:50:41 -07:00
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "base/message_loop.h"
|
2012-07-17 16:59:45 -07:00
|
|
|
#include "base/process_util.h"
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "base/task.h"
|
|
|
|
|
2010-03-10 21:33:00 -08:00
|
|
|
#include "nsChromeRegistryContent.h"
|
|
|
|
#include "mozilla/chrome/RegistryMessageUtils.h"
|
2010-08-31 11:58:35 -07:00
|
|
|
#include "nsFrameMessageManager.h"
|
2010-03-10 21:33:00 -08:00
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
#include "nsIGeolocationProvider.h"
|
2013-07-03 00:24:32 -07:00
|
|
|
#include "JavaScriptParent.h"
|
2011-02-16 10:43:23 -08:00
|
|
|
#include "mozilla/dom/PMemoryReportRequestChild.h"
|
2010-09-20 21:16:37 -07:00
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
|
|
|
#include "nsPermission.h"
|
|
|
|
#include "nsPermissionManager.h"
|
|
|
|
#endif
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 06:15:03 -08:00
|
|
|
#include "APKOpen.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-03 16:48:58 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
#include "nsVolume.h"
|
2013-05-17 12:55:14 -07:00
|
|
|
#include "nsVolumeService.h"
|
2012-08-03 16:48:58 -07:00
|
|
|
#endif
|
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <process.h>
|
|
|
|
#define getpid _getpid
|
|
|
|
#endif
|
|
|
|
|
2011-07-20 21:37:32 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBChild.h"
|
2013-03-01 00:38:47 -08:00
|
|
|
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
2013-09-06 23:19:53 -07:00
|
|
|
#include "mozilla/dom/telephony/TelephonyChild.h"
|
2012-06-19 16:14:39 -07:00
|
|
|
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
2012-09-13 09:37:14 -07:00
|
|
|
#include "mozilla/dom/bluetooth/PBluetoothChild.h"
|
2013-09-03 15:28:06 -07:00
|
|
|
#include "mozilla/dom/PFMRadioChild.h"
|
2013-01-17 12:17:33 -08:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2013-04-03 15:13:17 -07:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
#include "mozilla/dom/PSpeechSynthesisChild.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-02 23:25:30 -07:00
|
|
|
#include "nsDOMFile.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "nsIRemoteBlob.h"
|
2012-09-10 21:30:33 -07:00
|
|
|
#include "ProcessUtils.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "StructuredCloneUtils.h"
|
2012-08-23 12:33:46 -07:00
|
|
|
#include "URIUtils.h"
|
2012-08-25 09:53:48 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsIPrincipal.h"
|
2012-10-04 13:40:45 -07:00
|
|
|
#include "nsDeviceStorage.h"
|
2012-12-05 19:01:58 -08:00
|
|
|
#include "AudioChannelService.h"
|
2013-07-03 00:24:32 -07:00
|
|
|
#include "JavaScriptChild.h"
|
2013-01-26 13:14:01 -08:00
|
|
|
#include "ProcessPriorityManager.h"
|
2011-11-20 14:40:53 -08:00
|
|
|
|
2012-09-04 17:36:16 -07:00
|
|
|
using namespace base;
|
2012-12-14 16:01:34 -08:00
|
|
|
using namespace mozilla;
|
2010-10-20 10:12:32 -07:00
|
|
|
using namespace mozilla::docshell;
|
2012-09-13 09:37:14 -07:00
|
|
|
using namespace mozilla::dom::bluetooth;
|
2012-06-19 16:14:39 -07:00
|
|
|
using namespace mozilla::dom::devicestorage;
|
2013-01-26 13:14:01 -08:00
|
|
|
using namespace mozilla::dom::ipc;
|
2013-03-01 00:38:47 -08:00
|
|
|
using namespace mozilla::dom::mobilemessage;
|
2012-07-14 04:24:20 -07:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2013-09-06 23:19:53 -07:00
|
|
|
using namespace mozilla::dom::telephony;
|
2012-07-17 16:59:45 -07:00
|
|
|
using namespace mozilla::hal_sandbox;
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
using namespace mozilla::net;
|
2013-07-03 00:24:32 -07:00
|
|
|
using namespace mozilla::jsipc;
|
2012-08-03 16:48:58 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
using namespace mozilla::system;
|
|
|
|
#endif
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2011-02-16 10:43:23 -08:00
|
|
|
|
|
|
|
class MemoryReportRequestChild : public PMemoryReportRequestChild
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MemoryReportRequestChild();
|
|
|
|
virtual ~MemoryReportRequestChild();
|
|
|
|
};
|
|
|
|
|
|
|
|
MemoryReportRequestChild::MemoryReportRequestChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryReportRequestChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryReportRequestChild::~MemoryReportRequestChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(MemoryReportRequestChild);
|
|
|
|
}
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
class AlertObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
AlertObserver(nsIObserver *aObserver, const nsString& aData)
|
2010-12-05 05:15:36 -08:00
|
|
|
: mObserver(aObserver)
|
|
|
|
, mData(aData)
|
2010-09-15 09:44:57 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~AlertObserver() {}
|
|
|
|
|
|
|
|
bool ShouldRemoveFrom(nsIObserver* aObserver,
|
|
|
|
const nsString& aData) const
|
|
|
|
{
|
|
|
|
return (mObserver == aObserver &&
|
|
|
|
mData == aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Observes(const nsString& aData) const
|
|
|
|
{
|
|
|
|
return mData.Equals(aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Notify(const nsCString& aType) const
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mObserver->Observe(nullptr, aType.get(), mData.get());
|
2010-09-15 09:44:57 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIObserver> mObserver;
|
|
|
|
nsString mData;
|
|
|
|
};
|
|
|
|
|
2012-06-14 19:31:55 -07:00
|
|
|
class ConsoleListener MOZ_FINAL : public nsIConsoleListener
|
2010-09-23 18:39:32 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ConsoleListener(ContentChild* aChild)
|
|
|
|
: mChild(aChild) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICONSOLELISTENER
|
|
|
|
|
|
|
|
private:
|
|
|
|
ContentChild* mChild;
|
|
|
|
friend class ContentChild;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(ConsoleListener, nsIConsoleListener)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ConsoleListener::Observe(nsIConsoleMessage* aMessage)
|
|
|
|
{
|
|
|
|
if (!mChild)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
|
|
|
|
if (scriptError) {
|
|
|
|
nsString msg, sourceName, sourceLine;
|
|
|
|
nsXPIDLCString category;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t lineNum, colNum, flags;
|
2010-09-23 18:39:32 -07:00
|
|
|
|
|
|
|
nsresult rv = scriptError->GetErrorMessage(msg);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetSourceName(sourceName);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetSourceLine(sourceLine);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetCategory(getter_Copies(category));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetLineNumber(&lineNum);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetColumnNumber(&colNum);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetFlags(&flags);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mChild->SendScriptError(msg, sourceName, sourceLine,
|
|
|
|
lineNum, colNum, flags, category);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsXPIDLString msg;
|
|
|
|
nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mChild->SendConsoleMessage(msg);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-07-21 11:42:32 -07:00
|
|
|
|
2013-02-14 12:41:30 -08:00
|
|
|
class SystemMessageHandledObserver MOZ_FINAL : public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
};
|
|
|
|
|
|
|
|
void SystemMessageHandledObserver::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
|
|
|
|
if (os) {
|
2013-05-17 05:18:35 -07:00
|
|
|
os->AddObserver(this, "handle-system-messages-done",
|
2013-02-14 12:41:30 -08:00
|
|
|
/* ownsWeak */ false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
SystemMessageHandledObserver::Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
|
|
|
{
|
|
|
|
if (ContentChild::GetSingleton()) {
|
|
|
|
ContentChild::GetSingleton()->SendSystemMessageHandled();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(SystemMessageHandledObserver, nsIObserver)
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild* ContentChild::sSingleton;
|
2009-08-12 17:32:50 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::ContentChild()
|
2013-01-11 03:19:02 -08:00
|
|
|
: mID(uint64_t(-1))
|
2010-11-24 10:22:40 -08:00
|
|
|
#ifdef ANDROID
|
2012-08-09 16:14:55 -07:00
|
|
|
,mScreenSize(0, 0)
|
2010-11-24 10:22:40 -08:00
|
|
|
#endif
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2012-04-10 12:57:20 -07:00
|
|
|
// This process is a content process, so it's clearly running in
|
|
|
|
// multiprocess mode!
|
|
|
|
nsDebugImpl::SetMultiprocessMode("Child");
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::~ContentChild()
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::Init(MessageLoop* aIOLoop,
|
|
|
|
base::ProcessHandle aParentHandle,
|
|
|
|
IPC::Channel* aChannel)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2012-06-27 17:15:32 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2010-08-20 16:24:40 -07:00
|
|
|
// sigh
|
|
|
|
gtk_init(NULL, NULL);
|
|
|
|
#endif
|
2010-10-08 14:48:37 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
// sigh, seriously
|
2010-10-08 23:05:50 -07:00
|
|
|
nsQAppInstance::AddRef();
|
2010-10-08 14:48:37 -07:00
|
|
|
#endif
|
2010-08-20 16:24:40 -07:00
|
|
|
|
2010-09-09 18:25:26 -07:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
// Do this after initializing GDK, or GDK will install its own handler.
|
|
|
|
XRE_InstallX11ErrorHandler();
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
NS_ASSERTION(!sSingleton, "only one ContentChild per child");
|
2010-11-05 09:38:17 -07:00
|
|
|
|
2009-10-27 14:52:37 -07:00
|
|
|
Open(aChannel, aParentHandle, aIOLoop);
|
2009-08-12 17:32:50 -07:00
|
|
|
sSingleton = this;
|
|
|
|
|
2011-06-08 12:56:31 -07:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
SendPCrashReporterConstructor(CrashReporter::CurrentThreadId(),
|
|
|
|
XRE_GetProcessType());
|
2010-11-24 06:15:03 -08:00
|
|
|
#endif
|
|
|
|
|
2013-01-26 13:14:01 -08:00
|
|
|
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
|
|
|
|
|
2013-07-10 15:05:39 -07:00
|
|
|
GetCPOWManager();
|
|
|
|
|
2012-09-10 21:30:33 -07:00
|
|
|
if (mIsForApp && !mIsForBrowser) {
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 10:32:37 -08:00
|
|
|
SetProcessName(NS_LITERAL_STRING("(Preallocated app)"));
|
2012-09-10 21:30:33 -07:00
|
|
|
} else {
|
2012-10-05 14:54:54 -07:00
|
|
|
SetProcessName(NS_LITERAL_STRING("Browser"));
|
2012-09-10 21:30:33 -07:00
|
|
|
}
|
2012-09-04 17:36:16 -07:00
|
|
|
|
2009-08-12 17:32:50 -07:00
|
|
|
return true;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2012-10-05 14:54:54 -07:00
|
|
|
void
|
|
|
|
ContentChild::SetProcessName(const nsAString& aName)
|
|
|
|
{
|
2012-12-12 15:30:44 -08:00
|
|
|
char* name;
|
|
|
|
if ((name = PR_GetEnv("MOZ_DEBUG_APP_PROCESS")) &&
|
|
|
|
aName.EqualsASCII(name)) {
|
|
|
|
#ifdef OS_POSIX
|
|
|
|
printf_stderr("\n\nCHILDCHILDCHILDCHILD\n [%s] debug me @%d\n\n", name, getpid());
|
|
|
|
sleep(30);
|
|
|
|
#elif defined(OS_WIN)
|
2013-08-16 16:38:17 -07:00
|
|
|
// Windows has a decent JIT debugging story, so NS_DebugBreak does the
|
|
|
|
// right thing.
|
|
|
|
NS_DebugBreak(NS_DEBUG_BREAK,
|
|
|
|
"Invoking NS_DebugBreak() to debug child process",
|
|
|
|
nullptr, __FILE__, __LINE__);
|
2012-12-12 15:30:44 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-10-05 14:54:54 -07:00
|
|
|
mProcessName = aName;
|
|
|
|
mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
const void
|
|
|
|
ContentChild::GetProcessName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Assign(mProcessName);
|
|
|
|
}
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
void
|
|
|
|
ContentChild::InitXPCOM()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (!svc) {
|
|
|
|
NS_WARNING("Couldn't acquire console service");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mConsoleListener = new ConsoleListener(this);
|
|
|
|
if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
|
|
|
|
NS_WARNING("Couldn't register console listener for child process");
|
2012-11-08 13:09:39 -08:00
|
|
|
|
|
|
|
bool isOffline;
|
|
|
|
SendGetXPCOMProcessAttributes(&isOffline);
|
|
|
|
RecvSetOffline(isOffline);
|
2013-01-09 07:03:28 -08:00
|
|
|
|
|
|
|
DebugOnly<FileUpdateDispatcher*> observer = FileUpdateDispatcher::GetSingleton();
|
|
|
|
NS_ASSERTION(observer, "FileUpdateDispatcher is null");
|
2013-02-14 12:41:30 -08:00
|
|
|
|
|
|
|
// This object is held alive by the observer service.
|
|
|
|
nsRefPtr<SystemMessageHandledObserver> sysMsgObserver =
|
|
|
|
new SystemMessageHandledObserver();
|
|
|
|
sysMsgObserver->Init();
|
2010-09-23 18:39:32 -07:00
|
|
|
}
|
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
PMemoryReportRequestChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPMemoryReportRequestChild()
|
2011-02-16 10:43:23 -08:00
|
|
|
{
|
|
|
|
return new MemoryReportRequestChild();
|
|
|
|
}
|
|
|
|
|
2011-06-29 16:39:32 -07:00
|
|
|
// This is just a wrapper for InfallibleTArray<MemoryReport> that implements
|
2013-08-27 16:24:51 -07:00
|
|
|
// nsISupports, so it can be passed to nsIMemoryReporter::CollectReports.
|
2012-06-14 19:31:55 -07:00
|
|
|
class MemoryReportsWrapper MOZ_FINAL : public nsISupports {
|
2011-06-29 16:39:32 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
MemoryReportsWrapper(InfallibleTArray<MemoryReport> *r) : mReports(r) { }
|
|
|
|
InfallibleTArray<MemoryReport> *mReports;
|
|
|
|
};
|
|
|
|
NS_IMPL_ISUPPORTS0(MemoryReportsWrapper)
|
|
|
|
|
2013-08-27 16:24:51 -07:00
|
|
|
class MemoryReportCallback MOZ_FINAL : public nsIMemoryReporterCallback
|
2011-06-29 16:39:32 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
MemoryReportCallback(const nsACString &aProcess)
|
|
|
|
: mProcess(aProcess)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Callback(const nsACString &aProcess, const nsACString &aPath,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aKind, int32_t aUnits, int64_t aAmount,
|
2011-06-29 16:39:32 -07:00
|
|
|
const nsACString &aDescription,
|
|
|
|
nsISupports *aiWrappedReports)
|
|
|
|
{
|
|
|
|
MemoryReportsWrapper *wrappedReports =
|
|
|
|
static_cast<MemoryReportsWrapper *>(aiWrappedReports);
|
|
|
|
|
|
|
|
MemoryReport memreport(mProcess, nsCString(aPath), aKind, aUnits,
|
|
|
|
aAmount, nsCString(aDescription));
|
|
|
|
wrappedReports->mReports->AppendElement(memreport);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const nsCString mProcess;
|
|
|
|
};
|
|
|
|
NS_IMPL_ISUPPORTS1(
|
|
|
|
MemoryReportCallback
|
2013-08-27 16:24:51 -07:00
|
|
|
, nsIMemoryReporterCallback
|
2011-06-29 16:39:32 -07:00
|
|
|
)
|
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* child)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
|
2011-06-29 16:39:32 -07:00
|
|
|
InfallibleTArray<MemoryReport> reports;
|
|
|
|
|
2012-04-24 11:43:00 -07:00
|
|
|
nsPrintfCString process("Content (%d)", getpid());
|
2011-06-29 16:39:32 -07:00
|
|
|
|
2013-08-27 16:24:51 -07:00
|
|
|
// Run each reporter. The callback will turn each measurement into a
|
|
|
|
// MemoryReport.
|
2011-06-29 16:39:32 -07:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> e;
|
|
|
|
mgr->EnumerateReporters(getter_AddRefs(e));
|
2011-07-06 22:54:34 -07:00
|
|
|
nsRefPtr<MemoryReportsWrapper> wrappedReports =
|
|
|
|
new MemoryReportsWrapper(&reports);
|
|
|
|
nsRefPtr<MemoryReportCallback> cb = new MemoryReportCallback(process);
|
2013-08-27 16:24:51 -07:00
|
|
|
bool more;
|
2011-06-29 16:39:32 -07:00
|
|
|
while (NS_SUCCEEDED(e->HasMoreElements(&more)) && more) {
|
2013-08-27 16:24:51 -07:00
|
|
|
nsCOMPtr<nsIMemoryReporter> r;
|
2011-06-29 16:39:32 -07:00
|
|
|
e->GetNext(getter_AddRefs(r));
|
2011-07-06 22:54:34 -07:00
|
|
|
r->CollectReports(cb, wrappedReports);
|
2011-02-16 10:43:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
child->Send__delete__(child, reports);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-05 19:01:58 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAudioChannelNotify()
|
|
|
|
{
|
|
|
|
nsRefPtr<AudioChannelService> service =
|
|
|
|
AudioChannelService::GetAudioChannelService();
|
|
|
|
if (service) {
|
|
|
|
service->Notify();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor)
|
2011-02-16 10:43:23 -08:00
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-02 18:19:11 -07:00
|
|
|
bool
|
2013-03-27 20:31:26 -07:00
|
|
|
ContentChild::RecvDumpMemoryInfoToTempDir(const nsString& aIdentifier,
|
2012-10-02 18:19:11 -07:00
|
|
|
const bool& aMinimizeMemoryUsage,
|
|
|
|
const bool& aDumpChildProcesses)
|
|
|
|
{
|
2012-10-29 17:41:14 -07:00
|
|
|
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
|
|
|
|
2013-03-27 20:31:26 -07:00
|
|
|
dumper->DumpMemoryInfoToTempDir(aIdentifier, aMinimizeMemoryUsage,
|
|
|
|
aDumpChildProcesses);
|
2012-10-02 18:19:11 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-15 19:12:14 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvDumpGCAndCCLogsToFile(const nsString& aIdentifier,
|
2013-07-08 10:20:39 -07:00
|
|
|
const bool& aDumpAllTraces,
|
2012-10-15 19:12:14 -07:00
|
|
|
const bool& aDumpChildProcesses)
|
|
|
|
{
|
2012-10-29 17:41:14 -07:00
|
|
|
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
|
|
|
|
2013-07-08 10:20:39 -07:00
|
|
|
dumper->DumpGCAndCCLogsToFile(aIdentifier, aDumpAllTraces,
|
|
|
|
aDumpChildProcesses);
|
2012-10-15 19:12:14 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
PCompositorChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
2012-07-17 16:59:45 -07:00
|
|
|
{
|
|
|
|
return CompositorChild::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:24:48 -07:00
|
|
|
PImageBridgeChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
2012-08-29 05:24:48 -07:00
|
|
|
{
|
|
|
|
return ImageBridgeChild::StartUpInChildProcess(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2013-01-17 12:06:36 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvSetProcessPrivileges(const ChildPrivileges& aPrivs)
|
|
|
|
{
|
|
|
|
ChildPrivileges privs = (aPrivs == PRIVILEGES_DEFAULT) ?
|
|
|
|
GeckoChildProcessHost::DefaultChildPrivileges() :
|
|
|
|
aPrivs;
|
|
|
|
// If this fails, we die.
|
|
|
|
SetCurrentProcessPrivileges(privs);
|
2013-08-12 12:58:35 -07:00
|
|
|
#ifdef MOZ_CONTENT_SANDBOX
|
|
|
|
// SetCurrentProcessSandbox should be moved close to process initialization
|
|
|
|
// time if/when possible. SetCurrentProcessPrivileges should probably be
|
|
|
|
// moved as well. Right now this is set ONLY if we receive the
|
|
|
|
// RecvSetProcessPrivileges message. See bug 880808.
|
|
|
|
SetCurrentProcessSandbox();
|
|
|
|
#endif
|
2013-01-17 12:06:36 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-27 12:43:52 -08:00
|
|
|
static CancelableTask* sFirstIdleTask;
|
|
|
|
|
2012-10-08 21:46:19 -07:00
|
|
|
static void FirstIdle(void)
|
|
|
|
{
|
2012-11-27 12:43:52 -08:00
|
|
|
MOZ_ASSERT(sFirstIdleTask);
|
|
|
|
sFirstIdleTask = nullptr;
|
2012-10-08 21:46:19 -07:00
|
|
|
ContentChild::GetSingleton()->SendFirstIdle();
|
|
|
|
}
|
|
|
|
|
2013-07-03 00:24:32 -07:00
|
|
|
mozilla::jsipc::PJavaScriptChild *
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPJavaScriptChild()
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIJSRuntimeService> svc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
|
|
|
|
NS_ENSURE_TRUE(svc, NULL);
|
|
|
|
|
|
|
|
JSRuntime *rt;
|
|
|
|
svc->GetRuntime(&rt);
|
|
|
|
NS_ENSURE_TRUE(svc, NULL);
|
|
|
|
|
|
|
|
mozilla::jsipc::JavaScriptChild *child = new mozilla::jsipc::JavaScriptChild(rt);
|
|
|
|
if (!child->init()) {
|
|
|
|
delete child;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
|
|
|
delete child;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
PBrowserChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2013-02-22 20:24:28 -08:00
|
|
|
// We'll happily accept any kind of IPCTabContext here; we don't need to
|
|
|
|
// check that it's of a certain type for security purposes, because we
|
|
|
|
// believe whatever the parent process tells us.
|
|
|
|
|
2013-07-30 14:42:34 -07:00
|
|
|
MaybeInvalidTabContext tc(aContext);
|
|
|
|
if (!tc.IsValid()) {
|
|
|
|
NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
|
|
|
|
"the parent process. (%s) Crashing...",
|
|
|
|
tc.GetInvalidReason()).get());
|
|
|
|
MOZ_CRASH("Invalid TabContext received from the parent process.");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<TabChild> child = TabChild::Create(this, tc.GetTabContext(), aChromeFlags);
|
2013-02-22 20:24:28 -08:00
|
|
|
|
2013-07-08 08:48:39 -07:00
|
|
|
// The ref here is released in DeallocPBrowserChild.
|
2013-02-22 20:24:28 -08:00
|
|
|
return child.forget().get();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
|
|
|
|
const IPCTabContext& context,
|
|
|
|
const uint32_t& chromeFlags)
|
|
|
|
{
|
2013-07-08 08:48:39 -07:00
|
|
|
// This runs after AllocPBrowserChild() returns and the IPC machinery for this
|
2013-02-22 20:24:28 -08:00
|
|
|
// PBrowserChild has been set up.
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
nsITabChild* tc =
|
|
|
|
static_cast<nsITabChild*>(static_cast<TabChild*>(actor));
|
|
|
|
os->NotifyObservers(tc, "tab-child-created", nullptr);
|
|
|
|
}
|
|
|
|
|
2013-01-26 13:14:01 -08:00
|
|
|
static bool hasRunOnce = false;
|
|
|
|
if (!hasRunOnce) {
|
|
|
|
hasRunOnce = true;
|
|
|
|
|
2012-11-27 12:43:52 -08:00
|
|
|
MOZ_ASSERT(!sFirstIdleTask);
|
|
|
|
sFirstIdleTask = NewRunnableFunction(FirstIdle);
|
|
|
|
MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
|
2012-10-08 21:46:19 -07:00
|
|
|
}
|
|
|
|
|
2013-02-22 20:24:28 -08:00
|
|
|
return true;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2013-02-22 20:24:28 -08:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPBrowserChild(PBrowserChild* iframe)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-05-14 22:27:52 -07:00
|
|
|
TabChild* child = static_cast<TabChild*>(iframe);
|
|
|
|
NS_RELEASE(child);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
PBlobChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPBlobChild(const BlobConstructorParams& aParams)
|
2012-08-01 23:02:29 -07:00
|
|
|
{
|
2013-07-16 13:07:09 -07:00
|
|
|
return BlobChild::Create(this, aParams);
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPBlobChild(PBlobChild* aActor)
|
2012-08-01 23:02:29 -07:00
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-17 12:17:33 -08:00
|
|
|
BlobChild*
|
|
|
|
ContentChild::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
2012-08-01 23:02:29 -07:00
|
|
|
{
|
2013-08-29 10:16:44 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aBlob);
|
|
|
|
|
|
|
|
// If the blob represents a remote blob then we can simply pass its actor back
|
|
|
|
// here.
|
|
|
|
if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob)) {
|
|
|
|
BlobChild* actor =
|
|
|
|
static_cast<BlobChild*>(
|
|
|
|
static_cast<PBlobChild*>(remoteBlob->GetPBlob()));
|
|
|
|
MOZ_ASSERT(actor);
|
|
|
|
return actor;
|
|
|
|
}
|
2013-01-17 12:17:33 -08:00
|
|
|
|
|
|
|
// XXX This is only safe so long as all blob implementations in our tree
|
|
|
|
// inherit nsDOMFileBase. If that ever changes then this will need to grow
|
|
|
|
// a real interface or something.
|
|
|
|
const nsDOMFileBase* blob = static_cast<nsDOMFileBase*>(aBlob);
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2013-08-29 10:16:44 -07:00
|
|
|
// We often pass blobs that are multipart but that only contain one sub-blob
|
|
|
|
// (WebActivities does this a bunch). Unwrap to reduce the number of actors
|
|
|
|
// that we have to maintain.
|
|
|
|
const nsTArray<nsCOMPtr<nsIDOMBlob> >* subBlobs = blob->GetSubBlobs();
|
|
|
|
if (subBlobs && subBlobs->Length() == 1) {
|
|
|
|
const nsCOMPtr<nsIDOMBlob>& subBlob = subBlobs->ElementAt(0);
|
|
|
|
MOZ_ASSERT(subBlob);
|
|
|
|
|
|
|
|
// We can only take this shortcut if the multipart and the sub-blob are both
|
|
|
|
// Blob objects or both File objects.
|
|
|
|
nsCOMPtr<nsIDOMFile> multipartBlobAsFile = do_QueryInterface(aBlob);
|
|
|
|
nsCOMPtr<nsIDOMFile> subBlobAsFile = do_QueryInterface(subBlob);
|
|
|
|
if (!multipartBlobAsFile == !subBlobAsFile) {
|
|
|
|
// The wrapping was unnecessary, see if we can simply pass an existing
|
|
|
|
// remote blob.
|
|
|
|
if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(subBlob)) {
|
|
|
|
BlobChild* actor =
|
|
|
|
static_cast<BlobChild*>(
|
|
|
|
static_cast<PBlobChild*>(remoteBlob->GetPBlob()));
|
|
|
|
MOZ_ASSERT(actor);
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No need to add a reference here since the original blob must have a
|
|
|
|
// strong reference in the caller and it must also have a strong reference
|
|
|
|
// to this sub-blob.
|
|
|
|
aBlob = subBlob;
|
|
|
|
blob = static_cast<nsDOMFileBase*>(aBlob);
|
|
|
|
subBlobs = blob->GetSubBlobs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 12:17:33 -08:00
|
|
|
// All blobs shared between processes must be immutable.
|
|
|
|
nsCOMPtr<nsIMutable> mutableBlob = do_QueryInterface(aBlob);
|
|
|
|
if (!mutableBlob || NS_FAILED(mutableBlob->SetMutable(false))) {
|
|
|
|
NS_WARNING("Failed to make blob immutable!");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParentBlobConstructorParams params;
|
|
|
|
|
|
|
|
if (blob->IsSizeUnknown() || blob->IsDateUnknown()) {
|
2012-10-18 11:29:32 -07:00
|
|
|
// We don't want to call GetSize or GetLastModifiedDate
|
|
|
|
// yet since that may stat a file on the main thread
|
|
|
|
// here. Instead we'll learn the size lazily from the
|
|
|
|
// other process.
|
2013-01-17 12:17:33 -08:00
|
|
|
params.blobParams() = MysteryBlobConstructorParams();
|
|
|
|
params.optionalInputStreamParams() = void_t();
|
2012-08-02 23:25:30 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsString contentType;
|
|
|
|
nsresult rv = aBlob->GetType(contentType);
|
2013-01-17 12:17:33 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t length;
|
2012-08-02 23:25:30 -07:00
|
|
|
rv = aBlob->GetSize(&length);
|
2013-01-17 12:17:33 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
|
|
|
rv = aBlob->GetInternalStream(getter_AddRefs(stream));
|
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
|
|
|
|
|
|
InputStreamParams inputStreamParams;
|
|
|
|
SerializeInputStream(stream, inputStreamParams);
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2013-01-17 12:17:33 -08:00
|
|
|
params.optionalInputStreamParams() = inputStreamParams;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(aBlob);
|
2012-08-02 23:25:30 -07:00
|
|
|
if (file) {
|
|
|
|
FileBlobConstructorParams fileParams;
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2012-08-02 23:25:30 -07:00
|
|
|
rv = file->GetName(fileParams.name());
|
2013-01-17 12:17:33 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2012-10-18 11:29:32 -07:00
|
|
|
rv = file->GetMozLastModifiedDate(&fileParams.modDate());
|
2013-01-17 12:17:33 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-10-18 11:29:32 -07:00
|
|
|
|
2012-08-02 23:25:30 -07:00
|
|
|
fileParams.contentType() = contentType;
|
|
|
|
fileParams.length() = length;
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2013-01-17 12:17:33 -08:00
|
|
|
params.blobParams() = fileParams;
|
2012-08-02 23:25:30 -07:00
|
|
|
} else {
|
|
|
|
NormalBlobConstructorParams blobParams;
|
|
|
|
blobParams.contentType() = contentType;
|
|
|
|
blobParams.length() = length;
|
2013-01-17 12:17:33 -08:00
|
|
|
params.blobParams() = blobParams;
|
2012-08-02 23:25:30 -07:00
|
|
|
}
|
2013-08-29 10:16:44 -07:00
|
|
|
}
|
2012-08-01 23:02:29 -07:00
|
|
|
|
2013-07-16 13:07:09 -07:00
|
|
|
BlobChild* actor = BlobChild::Create(this, aBlob);
|
2012-08-01 23:02:29 -07:00
|
|
|
NS_ENSURE_TRUE(actor, nullptr);
|
|
|
|
|
2013-08-29 10:16:44 -07:00
|
|
|
return SendPBlobConstructor(actor, params) ? actor : nullptr;
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
|
|
|
|
2010-11-24 06:15:03 -08:00
|
|
|
PCrashReporterChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id,
|
|
|
|
const uint32_t& processType)
|
2010-11-24 06:15:03 -08:00
|
|
|
{
|
2011-06-08 12:56:31 -07:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2010-11-24 06:15:03 -08:00
|
|
|
return new CrashReporterChild();
|
2011-06-08 12:56:31 -07:00
|
|
|
#else
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-06-08 12:56:31 -07:00
|
|
|
#endif
|
2010-11-24 06:15:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPCrashReporterChild(PCrashReporterChild* crashreporter)
|
2010-11-24 06:15:03 -08:00
|
|
|
{
|
|
|
|
delete crashreporter;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-05 15:15:45 -07:00
|
|
|
PHalChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPHalChild()
|
2011-10-05 15:15:45 -07:00
|
|
|
{
|
|
|
|
return CreateHalChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPHalChild(PHalChild* aHal)
|
2011-10-05 15:15:45 -07:00
|
|
|
{
|
|
|
|
delete aHal;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-14 04:24:20 -07:00
|
|
|
PIndexedDBChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPIndexedDBChild()
|
2012-07-14 04:24:20 -07:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("Should never get here!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPIndexedDBChild(PIndexedDBChild* aActor)
|
2012-07-14 04:24:20 -07:00
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PTestShellChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPTestShellChild()
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
2010-05-14 22:27:52 -07:00
|
|
|
return new TestShellChild();
|
2009-08-12 11:31:48 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPTestShellChild(PTestShellChild* shell)
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
2010-05-14 22:27:52 -07:00
|
|
|
delete shell;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-25 16:07:22 -07:00
|
|
|
}
|
|
|
|
|
2013-07-03 00:24:32 -07:00
|
|
|
jsipc::JavaScriptChild *
|
|
|
|
ContentChild::GetCPOWManager()
|
|
|
|
{
|
|
|
|
if (ManagedPJavaScriptChild().Length()) {
|
|
|
|
return static_cast<JavaScriptChild*>(ManagedPJavaScriptChild()[0]);
|
|
|
|
}
|
|
|
|
JavaScriptChild* actor = static_cast<JavaScriptChild*>(SendPJavaScriptConstructor());
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
2009-11-06 12:43:39 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::RecvPTestShellConstructor(PTestShellChild* actor)
|
2009-11-06 12:43:39 -08:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-19 16:14:39 -07:00
|
|
|
PDeviceStorageRequestChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPDeviceStorageRequestChild(const DeviceStorageParams& aParams)
|
2012-06-19 16:14:39 -07:00
|
|
|
{
|
|
|
|
return new DeviceStorageRequestChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPDeviceStorageRequestChild(PDeviceStorageRequestChild* aDeviceStorage)
|
2012-06-19 16:14:39 -07:00
|
|
|
{
|
|
|
|
delete aDeviceStorage;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-08 08:48:39 -07:00
|
|
|
PNeckoChild*
|
|
|
|
ContentChild::AllocPNeckoChild()
|
2009-08-18 12:05:15 -07:00
|
|
|
{
|
|
|
|
return new NeckoChild();
|
|
|
|
}
|
|
|
|
|
2013-07-08 08:48:39 -07:00
|
|
|
bool
|
|
|
|
ContentChild::DeallocPNeckoChild(PNeckoChild* necko)
|
2009-08-18 12:05:15 -07:00
|
|
|
{
|
|
|
|
delete necko;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-18 12:05:15 -07:00
|
|
|
}
|
|
|
|
|
2010-09-15 15:55:08 -07:00
|
|
|
PExternalHelperAppChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPExternalHelperAppChild(const OptionalURIParams& uri,
|
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
|
|
|
const bool& aForceSave,
|
|
|
|
const int64_t& aContentLength,
|
|
|
|
const OptionalURIParams& aReferrer)
|
2010-09-15 15:55:08 -07:00
|
|
|
{
|
|
|
|
ExternalHelperAppChild *child = new ExternalHelperAppChild();
|
|
|
|
child->AddRef();
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPExternalHelperAppChild(PExternalHelperAppChild* aService)
|
2010-09-15 15:55:08 -07:00
|
|
|
{
|
|
|
|
ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
|
|
|
|
child->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-20 14:40:53 -08:00
|
|
|
PSmsChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPSmsChild()
|
2011-11-20 14:40:53 -08:00
|
|
|
{
|
|
|
|
return new SmsChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPSmsChild(PSmsChild* aSms)
|
2011-11-20 14:40:53 -08:00
|
|
|
{
|
|
|
|
delete aSms;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-06 23:19:53 -07:00
|
|
|
PTelephonyChild*
|
|
|
|
ContentChild::AllocPTelephonyChild()
|
|
|
|
{
|
|
|
|
MOZ_CRASH("No one should be allocating PTelephonyChild actors");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPTelephonyChild(PTelephonyChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-18 17:15:23 -08:00
|
|
|
PStorageChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPStorageChild()
|
2010-11-18 17:15:23 -08:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("We should never be manually allocating PStorageChild actors");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-11-18 17:15:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPStorageChild(PStorageChild* aActor)
|
2010-11-18 17:15:23 -08:00
|
|
|
{
|
2013-04-15 05:38:48 -07:00
|
|
|
DOMStorageDBChild* child = static_cast<DOMStorageDBChild*>(aActor);
|
2010-11-18 17:15:23 -08:00
|
|
|
child->ReleaseIPDLReference();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-13 09:37:14 -07:00
|
|
|
PBluetoothChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPBluetoothChild()
|
2012-09-13 09:37:14 -07:00
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("No one should be allocating PBluetoothChild actors");
|
2012-09-13 09:37:14 -07:00
|
|
|
#else
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("No support for bluetooth on this platform!");
|
2012-09-13 09:37:14 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPBluetoothChild(PBluetoothChild* aActor)
|
2012-09-13 09:37:14 -07:00
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("No support for bluetooth on this platform!");
|
2012-09-13 09:37:14 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-09-03 15:28:06 -07:00
|
|
|
PFMRadioChild*
|
|
|
|
ContentChild::AllocPFMRadioChild()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
NS_RUNTIMEABORT("No one should be allocating PFMRadioChild actors");
|
|
|
|
return nullptr;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("No support for FMRadio on this platform!");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPFMRadioChild(PFMRadioChild* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("No support for FMRadio on this platform!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-03 15:13:17 -07:00
|
|
|
PSpeechSynthesisChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPSpeechSynthesisChild()
|
2013-04-03 15:13:17 -07:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("No one should be allocating PSpeechSynthesisChild actors");
|
2013-04-03 15:13:17 -07:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor)
|
2013-04-03 15:13:17 -07:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-03-10 21:33:00 -08:00
|
|
|
bool
|
2010-11-08 18:49:00 -08:00
|
|
|
ContentChild::RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
|
|
|
|
const InfallibleTArray<ResourceMapping>& resources,
|
2011-01-11 13:34:31 -08:00
|
|
|
const InfallibleTArray<OverrideMapping>& overrides,
|
|
|
|
const nsCString& locale)
|
2010-03-10 21:33:00 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
2011-01-11 13:34:31 -08:00
|
|
|
chromeRegistry->RegisterRemoteChrome(packages, resources, overrides, locale);
|
2010-03-10 21:33:00 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-11 05:44:12 -07:00
|
|
|
bool
|
2011-09-28 23:19:26 -07:00
|
|
|
ContentChild::RecvSetOffline(const bool& offline)
|
2010-05-11 05:44:12 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIOService> io (do_GetIOService());
|
|
|
|
NS_ASSERTION(io, "IO Service can not be null");
|
|
|
|
|
|
|
|
io->SetOffline(offline);
|
2011-02-14 14:34:46 -08:00
|
|
|
|
2010-05-11 05:44:12 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-12-06 22:03:49 -08:00
|
|
|
void
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::ActorDestroy(ActorDestroyReason why)
|
2009-09-02 17:18:27 -07:00
|
|
|
{
|
2010-08-20 16:24:40 -07:00
|
|
|
if (AbnormalShutdown == why) {
|
|
|
|
NS_WARNING("shutting down early because of crash!");
|
|
|
|
QuickExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
// In release builds, there's no point in the content process
|
|
|
|
// going through the full XPCOM shutdown path, because it doesn't
|
|
|
|
// keep persistent state.
|
|
|
|
QuickExit();
|
|
|
|
#endif
|
2009-09-02 17:18:27 -07:00
|
|
|
|
2012-11-27 12:43:52 -08:00
|
|
|
if (sFirstIdleTask) {
|
|
|
|
sFirstIdleTask->Cancel();
|
|
|
|
}
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
mAlertObservers.Clear();
|
2011-02-14 14:34:46 -08:00
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (svc) {
|
|
|
|
svc->UnregisterListener(mConsoleListener);
|
2012-07-30 07:20:58 -07:00
|
|
|
mConsoleListener->mChild = nullptr;
|
2010-09-23 18:39:32 -07:00
|
|
|
}
|
|
|
|
|
2009-12-06 22:03:49 -08:00
|
|
|
XRE_ShutdownChildProcess();
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
void
|
|
|
|
ContentChild::ProcessingError(Result what)
|
|
|
|
{
|
|
|
|
switch (what) {
|
|
|
|
case MsgDropped:
|
|
|
|
QuickExit();
|
|
|
|
|
|
|
|
case MsgNotKnown:
|
2013-06-03 21:15:40 -07:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgNotKnown");
|
2010-08-20 16:24:40 -07:00
|
|
|
case MsgNotAllowed:
|
2013-06-03 21:15:40 -07:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgNotAllowed");
|
2010-08-20 16:24:40 -07:00
|
|
|
case MsgPayloadError:
|
2013-06-03 21:15:40 -07:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgPayloadError");
|
2010-08-20 16:24:40 -07:00
|
|
|
case MsgProcessingError:
|
2013-06-03 21:15:40 -07:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgProcessingError");
|
2010-08-20 16:24:40 -07:00
|
|
|
case MsgRouteError:
|
2013-06-03 21:15:40 -07:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgRouteError");
|
2010-08-20 16:24:40 -07:00
|
|
|
case MsgValueError:
|
2013-06-03 21:15:40 -07:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgValueError");
|
2010-08-20 16:24:40 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::QuickExit()
|
|
|
|
{
|
|
|
|
NS_WARNING("content process _exit()ing");
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
nsresult
|
|
|
|
ContentChild::AddRemoteAlertObserver(const nsString& aData,
|
|
|
|
nsIObserver* aObserver)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aObserver, "Adding a null observer?");
|
|
|
|
mAlertObservers.AppendElement(new AlertObserver(aObserver, aData));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-25 17:13:47 -07:00
|
|
|
bool
|
2012-08-22 13:00:21 -07:00
|
|
|
ContentChild::RecvPreferenceUpdate(const PrefSetting& aPref)
|
2010-07-21 11:42:32 -07:00
|
|
|
{
|
2012-08-22 13:00:21 -07:00
|
|
|
Preferences::SetPreference(aPref);
|
2010-05-25 17:13:47 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& aData)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < mAlertObservers.Length();
|
2010-09-15 09:44:57 -07:00
|
|
|
/*we mutate the array during the loop; ++i iff no mutation*/) {
|
|
|
|
AlertObserver* observer = mAlertObservers[i];
|
|
|
|
if (observer->Observes(aData) && observer->Notify(aType)) {
|
|
|
|
// if aType == alertfinished, this alert is done. we can
|
|
|
|
// remove the observer.
|
|
|
|
if (aType.Equals(nsDependentCString("alertfinished"))) {
|
|
|
|
mAlertObservers.RemoveElementAt(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 08:50:41 -07:00
|
|
|
bool
|
2012-08-23 12:33:46 -07:00
|
|
|
ContentChild::RecvNotifyVisited(const URIParams& aURI)
|
2010-07-02 08:50:41 -07:00
|
|
|
{
|
2012-08-23 12:33:46 -07:00
|
|
|
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
|
|
|
|
if (!newURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-09 01:55:54 -08:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
|
|
|
history->NotifyVisited(newURI);
|
|
|
|
}
|
2010-07-02 08:50:41 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-31 11:58:35 -07:00
|
|
|
bool
|
2012-08-01 23:02:29 -07:00
|
|
|
ContentChild::RecvAsyncMessage(const nsString& aMsg,
|
2013-07-10 15:05:39 -07:00
|
|
|
const ClonedMessageData& aData,
|
|
|
|
const InfallibleTArray<CpowEntry>& aCpows)
|
2010-08-31 11:58:35 -07:00
|
|
|
{
|
|
|
|
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::sChildProcessManager;
|
|
|
|
if (cpm) {
|
2013-01-24 08:24:19 -08:00
|
|
|
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForChild(aData);
|
2013-07-10 15:05:39 -07:00
|
|
|
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
2010-08-31 11:58:35 -07:00
|
|
|
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
|
2013-07-10 15:05:39 -07:00
|
|
|
aMsg, false, &cloneData, &cpows, nullptr);
|
2010-08-31 11:58:35 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGeolocationUpdate(const GeoPosition& somewhere)
|
|
|
|
{
|
2010-09-20 21:16:37 -07:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> gs = do_GetService("@mozilla.org/geolocation/service;1");
|
2010-09-21 19:36:58 -07:00
|
|
|
if (!gs) {
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
|
|
|
|
gs->Update(position);
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
|
|
|
{
|
|
|
|
#if MOZ_PERMISSIONS
|
2011-08-30 10:45:09 -07:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
|
|
|
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
|
|
|
nsPermissionManager* permissionManager =
|
|
|
|
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
2010-10-09 11:07:38 -07:00
|
|
|
NS_ABORT_IF_FALSE(permissionManager,
|
|
|
|
"We have no permissionManager in the Content process !");
|
|
|
|
|
2012-08-25 09:53:48 -07:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("http://") + nsCString(permission.host));
|
|
|
|
NS_ENSURE_TRUE(uri, true);
|
|
|
|
|
|
|
|
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
|
|
|
|
MOZ_ASSERT(secMan);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
2012-08-23 11:38:01 -07:00
|
|
|
nsresult rv = secMan->GetAppCodebasePrincipal(uri, permission.appId,
|
|
|
|
permission.isInBrowserElement,
|
|
|
|
getter_AddRefs(principal));
|
2012-08-25 09:53:48 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
permissionManager->AddInternal(principal,
|
2010-10-09 11:07:38 -07:00
|
|
|
nsCString(permission.type),
|
|
|
|
permission.capability,
|
|
|
|
0,
|
|
|
|
permission.expireType,
|
|
|
|
permission.expireTime,
|
|
|
|
nsPermissionManager::eNotify,
|
|
|
|
nsPermissionManager::eNoDBOperation);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2010-11-24 10:22:40 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvScreenSizeChanged(const gfxIntSize& size)
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
mScreenSize = size;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Message currently only expected on android");
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-12-11 14:36:08 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvFlushMemory(const nsString& reason)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (os)
|
2012-07-30 07:20:58 -07:00
|
|
|
os->NotifyObservers(nullptr, "memory-pressure", reason.get());
|
2013-01-09 07:03:28 -08:00
|
|
|
return true;
|
2010-12-11 14:36:08 -08:00
|
|
|
}
|
|
|
|
|
2011-07-20 21:37:32 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvActivateA11y()
|
|
|
|
{
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Start accessibility in content process if it's running in chrome
|
|
|
|
// process.
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService =
|
|
|
|
do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-13 10:53:51 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGarbageCollect()
|
|
|
|
{
|
2013-03-19 03:35:41 -07:00
|
|
|
nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
|
2011-09-13 10:53:51 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvCycleCollect()
|
|
|
|
{
|
2013-03-19 03:35:41 -07:00
|
|
|
nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
|
2011-09-13 10:53:51 -07:00
|
|
|
nsJSContext::CycleCollectNow();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:46:03 -07:00
|
|
|
static void
|
|
|
|
PreloadSlowThings()
|
|
|
|
{
|
|
|
|
// This fetches and creates all the built-in stylesheets.
|
|
|
|
nsLayoutStylesheetCache::UserContentSheet();
|
2012-08-29 08:26:18 -07:00
|
|
|
|
|
|
|
TabChild::PreloadSlowThings();
|
2012-08-15 18:46:03 -07:00
|
|
|
}
|
|
|
|
|
2011-10-04 13:31:00 -07:00
|
|
|
bool
|
2013-04-22 09:41:59 -07:00
|
|
|
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
|
|
|
|
const nsCString& name, const nsCString& UAName)
|
2011-10-04 13:31:00 -07:00
|
|
|
{
|
|
|
|
mAppInfo.version.Assign(version);
|
|
|
|
mAppInfo.buildID.Assign(buildID);
|
2013-04-22 09:41:59 -07:00
|
|
|
mAppInfo.name.Assign(name);
|
|
|
|
mAppInfo.UAName.Assign(UAName);
|
2013-01-24 10:39:18 -08:00
|
|
|
// If we're part of the mozbrowser machinery, go ahead and start
|
|
|
|
// preloading things. We can only do this for mozbrowser because
|
|
|
|
// PreloadSlowThings() may set the docshell of the first TabChild
|
|
|
|
// inactive, and we can only safely restore it to active from
|
|
|
|
// BrowserElementChild.js.
|
|
|
|
if ((mIsForApp || mIsForBrowser) &&
|
|
|
|
Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
|
|
|
|
PreloadSlowThings();
|
|
|
|
}
|
2011-10-04 13:31:00 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-19 17:13:20 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvLastPrivateDocShellDestroyed()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2012-07-30 07:20:58 -07:00
|
|
|
obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
2012-04-19 17:13:20 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-01 23:32:04 -07:00
|
|
|
bool
|
2013-05-11 02:10:18 -07:00
|
|
|
ContentChild::RecvFilePathUpdate(const nsString& aStorageType,
|
|
|
|
const nsString& aStorageName,
|
|
|
|
const nsString& aPath,
|
|
|
|
const nsCString& aReason)
|
2012-08-01 23:32:04 -07:00
|
|
|
{
|
2013-05-11 02:10:18 -07:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aStorageType, aStorageName, aPath);
|
2012-08-30 15:17:37 -07:00
|
|
|
|
2012-08-17 19:43:00 -07:00
|
|
|
nsString reason;
|
|
|
|
CopyASCIItoUTF16(aReason, reason);
|
2012-08-01 23:32:04 -07:00
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2012-08-30 15:17:37 -07:00
|
|
|
obs->NotifyObservers(dsf, "file-watcher-update", reason.get());
|
2012-08-01 23:32:04 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-03 16:48:58 -07:00
|
|
|
bool
|
2012-12-14 16:01:34 -08:00
|
|
|
ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
|
2013-05-11 02:10:18 -07:00
|
|
|
const nsString& aVolumeName,
|
2012-12-14 16:01:34 -08:00
|
|
|
const int32_t& aState,
|
2013-08-22 16:12:25 -07:00
|
|
|
const int32_t& aMountGeneration,
|
|
|
|
const bool& aIsMediaPresent,
|
|
|
|
const bool& aIsSharing)
|
2012-08-03 16:48:58 -07:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2013-05-11 02:10:18 -07:00
|
|
|
nsRefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
|
2013-08-22 16:12:25 -07:00
|
|
|
aMountGeneration, aIsMediaPresent,
|
|
|
|
aIsSharing);
|
2012-08-03 16:48:58 -07:00
|
|
|
|
2013-05-17 12:55:14 -07:00
|
|
|
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
|
|
|
|
if (vs) {
|
|
|
|
vs->UpdateVolume(volume);
|
|
|
|
}
|
2012-12-14 16:01:34 -08:00
|
|
|
#else
|
|
|
|
// Remove warnings about unused arguments
|
|
|
|
unused << aFsName;
|
2013-05-11 02:10:18 -07:00
|
|
|
unused << aVolumeName;
|
2012-12-14 16:01:34 -08:00
|
|
|
unused << aState;
|
|
|
|
unused << aMountGeneration;
|
2013-08-22 16:12:25 -07:00
|
|
|
unused << aIsMediaPresent;
|
|
|
|
unused << aIsSharing;
|
2012-08-03 16:48:58 -07:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-25 17:53:26 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyProcessPriorityChanged(
|
|
|
|
const hal::ProcessPriority& aPriority)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
NS_ENSURE_TRUE(os, true);
|
|
|
|
|
|
|
|
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
|
|
|
props->SetPropertyAsInt32(NS_LITERAL_STRING("priority"),
|
|
|
|
static_cast<int32_t>(aPriority));
|
|
|
|
|
|
|
|
os->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
|
|
|
|
"ipc:process-priority-changed", nullptr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvMinimizeMemoryUsage()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
|
|
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
NS_ENSURE_TRUE(mgr, true);
|
|
|
|
|
|
|
|
nsCOMPtr<nsICancelableRunnable> runnable =
|
|
|
|
do_QueryReferent(mMemoryMinimizerRunnable);
|
|
|
|
|
|
|
|
// Cancel the previous task if it's still pending.
|
|
|
|
if (runnable) {
|
|
|
|
runnable->Cancel();
|
|
|
|
runnable = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
mgr->MinimizeMemoryUsage(/* callback = */ nullptr,
|
|
|
|
getter_AddRefs(runnable));
|
|
|
|
mMemoryMinimizerRunnable = do_GetWeakReference(runnable);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvCancelMinimizeMemoryUsage()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICancelableRunnable> runnable =
|
|
|
|
do_QueryReferent(mMemoryMinimizerRunnable);
|
|
|
|
if (runnable) {
|
|
|
|
runnable->Cancel();
|
|
|
|
mMemoryMinimizerRunnable = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-27 10:10:39 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvLoadAndRegisterSheet(const URIParams& aURI, const uint32_t& aType)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
|
|
if (!uri) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
|
|
|
if (sheetService) {
|
|
|
|
sheetService->LoadAndRegisterSheet(uri, aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
|
|
if (!uri) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
|
|
|
if (sheetService) {
|
|
|
|
sheetService->UnregisterSheet(uri, aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
} // namespace dom
|
2013-02-14 12:41:30 -08:00
|
|
|
} // namespace mozilla
|