2009-08-18 19:05:15 +00: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 11:12:37 +00: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 16:18:08 +00:00
|
|
|
|
2012-06-28 00:15:32 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2010-08-20 23:24:40 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#endif
|
|
|
|
|
2010-10-08 21:48:37 +00:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
2010-10-09 06:05:50 +00:00
|
|
|
#include "nsQAppInstance.h"
|
2010-10-08 21:48:37 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
#include "ContentChild.h"
|
2010-11-24 14:15:03 +00:00
|
|
|
#include "CrashReporterChild.h"
|
2009-08-12 16:18:08 +00:00
|
|
|
#include "TabChild.h"
|
|
|
|
|
2012-09-05 00:36:16 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-10-05 22:15:45 +00:00
|
|
|
#include "mozilla/dom/ExternalHelperAppChild.h"
|
|
|
|
#include "mozilla/dom/PCrashReporterChild.h"
|
2013-04-15 12:38:48 +00:00
|
|
|
#include "mozilla/dom/DOMStorageIPC.h"
|
2012-09-05 00:36:16 +00:00
|
|
|
#include "mozilla/Hal.h"
|
2011-10-05 22:15:45 +00:00
|
|
|
#include "mozilla/hal_sandbox/PHalChild.h"
|
2013-01-17 20:06:36 +00:00
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
2009-08-12 18:31:48 +00:00
|
|
|
#include "mozilla/ipc/TestShellChild.h"
|
2009-11-06 20:43:39 +00:00
|
|
|
#include "mozilla/ipc/XPCShellEnvironment.h"
|
|
|
|
#include "mozilla/jsipc/PContextWrapperChild.h"
|
2012-07-17 23:59:45 +00:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
2012-08-29 12:24:48 +00:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2012-07-17 23:59:45 +00:00
|
|
|
#include "mozilla/layers/PCompositorChild.h"
|
2011-10-05 22:15:45 +00:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2011-11-02 14:51:39 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-12-15 00:01:34 +00:00
|
|
|
#include "mozilla/unused.h"
|
2009-08-12 18:31:48 +00:00
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
#include "nsIMemoryReporter.h"
|
2012-10-30 00:41:14 +00:00
|
|
|
#include "nsIMemoryInfoDumper.h"
|
2013-01-10 18:16:40 +00:00
|
|
|
#include "nsIMutable.h"
|
2010-07-21 18:42:32 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsTObserverArray.h"
|
|
|
|
#include "nsIObserver.h"
|
2012-08-09 02:58:06 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2010-07-21 18:42:32 +00:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2009-08-25 23:39:30 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
2010-07-21 18:42:32 +00:00
|
|
|
#include "nsWeakReference.h"
|
2010-09-24 01:39:32 +00:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsIConsoleService.h"
|
2011-09-13 17:53:51 +00:00
|
|
|
#include "nsJSEnvironment.h"
|
2011-10-05 22:15:45 +00:00
|
|
|
#include "SandboxHal.h"
|
2012-04-10 19:57:20 +00:00
|
|
|
#include "nsDebugImpl.h"
|
2013-04-26 00:53:26 +00:00
|
|
|
#include "nsHashPropertyBag.h"
|
2012-08-16 01:46:03 +00:00
|
|
|
#include "nsLayoutStylesheetCache.h"
|
2009-08-25 23:07:22 +00:00
|
|
|
|
2012-11-09 09:55:54 +00:00
|
|
|
#include "IHistory.h"
|
2010-07-02 15:50:41 +00:00
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
#include "base/message_loop.h"
|
2012-07-17 23:59:45 +00:00
|
|
|
#include "base/process_util.h"
|
2009-09-03 00:18:27 +00:00
|
|
|
#include "base/task.h"
|
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
#include "nsChromeRegistryContent.h"
|
|
|
|
#include "mozilla/chrome/RegistryMessageUtils.h"
|
2010-08-31 18:58:35 +00:00
|
|
|
#include "nsFrameMessageManager.h"
|
2010-03-11 05:33:00 +00:00
|
|
|
|
2010-09-21 04:16:37 +00:00
|
|
|
#include "nsIGeolocationProvider.h"
|
2011-02-16 18:43:23 +00:00
|
|
|
#include "mozilla/dom/PMemoryReportRequestChild.h"
|
2010-09-21 04:16:37 +00:00
|
|
|
|
2010-10-09 18:07:38 +00:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
|
|
|
#include "nsPermission.h"
|
|
|
|
#include "nsPermissionManager.h"
|
|
|
|
#endif
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 14:15:03 +00:00
|
|
|
#include "APKOpen.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-03 23:48:58 +00:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
#include "nsVolume.h"
|
2013-05-17 19:55:14 +00:00
|
|
|
#include "nsVolumeService.h"
|
2012-08-03 23:48:58 +00:00
|
|
|
#endif
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <process.h>
|
|
|
|
#define getpid _getpid
|
|
|
|
#endif
|
|
|
|
|
2011-07-21 04:37:32 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "mozilla/dom/indexedDB/PIndexedDBChild.h"
|
2013-03-01 08:38:47 +00:00
|
|
|
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
2012-06-19 23:14:39 +00:00
|
|
|
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
2012-09-13 16:37:14 +00:00
|
|
|
#include "mozilla/dom/bluetooth/PBluetoothChild.h"
|
2013-01-17 20:17:33 +00:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
#include "mozilla/dom/PSpeechSynthesisChild.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
#include "nsDOMFile.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "nsIRemoteBlob.h"
|
2012-09-11 04:30:33 +00:00
|
|
|
#include "ProcessUtils.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "StructuredCloneUtils.h"
|
2012-08-23 19:33:46 +00:00
|
|
|
#include "URIUtils.h"
|
2012-08-25 16:53:48 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsIPrincipal.h"
|
2012-10-04 20:40:45 +00:00
|
|
|
#include "nsDeviceStorage.h"
|
2012-12-06 03:01:58 +00:00
|
|
|
#include "AudioChannelService.h"
|
2013-01-26 21:14:01 +00:00
|
|
|
#include "ProcessPriorityManager.h"
|
2011-11-20 22:40:53 +00:00
|
|
|
|
2012-09-05 00:36:16 +00:00
|
|
|
using namespace base;
|
2012-12-15 00:01:34 +00:00
|
|
|
using namespace mozilla;
|
2010-10-20 17:12:32 +00:00
|
|
|
using namespace mozilla::docshell;
|
2012-09-13 16:37:14 +00:00
|
|
|
using namespace mozilla::dom::bluetooth;
|
2012-06-19 23:14:39 +00:00
|
|
|
using namespace mozilla::dom::devicestorage;
|
2013-01-26 21:14:01 +00:00
|
|
|
using namespace mozilla::dom::ipc;
|
2013-03-01 08:38:47 +00:00
|
|
|
using namespace mozilla::dom::mobilemessage;
|
2012-07-14 11:24:20 +00:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2012-07-17 23:59:45 +00:00
|
|
|
using namespace mozilla::hal_sandbox;
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
using namespace mozilla::net;
|
2012-08-03 23:48:58 +00:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
using namespace mozilla::system;
|
|
|
|
#endif
|
2009-08-12 18:31:48 +00:00
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2011-02-16 18:43:23 +00:00
|
|
|
|
|
|
|
class MemoryReportRequestChild : public PMemoryReportRequestChild
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MemoryReportRequestChild();
|
|
|
|
virtual ~MemoryReportRequestChild();
|
|
|
|
};
|
|
|
|
|
|
|
|
MemoryReportRequestChild::MemoryReportRequestChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryReportRequestChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryReportRequestChild::~MemoryReportRequestChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(MemoryReportRequestChild);
|
|
|
|
}
|
|
|
|
|
2010-09-15 16:44:57 +00:00
|
|
|
class AlertObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
AlertObserver(nsIObserver *aObserver, const nsString& aData)
|
2010-12-05 13:15:36 +00:00
|
|
|
: mObserver(aObserver)
|
|
|
|
, mData(aData)
|
2010-09-15 16:44:57 +00: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 14:20:58 +00:00
|
|
|
mObserver->Observe(nullptr, aType.get(), mData.get());
|
2010-09-15 16:44:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIObserver> mObserver;
|
|
|
|
nsString mData;
|
|
|
|
};
|
|
|
|
|
2012-06-15 02:31:55 +00:00
|
|
|
class ConsoleListener MOZ_FINAL : public nsIConsoleListener
|
2010-09-24 01:39:32 +00: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 15:56:38 +00:00
|
|
|
uint32_t lineNum, colNum, flags;
|
2010-09-24 01:39:32 +00: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 18:42:32 +00:00
|
|
|
|
2013-02-14 20:41:30 +00: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 12:18:35 +00:00
|
|
|
os->AddObserver(this, "handle-system-messages-done",
|
2013-02-14 20:41:30 +00: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 18:33:33 +00:00
|
|
|
ContentChild* ContentChild::sSingleton;
|
2009-08-13 00:32:50 +00:00
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::ContentChild()
|
2013-01-11 11:19:02 +00:00
|
|
|
: mID(uint64_t(-1))
|
2010-11-24 18:22:40 +00:00
|
|
|
#ifdef ANDROID
|
2012-08-09 23:14:55 +00:00
|
|
|
,mScreenSize(0, 0)
|
2010-11-24 18:22:40 +00:00
|
|
|
#endif
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2012-04-10 19:57:20 +00:00
|
|
|
// This process is a content process, so it's clearly running in
|
|
|
|
// multiprocess mode!
|
|
|
|
nsDebugImpl::SetMultiprocessMode("Child");
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::~ContentChild()
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::Init(MessageLoop* aIOLoop,
|
|
|
|
base::ProcessHandle aParentHandle,
|
|
|
|
IPC::Channel* aChannel)
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2012-06-28 00:15:32 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2010-08-20 23:24:40 +00:00
|
|
|
// sigh
|
|
|
|
gtk_init(NULL, NULL);
|
|
|
|
#endif
|
2010-10-08 21:48:37 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
// sigh, seriously
|
2010-10-09 06:05:50 +00:00
|
|
|
nsQAppInstance::AddRef();
|
2010-10-08 21:48:37 +00:00
|
|
|
#endif
|
2010-08-20 23:24:40 +00:00
|
|
|
|
2010-09-10 01:25:26 +00:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
// Do this after initializing GDK, or GDK will install its own handler.
|
|
|
|
XRE_InstallX11ErrorHandler();
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
NS_ASSERTION(!sSingleton, "only one ContentChild per child");
|
2010-11-05 16:38:17 +00:00
|
|
|
|
2009-10-27 21:52:37 +00:00
|
|
|
Open(aChannel, aParentHandle, aIOLoop);
|
2009-08-13 00:32:50 +00:00
|
|
|
sSingleton = this;
|
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
SendPCrashReporterConstructor(CrashReporter::CurrentThreadId(),
|
|
|
|
XRE_GetProcessType());
|
2010-11-24 14:15:03 +00:00
|
|
|
#endif
|
|
|
|
|
2013-01-26 21:14:01 +00:00
|
|
|
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
|
|
|
|
|
2012-09-11 04:30:33 +00: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 18:32:37 +00:00
|
|
|
SetProcessName(NS_LITERAL_STRING("(Preallocated app)"));
|
2012-09-11 04:30:33 +00:00
|
|
|
} else {
|
2012-10-05 21:54:54 +00:00
|
|
|
SetProcessName(NS_LITERAL_STRING("Browser"));
|
2012-09-11 04:30:33 +00:00
|
|
|
}
|
2012-09-05 00:36:16 +00:00
|
|
|
|
2009-08-13 00:32:50 +00:00
|
|
|
return true;
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2012-10-05 21:54:54 +00:00
|
|
|
void
|
|
|
|
ContentChild::SetProcessName(const nsAString& aName)
|
|
|
|
{
|
2012-12-12 23:30:44 +00: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)
|
|
|
|
printf_stderr("\n\nCHILDCHILDCHILDCHILD\n [%s] debug me @%d\n\n", name, _getpid());
|
|
|
|
Sleep(30000);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-10-05 21:54:54 +00:00
|
|
|
mProcessName = aName;
|
|
|
|
mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
const void
|
|
|
|
ContentChild::GetProcessName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Assign(mProcessName);
|
|
|
|
}
|
|
|
|
|
2010-09-24 01:39:32 +00: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 21:09:39 +00:00
|
|
|
|
|
|
|
bool isOffline;
|
|
|
|
SendGetXPCOMProcessAttributes(&isOffline);
|
|
|
|
RecvSetOffline(isOffline);
|
2013-01-09 15:03:28 +00:00
|
|
|
|
|
|
|
DebugOnly<FileUpdateDispatcher*> observer = FileUpdateDispatcher::GetSingleton();
|
|
|
|
NS_ASSERTION(observer, "FileUpdateDispatcher is null");
|
2013-02-14 20:41:30 +00:00
|
|
|
|
|
|
|
// This object is held alive by the observer service.
|
|
|
|
nsRefPtr<SystemMessageHandledObserver> sysMsgObserver =
|
|
|
|
new SystemMessageHandledObserver();
|
|
|
|
sysMsgObserver->Init();
|
2010-09-24 01:39:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
PMemoryReportRequestChild*
|
|
|
|
ContentChild::AllocPMemoryReportRequest()
|
|
|
|
{
|
|
|
|
return new MemoryReportRequestChild();
|
|
|
|
}
|
|
|
|
|
2011-06-29 23:39:32 +00:00
|
|
|
// This is just a wrapper for InfallibleTArray<MemoryReport> that implements
|
|
|
|
// nsISupports, so it can be passed to nsIMemoryMultiReporter::CollectReports.
|
2012-06-15 02:31:55 +00:00
|
|
|
class MemoryReportsWrapper MOZ_FINAL : public nsISupports {
|
2011-06-29 23:39:32 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
MemoryReportsWrapper(InfallibleTArray<MemoryReport> *r) : mReports(r) { }
|
|
|
|
InfallibleTArray<MemoryReport> *mReports;
|
|
|
|
};
|
|
|
|
NS_IMPL_ISUPPORTS0(MemoryReportsWrapper)
|
|
|
|
|
2012-06-15 02:31:55 +00:00
|
|
|
class MemoryReportCallback MOZ_FINAL : public nsIMemoryMultiReporterCallback
|
2011-06-29 23:39:32 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
MemoryReportCallback(const nsACString &aProcess)
|
|
|
|
: mProcess(aProcess)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Callback(const nsACString &aProcess, const nsACString &aPath,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aKind, int32_t aUnits, int64_t aAmount,
|
2011-06-29 23:39:32 +00: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
|
|
|
|
, nsIMemoryMultiReporterCallback
|
|
|
|
)
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* child)
|
|
|
|
{
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
|
2011-06-29 23:39:32 +00:00
|
|
|
InfallibleTArray<MemoryReport> reports;
|
|
|
|
|
2012-04-24 18:43:00 +00:00
|
|
|
nsPrintfCString process("Content (%d)", getpid());
|
2011-06-29 23:39:32 +00:00
|
|
|
|
|
|
|
// First do the vanilla memory reporters.
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> e;
|
|
|
|
mgr->EnumerateReporters(getter_AddRefs(e));
|
2011-09-29 06:19:26 +00:00
|
|
|
bool more;
|
2011-06-29 23:39:32 +00:00
|
|
|
while (NS_SUCCEEDED(e->HasMoreElements(&more)) && more) {
|
|
|
|
nsCOMPtr<nsIMemoryReporter> r;
|
|
|
|
e->GetNext(getter_AddRefs(r));
|
2011-02-16 18:43:23 +00:00
|
|
|
|
|
|
|
nsCString path;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t kind;
|
|
|
|
int32_t units;
|
|
|
|
int64_t amount;
|
2011-06-29 23:39:32 +00:00
|
|
|
nsCString desc;
|
2012-04-10 05:52:33 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(r->GetPath(path)) &&
|
|
|
|
NS_SUCCEEDED(r->GetKind(&kind)) &&
|
|
|
|
NS_SUCCEEDED(r->GetUnits(&units)) &&
|
|
|
|
NS_SUCCEEDED(r->GetAmount(&amount)) &&
|
|
|
|
NS_SUCCEEDED(r->GetDescription(desc)))
|
|
|
|
{
|
|
|
|
MemoryReport memreport(process, path, kind, units, amount, desc);
|
|
|
|
reports.AppendElement(memreport);
|
|
|
|
}
|
2011-06-29 23:39:32 +00:00
|
|
|
}
|
2011-02-16 18:43:23 +00:00
|
|
|
|
2011-06-29 23:39:32 +00:00
|
|
|
// Then do the memory multi-reporters, by calling CollectReports on each
|
|
|
|
// one, whereupon the callback will turn each measurement into a
|
|
|
|
// MemoryReport.
|
|
|
|
mgr->EnumerateMultiReporters(getter_AddRefs(e));
|
2011-07-07 05:54:34 +00:00
|
|
|
nsRefPtr<MemoryReportsWrapper> wrappedReports =
|
|
|
|
new MemoryReportsWrapper(&reports);
|
|
|
|
nsRefPtr<MemoryReportCallback> cb = new MemoryReportCallback(process);
|
2011-06-29 23:39:32 +00:00
|
|
|
while (NS_SUCCEEDED(e->HasMoreElements(&more)) && more) {
|
|
|
|
nsCOMPtr<nsIMemoryMultiReporter> r;
|
|
|
|
e->GetNext(getter_AddRefs(r));
|
2011-07-07 05:54:34 +00:00
|
|
|
r->CollectReports(cb, wrappedReports);
|
2011-02-16 18:43:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
child->Send__delete__(child, reports);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-06 03:01:58 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAudioChannelNotify()
|
|
|
|
{
|
|
|
|
nsRefPtr<AudioChannelService> service =
|
|
|
|
AudioChannelService::GetAudioChannelService();
|
|
|
|
if (service) {
|
|
|
|
service->Notify();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
bool
|
|
|
|
ContentChild::DeallocPMemoryReportRequest(PMemoryReportRequestChild* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-03 01:19:11 +00:00
|
|
|
bool
|
2013-03-28 03:31:26 +00:00
|
|
|
ContentChild::RecvDumpMemoryInfoToTempDir(const nsString& aIdentifier,
|
2012-10-03 01:19:11 +00:00
|
|
|
const bool& aMinimizeMemoryUsage,
|
|
|
|
const bool& aDumpChildProcesses)
|
|
|
|
{
|
2012-10-30 00:41:14 +00:00
|
|
|
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
|
|
|
|
2013-03-28 03:31:26 +00:00
|
|
|
dumper->DumpMemoryInfoToTempDir(aIdentifier, aMinimizeMemoryUsage,
|
|
|
|
aDumpChildProcesses);
|
2012-10-03 01:19:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-16 02:12:14 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvDumpGCAndCCLogsToFile(const nsString& aIdentifier,
|
|
|
|
const bool& aDumpChildProcesses)
|
|
|
|
{
|
2012-10-30 00:41:14 +00:00
|
|
|
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
|
|
|
|
|
|
|
dumper->DumpGCAndCCLogsToFile(
|
2012-10-16 02:12:14 +00:00
|
|
|
aIdentifier, aDumpChildProcesses);
|
2012-10-16 02:12:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
PCompositorChild*
|
2012-08-02 06:02:29 +00:00
|
|
|
ContentChild::AllocPCompositor(mozilla::ipc::Transport* aTransport,
|
2012-07-17 23:59:45 +00:00
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return CompositorChild::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2012-08-29 12:24:48 +00:00
|
|
|
PImageBridgeChild*
|
|
|
|
ContentChild::AllocPImageBridge(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return ImageBridgeChild::StartUpInChildProcess(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2013-01-17 20:06:36 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvSetProcessPrivileges(const ChildPrivileges& aPrivs)
|
|
|
|
{
|
|
|
|
ChildPrivileges privs = (aPrivs == PRIVILEGES_DEFAULT) ?
|
|
|
|
GeckoChildProcessHost::DefaultChildPrivileges() :
|
|
|
|
aPrivs;
|
|
|
|
// If this fails, we die.
|
|
|
|
SetCurrentProcessPrivileges(privs);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-27 20:43:52 +00:00
|
|
|
static CancelableTask* sFirstIdleTask;
|
|
|
|
|
2012-10-09 04:46:19 +00:00
|
|
|
static void FirstIdle(void)
|
|
|
|
{
|
2012-11-27 20:43:52 +00:00
|
|
|
MOZ_ASSERT(sFirstIdleTask);
|
|
|
|
sFirstIdleTask = nullptr;
|
2012-10-09 04:46:19 +00:00
|
|
|
ContentChild::GetSingleton()->SendFirstIdle();
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
PBrowserChild*
|
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 18:32:37 +00:00
|
|
|
ContentChild::AllocPBrowser(const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags)
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2013-02-23 04:24:28 +00: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.
|
|
|
|
|
|
|
|
nsRefPtr<TabChild> child = TabChild::Create(TabContext(aContext), aChromeFlags);
|
|
|
|
|
|
|
|
// The ref here is released in DeallocPBrowser.
|
|
|
|
return child.forget().get();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
|
|
|
|
const IPCTabContext& context,
|
|
|
|
const uint32_t& chromeFlags)
|
|
|
|
{
|
|
|
|
// This runs after AllocPBrowser() returns and the IPC machinery for this
|
|
|
|
// 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 21:14:01 +00:00
|
|
|
static bool hasRunOnce = false;
|
|
|
|
if (!hasRunOnce) {
|
|
|
|
hasRunOnce = true;
|
|
|
|
|
2012-11-27 20:43:52 +00:00
|
|
|
MOZ_ASSERT(!sFirstIdleTask);
|
|
|
|
sFirstIdleTask = NewRunnableFunction(FirstIdle);
|
|
|
|
MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
|
2012-10-09 04:46:19 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 04:24:28 +00:00
|
|
|
return true;
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 04:24:28 +00:00
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::DeallocPBrowser(PBrowserChild* iframe)
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2010-05-15 05:27:52 +00:00
|
|
|
TabChild* child = static_cast<TabChild*>(iframe);
|
|
|
|
NS_RELEASE(child);
|
2009-09-17 23:09:20 +00:00
|
|
|
return true;
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
PBlobChild*
|
|
|
|
ContentChild::AllocPBlob(const BlobConstructorParams& aParams)
|
|
|
|
{
|
2013-01-17 20:17:33 +00:00
|
|
|
return BlobChild::Create(aParams);
|
2012-08-02 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPBlob(PBlobChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-01-17 20:17:33 +00:00
|
|
|
BlobChild*
|
|
|
|
ContentChild::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
2012-08-02 06:02:29 +00:00
|
|
|
{
|
2013-01-17 20:17:33 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
NS_ASSERTION(aBlob, "Null pointer!");
|
|
|
|
|
|
|
|
// 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-02 06:02:29 +00:00
|
|
|
|
2013-01-17 20:17:33 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob);
|
|
|
|
if (remoteBlob) {
|
|
|
|
BlobChild* actor =
|
|
|
|
static_cast<BlobChild*>(static_cast<PBlobChild*>(remoteBlob->GetPBlob()));
|
|
|
|
NS_ASSERTION(actor, "Null actor?!");
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParentBlobConstructorParams params;
|
|
|
|
|
|
|
|
if (blob->IsSizeUnknown() || blob->IsDateUnknown()) {
|
2012-10-18 18:29:32 +00: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 20:17:33 +00:00
|
|
|
params.blobParams() = MysteryBlobConstructorParams();
|
|
|
|
params.optionalInputStreamParams() = void_t();
|
2012-08-03 06:25:30 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsString contentType;
|
|
|
|
nsresult rv = aBlob->GetType(contentType);
|
2013-01-17 20:17:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t length;
|
2012-08-03 06:25:30 +00:00
|
|
|
rv = aBlob->GetSize(&length);
|
2013-01-17 20:17:33 +00: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-02 06:02:29 +00:00
|
|
|
|
2013-01-17 20:17:33 +00:00
|
|
|
params.optionalInputStreamParams() = inputStreamParams;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(aBlob);
|
2012-08-03 06:25:30 +00:00
|
|
|
if (file) {
|
|
|
|
FileBlobConstructorParams fileParams;
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
rv = file->GetName(fileParams.name());
|
2013-01-17 20:17:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-10-18 18:29:32 +00:00
|
|
|
rv = file->GetMozLastModifiedDate(&fileParams.modDate());
|
2013-01-17 20:17:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-10-18 18:29:32 +00:00
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
fileParams.contentType() = contentType;
|
|
|
|
fileParams.length() = length;
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2013-01-17 20:17:33 +00:00
|
|
|
params.blobParams() = fileParams;
|
2012-08-03 06:25:30 +00:00
|
|
|
} else {
|
|
|
|
NormalBlobConstructorParams blobParams;
|
|
|
|
blobParams.contentType() = contentType;
|
|
|
|
blobParams.length() = length;
|
2013-01-17 20:17:33 +00:00
|
|
|
params.blobParams() = blobParams;
|
2012-08-03 06:25:30 +00:00
|
|
|
}
|
2013-01-10 13:47:32 +00:00
|
|
|
}
|
2012-08-02 06:02:29 +00:00
|
|
|
|
|
|
|
BlobChild* actor = BlobChild::Create(aBlob);
|
|
|
|
NS_ENSURE_TRUE(actor, nullptr);
|
|
|
|
|
2013-01-17 20:17:33 +00:00
|
|
|
if (!SendPBlobConstructor(actor, params)) {
|
2013-01-10 13:47:32 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
2010-11-24 14:15:03 +00:00
|
|
|
PCrashReporterChild*
|
2011-06-08 19:56:31 +00:00
|
|
|
ContentChild::AllocPCrashReporter(const mozilla::dom::NativeThreadId& id,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& processType)
|
2010-11-24 14:15:03 +00:00
|
|
|
{
|
2011-06-08 19:56:31 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2010-11-24 14:15:03 +00:00
|
|
|
return new CrashReporterChild();
|
2011-06-08 19:56:31 +00:00
|
|
|
#else
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-06-08 19:56:31 +00:00
|
|
|
#endif
|
2010-11-24 14:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPCrashReporter(PCrashReporterChild* crashreporter)
|
|
|
|
{
|
|
|
|
delete crashreporter;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-05 22:15:45 +00:00
|
|
|
PHalChild*
|
|
|
|
ContentChild::AllocPHal()
|
|
|
|
{
|
|
|
|
return CreateHalChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPHal(PHalChild* aHal)
|
|
|
|
{
|
|
|
|
delete aHal;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-14 11:24:20 +00:00
|
|
|
PIndexedDBChild*
|
|
|
|
ContentChild::AllocPIndexedDB()
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("Should never get here!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPIndexedDB(PIndexedDBChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
PTestShellChild*
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::AllocPTestShell()
|
2009-08-12 18:31:48 +00:00
|
|
|
{
|
2010-05-15 05:27:52 +00:00
|
|
|
return new TestShellChild();
|
2009-08-12 18:31:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::DeallocPTestShell(PTestShellChild* shell)
|
2009-08-12 18:31:48 +00:00
|
|
|
{
|
2010-05-15 05:27:52 +00:00
|
|
|
delete shell;
|
2009-09-17 23:09:20 +00:00
|
|
|
return true;
|
2009-08-25 23:07:22 +00:00
|
|
|
}
|
|
|
|
|
2009-11-06 20:43:39 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::RecvPTestShellConstructor(PTestShellChild* actor)
|
2009-11-06 20:43:39 +00:00
|
|
|
{
|
|
|
|
actor->SendPContextWrapperConstructor()->SendPObjectWrapperConstructor(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-19 23:14:39 +00:00
|
|
|
PDeviceStorageRequestChild*
|
|
|
|
ContentChild::AllocPDeviceStorageRequest(const DeviceStorageParams& aParams)
|
|
|
|
{
|
|
|
|
return new DeviceStorageRequestChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPDeviceStorageRequest(PDeviceStorageRequestChild* aDeviceStorage)
|
|
|
|
{
|
|
|
|
delete aDeviceStorage;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-08-18 19:05:15 +00:00
|
|
|
PNeckoChild*
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::AllocPNecko()
|
2009-08-18 19:05:15 +00:00
|
|
|
{
|
|
|
|
return new NeckoChild();
|
|
|
|
}
|
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::DeallocPNecko(PNeckoChild* necko)
|
2009-08-18 19:05:15 +00:00
|
|
|
{
|
|
|
|
delete necko;
|
2009-09-17 23:09:20 +00:00
|
|
|
return true;
|
2009-08-18 19:05:15 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 22:55:08 +00:00
|
|
|
PExternalHelperAppChild*
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentChild::AllocPExternalHelperApp(const OptionalURIParams& uri,
|
2010-09-15 22:55:08 +00:00
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
|
|
|
const bool& aForceSave,
|
2012-08-22 15:56:38 +00:00
|
|
|
const int64_t& aContentLength,
|
2012-08-23 19:33:46 +00:00
|
|
|
const OptionalURIParams& aReferrer)
|
2010-09-15 22:55:08 +00:00
|
|
|
{
|
|
|
|
ExternalHelperAppChild *child = new ExternalHelperAppChild();
|
|
|
|
child->AddRef();
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPExternalHelperApp(PExternalHelperAppChild* aService)
|
|
|
|
{
|
|
|
|
ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
|
|
|
|
child->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-20 22:40:53 +00:00
|
|
|
PSmsChild*
|
|
|
|
ContentChild::AllocPSms()
|
|
|
|
{
|
|
|
|
return new SmsChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPSms(PSmsChild* aSms)
|
|
|
|
{
|
|
|
|
delete aSms;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-19 01:15:23 +00:00
|
|
|
PStorageChild*
|
2013-04-15 12:38:48 +00:00
|
|
|
ContentChild::AllocPStorage()
|
2010-11-19 01:15:23 +00:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("We should never be manually allocating PStorageChild actors");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-11-19 01:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPStorage(PStorageChild* aActor)
|
|
|
|
{
|
2013-04-15 12:38:48 +00:00
|
|
|
DOMStorageDBChild* child = static_cast<DOMStorageDBChild*>(aActor);
|
2010-11-19 01:15:23 +00:00
|
|
|
child->ReleaseIPDLReference();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-13 16:37:14 +00:00
|
|
|
PBluetoothChild*
|
|
|
|
ContentChild::AllocPBluetooth()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
MOZ_NOT_REACHED("No one should be allocating PBluetoothChild actors");
|
|
|
|
return nullptr;
|
|
|
|
#else
|
|
|
|
MOZ_NOT_REACHED("No support for bluetooth on this platform!");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPBluetooth(PBluetoothChild* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
MOZ_NOT_REACHED("No support for bluetooth on this platform!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-03 22:13:17 +00:00
|
|
|
PSpeechSynthesisChild*
|
|
|
|
ContentChild::AllocPSpeechSynthesis()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
MOZ_NOT_REACHED("No one should be allocating PSpeechSynthesisChild actors");
|
|
|
|
return nullptr;
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPSpeechSynthesis(PSpeechSynthesisChild* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
bool
|
2010-11-09 02:49:00 +00:00
|
|
|
ContentChild::RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
|
|
|
|
const InfallibleTArray<ResourceMapping>& resources,
|
2011-01-11 21:34:31 +00:00
|
|
|
const InfallibleTArray<OverrideMapping>& overrides,
|
|
|
|
const nsCString& locale)
|
2010-03-11 05:33:00 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
2011-01-11 21:34:31 +00:00
|
|
|
chromeRegistry->RegisterRemoteChrome(packages, resources, overrides, locale);
|
2010-03-11 05:33:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-11 12:44:12 +00:00
|
|
|
bool
|
2011-09-29 06:19:26 +00:00
|
|
|
ContentChild::RecvSetOffline(const bool& offline)
|
2010-05-11 12:44:12 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIOService> io (do_GetIOService());
|
|
|
|
NS_ASSERTION(io, "IO Service can not be null");
|
|
|
|
|
|
|
|
io->SetOffline(offline);
|
2011-02-14 22:34:46 +00:00
|
|
|
|
2010-05-11 12:44:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-12-07 06:03:49 +00:00
|
|
|
void
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentChild::ActorDestroy(ActorDestroyReason why)
|
2009-09-03 00:18:27 +00:00
|
|
|
{
|
2010-08-20 23:24:40 +00: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-03 00:18:27 +00:00
|
|
|
|
2012-11-27 20:43:52 +00:00
|
|
|
if (sFirstIdleTask) {
|
|
|
|
sFirstIdleTask->Cancel();
|
|
|
|
}
|
|
|
|
|
2010-09-15 16:44:57 +00:00
|
|
|
mAlertObservers.Clear();
|
2011-02-14 22:34:46 +00:00
|
|
|
|
2010-09-24 01:39:32 +00:00
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (svc) {
|
|
|
|
svc->UnregisterListener(mConsoleListener);
|
2012-07-30 14:20:58 +00:00
|
|
|
mConsoleListener->mChild = nullptr;
|
2010-09-24 01:39:32 +00:00
|
|
|
}
|
|
|
|
|
2009-12-07 06:03:49 +00:00
|
|
|
XRE_ShutdownChildProcess();
|
2009-09-03 00:18:27 +00:00
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:40 +00:00
|
|
|
void
|
|
|
|
ContentChild::ProcessingError(Result what)
|
|
|
|
{
|
|
|
|
switch (what) {
|
|
|
|
case MsgDropped:
|
|
|
|
QuickExit();
|
|
|
|
|
|
|
|
case MsgNotKnown:
|
2013-06-04 04:15:40 +00:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgNotKnown");
|
2010-08-20 23:24:40 +00:00
|
|
|
case MsgNotAllowed:
|
2013-06-04 04:15:40 +00:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgNotAllowed");
|
2010-08-20 23:24:40 +00:00
|
|
|
case MsgPayloadError:
|
2013-06-04 04:15:40 +00:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgPayloadError");
|
2010-08-20 23:24:40 +00:00
|
|
|
case MsgProcessingError:
|
2013-06-04 04:15:40 +00:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgProcessingError");
|
2010-08-20 23:24:40 +00:00
|
|
|
case MsgRouteError:
|
2013-06-04 04:15:40 +00:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgRouteError");
|
2010-08-20 23:24:40 +00:00
|
|
|
case MsgValueError:
|
2013-06-04 04:15:40 +00:00
|
|
|
NS_RUNTIMEABORT("aborting because of MsgValueError");
|
2010-08-20 23:24:40 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::QuickExit()
|
|
|
|
{
|
|
|
|
NS_WARNING("content process _exit()ing");
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
|
2010-09-15 16:44:57 +00: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-26 00:13:47 +00:00
|
|
|
bool
|
2012-08-22 20:00:21 +00:00
|
|
|
ContentChild::RecvPreferenceUpdate(const PrefSetting& aPref)
|
2010-07-21 18:42:32 +00:00
|
|
|
{
|
2012-08-22 20:00:21 +00:00
|
|
|
Preferences::SetPreference(aPref);
|
2010-05-26 00:13:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-15 16:44:57 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& aData)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < mAlertObservers.Length();
|
2010-09-15 16:44:57 +00: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 15:50:41 +00:00
|
|
|
bool
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentChild::RecvNotifyVisited(const URIParams& aURI)
|
2010-07-02 15:50:41 +00:00
|
|
|
{
|
2012-08-23 19:33:46 +00:00
|
|
|
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
|
|
|
|
if (!newURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-09 09:55:54 +00:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
|
|
|
history->NotifyVisited(newURI);
|
|
|
|
}
|
2010-07-02 15:50:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-31 18:58:35 +00:00
|
|
|
bool
|
2012-08-02 06:02:29 +00:00
|
|
|
ContentChild::RecvAsyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData)
|
2010-08-31 18:58:35 +00:00
|
|
|
{
|
|
|
|
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::sChildProcessManager;
|
|
|
|
if (cpm) {
|
2013-01-24 16:24:19 +00:00
|
|
|
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForChild(aData);
|
2010-08-31 18:58:35 +00:00
|
|
|
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
|
2013-05-20 12:40:06 +00:00
|
|
|
aMsg, false, &cloneData, JS::NullPtr(), nullptr);
|
2010-08-31 18:58:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-21 04:16:37 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGeolocationUpdate(const GeoPosition& somewhere)
|
|
|
|
{
|
2010-09-21 04:16:37 +00:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> gs = do_GetService("@mozilla.org/geolocation/service;1");
|
2010-09-22 02:36:58 +00:00
|
|
|
if (!gs) {
|
2010-09-21 04:16:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
|
|
|
|
gs->Update(position);
|
2010-09-21 04:16:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-09 18:07:38 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
|
|
|
{
|
|
|
|
#if MOZ_PERMISSIONS
|
2011-08-30 17:45:09 +00:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
|
|
|
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
|
|
|
nsPermissionManager* permissionManager =
|
|
|
|
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
2010-10-09 18:07:38 +00:00
|
|
|
NS_ABORT_IF_FALSE(permissionManager,
|
|
|
|
"We have no permissionManager in the Content process !");
|
|
|
|
|
2012-08-25 16:53:48 +00: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 18:38:01 +00:00
|
|
|
nsresult rv = secMan->GetAppCodebasePrincipal(uri, permission.appId,
|
|
|
|
permission.isInBrowserElement,
|
|
|
|
getter_AddRefs(principal));
|
2012-08-25 16:53:48 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
permissionManager->AddInternal(principal,
|
2010-10-09 18:07:38 +00:00
|
|
|
nsCString(permission.type),
|
|
|
|
permission.capability,
|
|
|
|
0,
|
|
|
|
permission.expireType,
|
|
|
|
permission.expireTime,
|
|
|
|
nsPermissionManager::eNotify,
|
|
|
|
nsPermissionManager::eNoDBOperation);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-20 05:36:17 +00:00
|
|
|
|
2010-11-24 18:22:40 +00: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 22:36:08 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvFlushMemory(const nsString& reason)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (os)
|
2012-07-30 14:20:58 +00:00
|
|
|
os->NotifyObservers(nullptr, "memory-pressure", reason.get());
|
2013-01-09 15:03:28 +00:00
|
|
|
return true;
|
2010-12-11 22:36:08 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 04:37:32 +00: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 17:53:51 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGarbageCollect()
|
|
|
|
{
|
2013-03-19 10:35:41 +00:00
|
|
|
nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
|
2011-09-13 17:53:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvCycleCollect()
|
|
|
|
{
|
2013-03-19 10:35:41 +00:00
|
|
|
nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
|
2011-09-13 17:53:51 +00:00
|
|
|
nsJSContext::CycleCollectNow();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
static void
|
|
|
|
PreloadSlowThings()
|
|
|
|
{
|
|
|
|
// This fetches and creates all the built-in stylesheets.
|
|
|
|
nsLayoutStylesheetCache::UserContentSheet();
|
2012-08-29 15:26:18 +00:00
|
|
|
|
|
|
|
TabChild::PreloadSlowThings();
|
2012-08-16 01:46:03 +00:00
|
|
|
}
|
|
|
|
|
2011-10-04 20:31:00 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID)
|
|
|
|
{
|
|
|
|
mAppInfo.version.Assign(version);
|
|
|
|
mAppInfo.buildID.Assign(buildID);
|
2013-01-24 18:39:18 +00: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 20:31:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-20 00:13:20 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvLastPrivateDocShellDestroyed()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2012-07-30 14:20:58 +00:00
|
|
|
obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
2012-04-20 00:13:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-02 06:32:04 +00:00
|
|
|
bool
|
2013-05-11 09:10:18 +00:00
|
|
|
ContentChild::RecvFilePathUpdate(const nsString& aStorageType,
|
|
|
|
const nsString& aStorageName,
|
|
|
|
const nsString& aPath,
|
|
|
|
const nsCString& aReason)
|
2012-08-02 06:32:04 +00:00
|
|
|
{
|
2013-05-11 09:10:18 +00:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aStorageType, aStorageName, aPath);
|
2012-08-30 22:17:37 +00:00
|
|
|
|
2012-08-18 02:43:00 +00:00
|
|
|
nsString reason;
|
|
|
|
CopyASCIItoUTF16(aReason, reason);
|
2012-08-02 06:32:04 +00:00
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2012-08-30 22:17:37 +00:00
|
|
|
obs->NotifyObservers(dsf, "file-watcher-update", reason.get());
|
2012-08-02 06:32:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-03 23:48:58 +00:00
|
|
|
bool
|
2012-12-15 00:01:34 +00:00
|
|
|
ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
|
2013-05-11 09:10:18 +00:00
|
|
|
const nsString& aVolumeName,
|
2012-12-15 00:01:34 +00:00
|
|
|
const int32_t& aState,
|
|
|
|
const int32_t& aMountGeneration)
|
2012-08-03 23:48:58 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2013-05-11 09:10:18 +00:00
|
|
|
nsRefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
|
2012-12-15 00:01:34 +00:00
|
|
|
aMountGeneration);
|
2012-08-03 23:48:58 +00:00
|
|
|
|
2013-05-17 19:55:14 +00:00
|
|
|
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
|
|
|
|
if (vs) {
|
|
|
|
vs->UpdateVolume(volume);
|
|
|
|
}
|
2012-12-15 00:01:34 +00:00
|
|
|
#else
|
|
|
|
// Remove warnings about unused arguments
|
|
|
|
unused << aFsName;
|
2013-05-11 09:10:18 +00:00
|
|
|
unused << aVolumeName;
|
2012-12-15 00:01:34 +00:00
|
|
|
unused << aState;
|
|
|
|
unused << aMountGeneration;
|
2012-08-03 23:48:58 +00:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-26 00:53:26 +00:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyProcessPriorityChanged(
|
|
|
|
const hal::ProcessPriority& aPriority)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
NS_ENSURE_TRUE(os, true);
|
|
|
|
|
|
|
|
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
|
|
|
props->Init();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
} // namespace dom
|
2013-02-14 20:41:30 +00:00
|
|
|
} // namespace mozilla
|