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"
|
2014-09-26 16:21:57 -07:00
|
|
|
|
|
|
|
#include "BlobChild.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"
|
2014-06-10 22:44:06 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-06-10 22:44:13 -07:00
|
|
|
#include "mozilla/dom/ContentBridgeChild.h"
|
|
|
|
#include "mozilla/dom/ContentBridgeParent.h"
|
2014-06-10 22:44:06 -07:00
|
|
|
#include "mozilla/dom/DOMStorageIPC.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "mozilla/dom/ExternalHelperAppChild.h"
|
|
|
|
#include "mozilla/dom/PCrashReporterChild.h"
|
2014-05-20 22:49:36 -07:00
|
|
|
#include "mozilla/dom/Promise.h"
|
2014-06-10 22:44:06 -07:00
|
|
|
#include "mozilla/dom/asmjscache/AsmJSCache.h"
|
|
|
|
#include "mozilla/dom/asmjscache/PAsmJSCacheEntryChild.h"
|
|
|
|
#include "mozilla/dom/nsIContentChild.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "mozilla/hal_sandbox/PHalChild.h"
|
2013-11-26 23:59:41 -08:00
|
|
|
#include "mozilla/ipc/BackgroundChild.h"
|
2014-09-26 16:21:57 -07:00
|
|
|
#include "mozilla/ipc/FileDescriptorSetChild.h"
|
2014-05-13 10:13:00 -07:00
|
|
|
#include "mozilla/ipc/FileDescriptorUtils.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"
|
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"
|
2014-06-10 22:44:06 -07:00
|
|
|
#include "mozilla/layers/SharedBufferManagerChild.h"
|
2011-10-05 15:15:45 -07:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2014-02-14 08:07:16 -08:00
|
|
|
|
2014-03-12 15:48:15 -07:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
|
|
|
#if defined(XP_WIN)
|
2014-02-14 08:07:16 -08:00
|
|
|
#define TARGET_SANDBOX_EXPORTS
|
|
|
|
#include "mozilla/sandboxTarget.h"
|
2014-09-10 04:36:17 -07:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2014-03-12 15:48:15 -07:00
|
|
|
#elif defined(XP_LINUX)
|
2014-02-27 13:18:01 -08:00
|
|
|
#include "mozilla/Sandbox.h"
|
2014-02-14 08:07:16 -08:00
|
|
|
#endif
|
2014-03-12 15:48:15 -07:00
|
|
|
#endif
|
2014-02-14 08:07:16 -08:00
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
#include "mozilla/unused.h"
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2014-10-03 07:52:37 -07:00
|
|
|
#include "mozInlineSpellChecker.h"
|
2013-09-23 14:30:40 -07:00
|
|
|
#include "nsIConsoleListener.h"
|
2014-05-13 10:13:00 -07:00
|
|
|
#include "nsICycleCollectorListener.h"
|
2013-11-26 23:59:41 -08:00
|
|
|
#include "nsIIPCBackgroundChildCreateCallback.h"
|
2013-09-23 14:30:40 -07:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
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"
|
2012-08-08 19:58:06 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2014-07-14 10:22:26 -07:00
|
|
|
#include "nsScreenManagerProxy.h"
|
2014-07-02 15:59:02 -07:00
|
|
|
#include "nsMemoryInfoDumper.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-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"
|
2014-01-31 15:02:30 -08:00
|
|
|
#include "nsThreadManager.h"
|
2014-06-24 10:11:36 -07:00
|
|
|
#include "nsAnonymousTemporaryFile.h"
|
2014-10-03 07:52:37 -07:00
|
|
|
#include "nsISpellChecker.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 "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"
|
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"
|
2011-02-16 10:43:23 -08:00
|
|
|
#include "mozilla/dom/PMemoryReportRequestChild.h"
|
2014-05-13 10:13:00 -07:00
|
|
|
#include "mozilla/dom/PCycleCollectWithLogsChild.h"
|
2010-09-20 21:16:37 -07:00
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
2013-09-23 14:30:40 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2010-10-09 11:07:38 -07:00
|
|
|
#include "nsPermission.h"
|
|
|
|
#include "nsPermissionManager.h"
|
|
|
|
#endif
|
|
|
|
|
2013-11-06 09:21:15 -08:00
|
|
|
#include "PermissionMessageUtils.h"
|
|
|
|
|
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"
|
2013-11-24 15:50:03 -08:00
|
|
|
#include "SpeakerManagerService.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
|
|
|
|
|
2014-02-05 08:37:26 -08:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
|
|
|
|
2011-07-20 21:37:32 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include "ipc/Nuwa.h"
|
|
|
|
#endif
|
|
|
|
|
2014-08-18 02:06:11 -07:00
|
|
|
#include "mozilla/dom/cellbroadcast/CellBroadcastIPCService.h"
|
2014-09-21 00:24:42 -07:00
|
|
|
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
|
2013-03-01 00:38:47 -08:00
|
|
|
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
2012-06-19 16:14:39 -07:00
|
|
|
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
2014-03-04 19:25:40 -08:00
|
|
|
#include "mozilla/dom/PFileSystemRequestChild.h"
|
|
|
|
#include "mozilla/dom/FileSystemTaskBase.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-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 "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"
|
2014-06-03 07:36:46 -07:00
|
|
|
#include "mozilla/dom/DataStoreService.h"
|
2013-09-23 14:30:40 -07:00
|
|
|
#include "mozilla/dom/telephony/PTelephonyChild.h"
|
2014-02-14 00:43:51 -08:00
|
|
|
#include "mozilla/dom/time/DateCacheCleaner.h"
|
2014-09-25 22:00:24 -07:00
|
|
|
#include "mozilla/dom/voicemail/VoicemailIPCService.h"
|
2013-10-18 13:57:55 -07:00
|
|
|
#include "mozilla/net/NeckoMessageUtils.h"
|
2014-07-01 15:24:27 -07:00
|
|
|
#include "mozilla/RemoteSpellCheckEngineChild.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;
|
2014-08-18 02:06:11 -07:00
|
|
|
using namespace mozilla::dom::cellbroadcast;
|
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;
|
2014-09-21 00:24:42 -07:00
|
|
|
using namespace mozilla::dom::mobileconnection;
|
2013-03-01 00:38:47 -08:00
|
|
|
using namespace mozilla::dom::mobilemessage;
|
2013-09-06 23:19:53 -07:00
|
|
|
using namespace mozilla::dom::telephony;
|
2014-09-25 22:00:24 -07:00
|
|
|
using namespace mozilla::dom::voicemail;
|
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
|
2014-07-14 10:22:26 -07:00
|
|
|
using namespace mozilla::widget;
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
static bool sNuwaForking = false;
|
|
|
|
|
|
|
|
// The size of the reserved stack (in unsigned ints). It's used to reserve space
|
|
|
|
// to push sigsetjmp() in NuwaCheckpointCurrentThread() to higher in the stack
|
|
|
|
// so that after it returns and do other work we don't garble the stack we want
|
|
|
|
// to preserve in NuwaCheckpointCurrentThread().
|
|
|
|
#define RESERVED_INT_STACK 128
|
|
|
|
|
|
|
|
// A sentinel value for checking whether RESERVED_INT_STACK is large enough.
|
|
|
|
#define STACK_SENTINEL_VALUE 0xdeadbeef
|
|
|
|
#endif
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2011-02-16 10:43:23 -08:00
|
|
|
|
2014-03-04 18:27:13 -08:00
|
|
|
class MemoryReportRequestChild : public PMemoryReportRequestChild,
|
|
|
|
public nsIRunnable
|
2011-02-16 10:43:23 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-03-04 18:27:13 -08:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2014-05-20 23:06:54 -07:00
|
|
|
MemoryReportRequestChild(uint32_t aGeneration, bool aAnonymize,
|
2014-09-18 08:59:00 -07:00
|
|
|
const MaybeFileDesc& aDMDFile);
|
2014-03-04 18:27:13 -08:00
|
|
|
NS_IMETHOD Run();
|
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~MemoryReportRequestChild();
|
|
|
|
|
2014-03-04 18:27:13 -08:00
|
|
|
uint32_t mGeneration;
|
2014-05-20 23:06:54 -07:00
|
|
|
bool mAnonymize;
|
2014-07-02 15:59:02 -07:00
|
|
|
FileDescriptor mDMDFile;
|
2011-02-16 10:43:23 -08:00
|
|
|
};
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable)
|
2014-03-04 18:27:13 -08:00
|
|
|
|
2014-05-20 23:06:54 -07:00
|
|
|
MemoryReportRequestChild::MemoryReportRequestChild(
|
2014-09-18 08:59:00 -07:00
|
|
|
uint32_t aGeneration, bool aAnonymize, const MaybeFileDesc& aDMDFile)
|
|
|
|
: mGeneration(aGeneration), mAnonymize(aAnonymize)
|
2011-02-16 10:43:23 -08:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryReportRequestChild);
|
2014-09-18 08:59:00 -07:00
|
|
|
if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) {
|
|
|
|
mDMDFile = aDMDFile.get_FileDescriptor();
|
|
|
|
}
|
2011-02-16 10:43:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
MemoryReportRequestChild::~MemoryReportRequestChild()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(MemoryReportRequestChild);
|
|
|
|
}
|
|
|
|
|
2014-05-13 10:13:00 -07:00
|
|
|
// IPC sender for remote GC/CC logging.
|
|
|
|
class CycleCollectWithLogsChild MOZ_FINAL
|
|
|
|
: public PCycleCollectWithLogsChild
|
|
|
|
, public nsICycleCollectorLogSink
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
CycleCollectWithLogsChild(const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
|
|
|
{
|
|
|
|
mGCLog = FileDescriptorToFILE(aGCLog, "w");
|
|
|
|
mCCLog = FileDescriptorToFILE(aCCLog, "w");
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Open(FILE** aGCLog, FILE** aCCLog) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!mGCLog) || NS_WARN_IF(!mCCLog)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
*aGCLog = mGCLog;
|
|
|
|
*aCCLog = mCCLog;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD CloseGCLog() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGCLog);
|
|
|
|
fclose(mGCLog);
|
|
|
|
mGCLog = nullptr;
|
|
|
|
SendCloseGCLog();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD CloseCCLog() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCCLog);
|
|
|
|
fclose(mCCLog);
|
|
|
|
mCCLog = nullptr;
|
|
|
|
SendCloseCCLog();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetFilenameIdentifier(nsAString& aIdentifier) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD SetFilenameIdentifier(const nsAString& aIdentifier) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetProcessIdentifier(int32_t *aIdentifier) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD SetProcessIdentifier(int32_t aIdentifier) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetGcLog(nsIFile** aPath) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD GetCcLog(nsIFile** aPath) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
~CycleCollectWithLogsChild()
|
|
|
|
{
|
|
|
|
if (mGCLog) {
|
|
|
|
fclose(mGCLog);
|
|
|
|
mGCLog = nullptr;
|
|
|
|
}
|
|
|
|
if (mCCLog) {
|
|
|
|
fclose(mCCLog);
|
|
|
|
mCCLog = nullptr;
|
|
|
|
}
|
|
|
|
// The XPCOM refcount drives the IPC lifecycle; see also
|
|
|
|
// DeallocPCycleCollectWithLogsChild.
|
|
|
|
unused << Send__delete__(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult UnimplementedProperty()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(false, "This object is a remote GC/CC logger;"
|
|
|
|
" this property isn't meaningful.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE* mGCLog;
|
|
|
|
FILE* mCCLog;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(CycleCollectWithLogsChild, nsICycleCollectorLogSink);
|
|
|
|
|
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:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit ConsoleListener(ContentChild* aChild)
|
2010-09-23 18:39:32 -07:00
|
|
|
: mChild(aChild) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICONSOLELISTENER
|
|
|
|
|
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
~ConsoleListener() {}
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
ContentChild* mChild;
|
|
|
|
friend class ContentChild;
|
|
|
|
};
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(ConsoleListener, nsIConsoleListener)
|
2010-09-23 18:39:32 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ConsoleListener::Observe(nsIConsoleMessage* aMessage)
|
|
|
|
{
|
|
|
|
if (!mChild)
|
|
|
|
return NS_OK;
|
2014-08-18 02:06:11 -07:00
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
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);
|
2014-03-04 20:13:19 -08:00
|
|
|
|
|
|
|
// Before we send the error to the parent process (which
|
|
|
|
// involves copying the memory), truncate any long lines. CSS
|
|
|
|
// errors in particular share the memory for long lines with
|
|
|
|
// repeated errors, but the IPC communication we're about to do
|
|
|
|
// will break that sharing, so we better truncate now.
|
|
|
|
if (sourceLine.Length() > 1000) {
|
|
|
|
sourceLine.Truncate(1000);
|
|
|
|
}
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
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
|
|
|
|
{
|
2014-06-23 12:56:07 -07:00
|
|
|
~SystemMessageHandledObserver() {}
|
|
|
|
|
2013-02-14 12:41:30 -08:00
|
|
|
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,
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* aData)
|
2013-02-14 12:41:30 -08:00
|
|
|
{
|
|
|
|
if (ContentChild::GetSingleton()) {
|
|
|
|
ContentChild::GetSingleton()->SendSystemMessageHandled();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(SystemMessageHandledObserver, nsIObserver)
|
2013-02-14 12:41:30 -08:00
|
|
|
|
2013-11-26 23:59:41 -08:00
|
|
|
class BackgroundChildPrimer MOZ_FINAL :
|
|
|
|
public nsIIPCBackgroundChildCreateCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BackgroundChildPrimer()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
private:
|
|
|
|
~BackgroundChildPrimer()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ActorCreated(PBackgroundChild* aActor) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor, "Failed to create a PBackgroundChild actor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ActorFailed() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(BackgroundChildPrimer, nsIIPCBackgroundChildCreateCallback)
|
2013-11-26 23:59:41 -08:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild* ContentChild::sSingleton;
|
2009-08-12 17:32:50 -07:00
|
|
|
|
2014-02-14 00:43:51 -08:00
|
|
|
// Performs initialization that is not fork-safe, i.e. that must be done after
|
|
|
|
// forking from the Nuwa process.
|
|
|
|
static void
|
2014-09-15 04:10:21 -07:00
|
|
|
InitOnContentProcessCreated()
|
2014-02-14 00:43:51 -08:00
|
|
|
{
|
2014-06-18 10:22:05 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Wait until we are forked from Nuwa
|
2014-09-15 04:10:21 -07:00
|
|
|
if (IsNuwaProcess()) {
|
2014-06-18 10:22:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2014-09-15 04:10:21 -07:00
|
|
|
|
2014-02-14 00:43:51 -08:00
|
|
|
// This will register cross-process observer.
|
|
|
|
mozilla::dom::time::InitializeDateCacheCleaner();
|
|
|
|
}
|
|
|
|
|
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
|
2014-03-25 21:56:35 -07:00
|
|
|
, mCanOverrideProcessName(true)
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-10 22:44:06 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN(ContentChild)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentChild)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
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
|
2013-10-28 07:04:12 -07:00
|
|
|
gtk_init(nullptr, nullptr);
|
2010-08-20 16:24:40 -07:00
|
|
|
#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
|
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
SetTransport(aChannel);
|
|
|
|
#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
|
|
|
|
2014-01-31 15:02:30 -08:00
|
|
|
// Once we start sending IPC messages, we need the thread manager to be
|
|
|
|
// initialized so we can deal with the responses. Do that here before we
|
|
|
|
// try to construct the crash reporter.
|
|
|
|
nsresult rv = nsThreadManager::get()->Init();
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:52:37 -07:00
|
|
|
Open(aChannel, aParentHandle, aIOLoop);
|
2009-08-12 17:32:50 -07:00
|
|
|
sSingleton = this;
|
|
|
|
|
2014-08-05 21:44:42 -07:00
|
|
|
// Make sure there's an nsAutoScriptBlocker on the stack when dispatching
|
|
|
|
// urgent messages.
|
|
|
|
GetIPCChannel()->BlockScripts();
|
|
|
|
|
2014-02-05 08:37:26 -08:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
// Send the parent our X socket to act as a proxy reference for our X
|
|
|
|
// resources.
|
|
|
|
int xSocketFd = ConnectionNumber(DefaultXDisplay());
|
|
|
|
SendBackUpXResources(FileDescriptor(xSocketFd));
|
|
|
|
#endif
|
|
|
|
|
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-07-10 15:05:39 -07:00
|
|
|
GetCPOWManager();
|
|
|
|
|
2014-06-03 14:15:27 -07:00
|
|
|
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
|
2014-02-13 02:42:41 -08:00
|
|
|
InitProcessAttributes();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::InitProcessAttributes()
|
|
|
|
{
|
2014-08-26 10:03:09 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
2014-03-25 21:56:35 -07:00
|
|
|
SetProcessName(NS_LITERAL_STRING("(Nuwa)"), false);
|
2014-02-13 02:42:41 -08:00
|
|
|
return;
|
2013-06-03 03:14:40 -07:00
|
|
|
}
|
|
|
|
#endif
|
2012-09-10 21:30:33 -07:00
|
|
|
if (mIsForApp && !mIsForBrowser) {
|
2014-03-25 21:56:35 -07:00
|
|
|
SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
|
2012-09-10 21:30:33 -07:00
|
|
|
} else {
|
2014-03-25 21:56:35 -07:00
|
|
|
SetProcessName(NS_LITERAL_STRING("Browser"), false);
|
2012-09-10 21:30:33 -07:00
|
|
|
}
|
2014-08-26 10:03:09 -07:00
|
|
|
#else
|
|
|
|
SetProcessName(NS_LITERAL_STRING("Web Content"), true);
|
|
|
|
#endif
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2012-10-05 14:54:54 -07:00
|
|
|
void
|
2014-03-25 21:56:35 -07:00
|
|
|
ContentChild::SetProcessName(const nsAString& aName, bool aDontOverride)
|
2012-10-05 14:54:54 -07:00
|
|
|
{
|
2014-03-25 21:56:35 -07:00
|
|
|
if (!mCanOverrideProcessName) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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());
|
2014-03-25 21:56:35 -07:00
|
|
|
|
|
|
|
if (aDontOverride) {
|
|
|
|
mCanOverrideProcessName = false;
|
|
|
|
}
|
2012-10-05 14:54:54 -07:00
|
|
|
}
|
|
|
|
|
2013-10-24 20:47:48 -07:00
|
|
|
void
|
2012-10-05 14:54:54 -07:00
|
|
|
ContentChild::GetProcessName(nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Assign(mProcessName);
|
|
|
|
}
|
|
|
|
|
2013-10-24 20:47:48 -07:00
|
|
|
void
|
|
|
|
ContentChild::GetProcessName(nsACString& aName)
|
|
|
|
{
|
|
|
|
aName.Assign(NS_ConvertUTF16toUTF8(mProcessName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
ContentChild::AppendProcessId(nsACString& aName)
|
|
|
|
{
|
|
|
|
if (!aName.IsEmpty()) {
|
2014-05-21 20:48:51 -07:00
|
|
|
aName.Append(' ');
|
2013-10-24 20:47:48 -07:00
|
|
|
}
|
|
|
|
unsigned pid = getpid();
|
|
|
|
aName.Append(nsPrintfCString("(pid %u)", pid));
|
|
|
|
}
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
void
|
|
|
|
ContentChild::InitXPCOM()
|
|
|
|
{
|
2013-11-26 23:59:41 -08:00
|
|
|
// Do this as early as possible to get the parent process to initialize the
|
|
|
|
// background thread since we'll likely need database information very soon.
|
|
|
|
BackgroundChild::Startup();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback =
|
|
|
|
new BackgroundChildPrimer();
|
|
|
|
if (!BackgroundChild::GetOrCreateForCurrentThread(callback)) {
|
|
|
|
MOZ_CRASH("Failed to create PBackgroundChild!");
|
|
|
|
}
|
|
|
|
|
2014-09-26 16:21:57 -07:00
|
|
|
BlobChild::Startup(BlobChild::FriendKey());
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
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
|
|
|
|
2014-07-24 14:07:53 -07:00
|
|
|
bool isOffline;
|
2014-10-03 07:52:37 -07:00
|
|
|
SendGetXPCOMProcessAttributes(&isOffline, &mAvailableDictionaries);
|
2012-11-08 13:09:39 -08:00
|
|
|
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();
|
2014-02-14 00:43:51 -08:00
|
|
|
|
2014-09-15 04:10:21 -07:00
|
|
|
InitOnContentProcessCreated();
|
2010-09-23 18:39:32 -07:00
|
|
|
}
|
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
PMemoryReportRequestChild*
|
2014-05-20 23:06:54 -07:00
|
|
|
ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
|
|
|
|
const bool &aAnonymize,
|
|
|
|
const bool &aMinimizeMemoryUsage,
|
2014-09-18 08:59:00 -07:00
|
|
|
const MaybeFileDesc& aDMDFile)
|
2011-02-16 10:43:23 -08:00
|
|
|
{
|
2014-05-20 23:06:54 -07:00
|
|
|
MemoryReportRequestChild *actor =
|
2014-07-02 15:59:02 -07:00
|
|
|
new MemoryReportRequestChild(aGeneration, aAnonymize, aDMDFile);
|
2014-03-04 18:27:13 -08:00
|
|
|
actor->AddRef();
|
|
|
|
return actor;
|
2011-02-16 10:43:23 -08:00
|
|
|
}
|
|
|
|
|
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 {
|
2014-06-23 12:56:07 -07:00
|
|
|
~MemoryReportsWrapper() {}
|
2011-06-29 16:39:32 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit MemoryReportsWrapper(InfallibleTArray<MemoryReport>* r) : mReports(r) { }
|
2011-06-29 16:39:32 -07:00
|
|
|
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
|
|
|
|
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit MemoryReportCallback(const nsACString& aProcess)
|
2011-06-29 16:39:32 -07:00
|
|
|
: 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:
|
2014-06-23 12:56:07 -07:00
|
|
|
~MemoryReportCallback() {}
|
|
|
|
|
2011-06-29 16:39:32 -07:00
|
|
|
const nsCString mProcess;
|
|
|
|
};
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(
|
2011-06-29 16:39:32 -07:00
|
|
|
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
|
2013-10-22 22:26:24 -07:00
|
|
|
ContentChild::RecvPMemoryReportRequestConstructor(
|
2014-05-20 23:06:54 -07:00
|
|
|
PMemoryReportRequestChild* aChild,
|
|
|
|
const uint32_t& aGeneration,
|
|
|
|
const bool& aAnonymize,
|
|
|
|
const bool& aMinimizeMemoryUsage,
|
2014-09-18 08:59:00 -07:00
|
|
|
const MaybeFileDesc& aDMDFile)
|
2011-02-16 10:43:23 -08:00
|
|
|
{
|
2014-05-20 23:06:54 -07:00
|
|
|
MemoryReportRequestChild *actor =
|
|
|
|
static_cast<MemoryReportRequestChild*>(aChild);
|
2014-03-04 18:27:13 -08:00
|
|
|
nsresult rv;
|
|
|
|
|
2014-05-20 23:06:54 -07:00
|
|
|
if (aMinimizeMemoryUsage) {
|
2014-03-04 18:27:13 -08:00
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
rv = mgr->MinimizeMemoryUsage(actor);
|
|
|
|
// mgr will eventually call actor->Run()
|
|
|
|
} else {
|
|
|
|
rv = actor->Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
return !NS_WARN_IF(NS_FAILED(rv));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP MemoryReportRequestChild::Run()
|
|
|
|
{
|
|
|
|
ContentChild *child = static_cast<ContentChild*>(Manager());
|
2011-02-16 10:43:23 -08:00
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
|
2011-06-29 16:39:32 -07:00
|
|
|
InfallibleTArray<MemoryReport> reports;
|
|
|
|
|
2013-10-24 20:47:48 -07:00
|
|
|
nsCString process;
|
2014-03-04 18:27:13 -08:00
|
|
|
child->GetProcessName(process);
|
|
|
|
child->AppendProcessId(process);
|
2011-06-29 16:39:32 -07:00
|
|
|
|
2013-12-01 16:29:37 -08:00
|
|
|
// Run the reporters. The callback will turn each measurement into a
|
2013-08-27 16:24:51 -07:00
|
|
|
// MemoryReport.
|
2011-07-06 22:54:34 -07:00
|
|
|
nsRefPtr<MemoryReportsWrapper> wrappedReports =
|
|
|
|
new MemoryReportsWrapper(&reports);
|
|
|
|
nsRefPtr<MemoryReportCallback> cb = new MemoryReportCallback(process);
|
2014-05-20 23:06:54 -07:00
|
|
|
mgr->GetReportsForThisProcessExtended(cb, wrappedReports, mAnonymize,
|
2014-07-02 15:59:02 -07:00
|
|
|
FileDescriptorToFILE(mDMDFile, "wb"));
|
2011-02-16 10:43:23 -08:00
|
|
|
|
2014-03-04 18:27:13 -08:00
|
|
|
bool sent = Send__delete__(this, mGeneration, reports);
|
|
|
|
return sent ? NS_OK : NS_ERROR_FAILURE;
|
2011-02-16 10:43:23 -08:00
|
|
|
}
|
|
|
|
|
2012-12-05 19:01:58 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAudioChannelNotify()
|
|
|
|
{
|
|
|
|
nsRefPtr<AudioChannelService> service =
|
|
|
|
AudioChannelService::GetAudioChannelService();
|
|
|
|
if (service) {
|
|
|
|
service->Notify();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-03 07:36:46 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvDataStoreNotify(const uint32_t& aAppId,
|
|
|
|
const nsString& aName,
|
|
|
|
const nsString& aManifestURL)
|
|
|
|
{
|
|
|
|
nsRefPtr<DataStoreService> service = DataStoreService::GetOrCreate();
|
|
|
|
if (NS_WARN_IF(!service)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = service->EnableDataStore(aAppId, aName, aManifestURL);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2014-03-04 18:27:13 -08:00
|
|
|
static_cast<MemoryReportRequestChild*>(actor)->Release();
|
2012-10-02 18:19:11 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-13 10:13:00 -07:00
|
|
|
PCycleCollectWithLogsChild*
|
|
|
|
ContentChild::AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
|
|
|
|
const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
|
|
|
{
|
|
|
|
CycleCollectWithLogsChild* actor = new CycleCollectWithLogsChild(aGCLog, aCCLog);
|
|
|
|
// Return actor with refcount 0, which is safe because it has a non-XPCOM type.
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
2012-10-15 19:12:14 -07:00
|
|
|
bool
|
2014-05-13 10:13:00 -07:00
|
|
|
ContentChild::RecvPCycleCollectWithLogsConstructor(PCycleCollectWithLogsChild* aActor,
|
|
|
|
const bool& aDumpAllTraces,
|
|
|
|
const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
2012-10-15 19:12:14 -07:00
|
|
|
{
|
2014-05-13 10:13:00 -07:00
|
|
|
// Take a reference here, where the XPCOM type is regained.
|
|
|
|
nsRefPtr<CycleCollectWithLogsChild> sink = static_cast<CycleCollectWithLogsChild*>(aActor);
|
2012-10-29 17:41:14 -07:00
|
|
|
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
|
|
|
|
2014-05-13 10:13:00 -07:00
|
|
|
dumper->DumpGCAndCCLogsToSink(aDumpAllTraces, sink);
|
|
|
|
|
|
|
|
// The actor's destructor is called when the last reference goes away...
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* /* aActor */)
|
|
|
|
{
|
|
|
|
// ...so when we get here, there's nothing for us to do.
|
|
|
|
//
|
|
|
|
// Also, we're already in ~CycleCollectWithLogsChild (q.v.) at
|
|
|
|
// this point, so we shouldn't touch the actor in any case.
|
2012-10-15 19:12:14 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-10 22:44:13 -07:00
|
|
|
PContentBridgeChild*
|
|
|
|
ContentChild::AllocPContentBridgeChild(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return ContentBridgeChild::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
|
|
|
PContentBridgeParent*
|
|
|
|
ContentChild::AllocPContentBridgeParent(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mLastBridge);
|
|
|
|
mLastBridge = static_cast<ContentBridgeParent*>(
|
|
|
|
ContentBridgeParent::Create(aTransport, aOtherProcess));
|
|
|
|
return mLastBridge;
|
|
|
|
}
|
|
|
|
|
2013-09-25 21:19:09 -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);
|
|
|
|
}
|
|
|
|
|
2014-04-30 18:52:00 -07:00
|
|
|
PSharedBufferManagerChild*
|
|
|
|
ContentChild::AllocPSharedBufferManagerChild(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return SharedBufferManagerChild::StartUpInChildProcess(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2013-09-25 21:19:09 -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-11-26 23:59:41 -08:00
|
|
|
PBackgroundChild*
|
|
|
|
ContentChild::AllocPBackgroundChild(Transport* aTransport,
|
|
|
|
ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return BackgroundChild::Alloc(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2014-09-10 04:36:17 -07:00
|
|
|
#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX)
|
|
|
|
static void
|
|
|
|
SetUpSandboxEnvironment()
|
|
|
|
{
|
|
|
|
// Set up a low integrity temp directory. This only makes sense if the
|
|
|
|
// delayed integrity level for the content process is INTEGRITY_LEVEL_LOW.
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIProperties> directoryService =
|
|
|
|
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> lowIntegrityTemp;
|
|
|
|
rv = directoryService->Get(NS_WIN_LOW_INTEGRITY_TEMP, NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(lowIntegrityTemp));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Undefine returns a failure if the property is not already set.
|
|
|
|
unused << directoryService->Undefine(NS_OS_TEMP_DIR);
|
|
|
|
rv = directoryService->Set(NS_OS_TEMP_DIR, lowIntegrityTemp);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set TEMP and TMP environment variables.
|
|
|
|
nsAutoString lowIntegrityTempPath;
|
|
|
|
rv = lowIntegrityTemp->GetPath(lowIntegrityTempPath);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool setOK = SetEnvironmentVariableW(L"TEMP", lowIntegrityTempPath.get());
|
|
|
|
NS_WARN_IF_FALSE(setOK, "Failed to set TEMP to low integrity temp path");
|
|
|
|
setOK = SetEnvironmentVariableW(L"TMP", lowIntegrityTempPath.get());
|
|
|
|
NS_WARN_IF_FALSE(setOK, "Failed to set TMP to low integrity temp path");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::CleanUpSandboxEnvironment()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIProperties> directoryService =
|
|
|
|
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> lowIntegrityTemp;
|
|
|
|
rv = directoryService->Get(NS_WIN_LOW_INTEGRITY_TEMP, NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(lowIntegrityTemp));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't check the return value as the directory will only have been created
|
|
|
|
// if it has been used.
|
|
|
|
unused << lowIntegrityTemp->Remove(/* aRecursive */ true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-17 12:06:36 -08:00
|
|
|
bool
|
2014-03-12 15:48:15 -07:00
|
|
|
ContentChild::RecvSetProcessSandbox()
|
2013-01-17 12:06:36 -08:00
|
|
|
{
|
2014-08-15 11:56:28 -07:00
|
|
|
// We may want to move the sandbox initialization somewhere else
|
|
|
|
// at some point; see bug 880808.
|
2014-03-12 15:48:15 -07:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
|
|
|
#if defined(XP_LINUX)
|
2014-08-15 11:56:28 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
|
|
|
|
// For B2G >= KitKat, sandboxing is mandatory; this has already
|
|
|
|
// been enforced by ContentParent::StartUp().
|
|
|
|
MOZ_ASSERT(CanSandboxContentProcess());
|
|
|
|
#else
|
|
|
|
// Otherwise, sandboxing is best-effort.
|
|
|
|
if (!CanSandboxContentProcess()) {
|
|
|
|
return true;
|
2014-08-12 21:28:27 -07:00
|
|
|
}
|
2014-08-15 11:56:28 -07:00
|
|
|
#endif
|
|
|
|
SetContentProcessSandbox();
|
2014-03-12 15:48:15 -07:00
|
|
|
#elif defined(XP_WIN)
|
2014-06-11 07:32:37 -07:00
|
|
|
nsAdoptingString contentSandboxPref =
|
|
|
|
Preferences::GetString("browser.tabs.remote.sandbox");
|
|
|
|
if (contentSandboxPref.EqualsLiteral("on")
|
|
|
|
|| contentSandboxPref.EqualsLiteral("warn")) {
|
|
|
|
mozilla::SandboxTarget::Instance()->StartSandbox();
|
2014-09-10 04:36:17 -07:00
|
|
|
SetUpSandboxEnvironment();
|
2014-06-11 07:32:37 -07:00
|
|
|
}
|
2014-03-12 15:48:15 -07:00
|
|
|
#endif
|
2013-08-12 12:58:35 -07:00
|
|
|
#endif
|
2014-05-27 20:04:23 -07:00
|
|
|
return true;
|
2013-01-17 12:06:36 -08:00
|
|
|
}
|
|
|
|
|
2013-11-24 15:50:03 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvSpeakerManagerNotify()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-08-19 19:25:55 -07:00
|
|
|
// Only notify the process which has the SpeakerManager instance.
|
2014-05-27 20:04:23 -07:00
|
|
|
nsRefPtr<SpeakerManagerService> service =
|
|
|
|
SpeakerManagerService::GetSpeakerManagerService();
|
|
|
|
if (service) {
|
|
|
|
service->Notify();
|
|
|
|
}
|
|
|
|
return true;
|
2013-11-24 15:50:03 -08:00
|
|
|
#endif
|
2014-05-27 20:04:23 -07:00
|
|
|
return false;
|
2013-11-24 15:50:03 -08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-05-08 15:43:53 -07:00
|
|
|
MOZ_ASSERT(!ManagedPJavaScriptChild().Length());
|
|
|
|
|
2014-06-10 22:44:06 -07:00
|
|
|
return nsIContentChild::AllocPJavaScriptChild();
|
2013-07-03 00:24:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-06-10 22:44:06 -07:00
|
|
|
ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *aChild)
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
2014-06-10 22:44:06 -07:00
|
|
|
return nsIContentChild::DeallocPJavaScriptChild(aChild);
|
2013-07-03 00:24:32 -07:00
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
PBrowserChild*
|
2013-07-08 08:48:39 -07:00
|
|
|
ContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
|
2014-06-03 14:15:27 -07:00
|
|
|
const uint32_t& aChromeFlags,
|
2014-06-10 22:44:06 -07:00
|
|
|
const uint64_t& aID,
|
2014-06-03 14:15:27 -07:00
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2014-06-10 22:44:06 -07:00
|
|
|
return nsIContentChild::AllocPBrowserChild(aContext,
|
|
|
|
aChromeFlags,
|
|
|
|
aID,
|
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
|
|
|
}
|
2013-02-22 20:24:28 -08:00
|
|
|
|
2014-06-10 22:44:06 -07:00
|
|
|
bool
|
|
|
|
ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
|
|
|
const uint64_t& aID,
|
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
|
|
|
return PContentChild::SendPBrowserConstructor(aActor,
|
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
|
|
|
aID,
|
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
2013-02-22 20:24:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-06-03 14:15:27 -07:00
|
|
|
ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
|
|
|
const uint64_t& aID,
|
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
2013-02-22 20:24:28 -08:00
|
|
|
{
|
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 =
|
2014-06-03 14:15:27 -07:00
|
|
|
static_cast<nsITabChild*>(static_cast<TabChild*>(aActor));
|
2013-02-22 20:24:28 -08:00
|
|
|
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);
|
2014-02-13 02:42:41 -08:00
|
|
|
|
|
|
|
// Redo InitProcessAttributes() when the app or browser is really
|
|
|
|
// launching so the attributes will be correct.
|
2014-06-03 14:15:27 -07:00
|
|
|
mID = aID;
|
|
|
|
mIsForApp = aIsForApp;
|
|
|
|
mIsForBrowser = aIsForBrowser;
|
2014-02-13 02:42:41 -08:00
|
|
|
InitProcessAttributes();
|
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
|
|
|
}
|
|
|
|
|
2014-10-03 07:52:37 -07:00
|
|
|
void
|
|
|
|
ContentChild::GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries)
|
|
|
|
{
|
|
|
|
aDictionaries = mAvailableDictionaries;
|
|
|
|
}
|
|
|
|
|
2014-03-25 11:37:13 -07:00
|
|
|
PFileDescriptorSetChild*
|
|
|
|
ContentChild::AllocPFileDescriptorSetChild(const FileDescriptor& aFD)
|
|
|
|
{
|
|
|
|
return new FileDescriptorSetChild(aFD);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPFileDescriptorSetChild(PFileDescriptorSetChild* aActor)
|
|
|
|
{
|
|
|
|
delete static_cast<FileDescriptorSetChild*>(aActor);
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-22 20:24:28 -08:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2014-06-10 22:44:06 -07:00
|
|
|
ContentChild::DeallocPBrowserChild(PBrowserChild* aIframe)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2014-06-10 22:44:06 -07:00
|
|
|
return nsIContentChild::DeallocPBrowserChild(aIframe);
|
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
|
|
|
{
|
2014-06-10 22:44:06 -07:00
|
|
|
return nsIContentChild::AllocPBlobChild(aParams);
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
|
|
|
|
2014-07-01 15:24:27 -07:00
|
|
|
mozilla::PRemoteSpellcheckEngineChild *
|
|
|
|
ContentChild::AllocPRemoteSpellcheckEngineChild()
|
|
|
|
{
|
2014-10-03 07:52:37 -07:00
|
|
|
NS_NOTREACHED("Default Constructor for PRemoteSpellcheckEngineChild should never be called");
|
2014-07-01 15:24:27 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild *child)
|
|
|
|
{
|
|
|
|
delete child;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-06-10 22:44:06 -07:00
|
|
|
return nsIContentChild::DeallocPBlobChild(aActor);
|
2012-08-01 23:02:29 -07:00
|
|
|
}
|
|
|
|
|
2014-06-10 22:44:06 -07:00
|
|
|
PBlobChild*
|
|
|
|
ContentChild::SendPBlobConstructor(PBlobChild* aActor,
|
|
|
|
const BlobConstructorParams& aParams)
|
2012-08-01 23:02:29 -07:00
|
|
|
{
|
2014-06-10 22:44:06 -07:00
|
|
|
return PContentChild::SendPBlobConstructor(aActor, aParams);
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-18 13:49:53 -08:00
|
|
|
asmjscache::PAsmJSCacheEntryChild*
|
2013-12-04 20:32:52 -08:00
|
|
|
ContentChild::AllocPAsmJSCacheEntryChild(
|
|
|
|
const asmjscache::OpenMode& aOpenMode,
|
|
|
|
const asmjscache::WriteParams& aWriteParams,
|
|
|
|
const IPC::Principal& aPrincipal)
|
2013-11-18 13:49:53 -08:00
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
NS_NOTREACHED("Should never get here!");
|
|
|
|
return nullptr;
|
2013-11-18 13:49:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPAsmJSCacheEntryChild(PAsmJSCacheEntryChild* aActor)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
asmjscache::DeallocEntryChild(aActor);
|
|
|
|
return true;
|
2013-11-18 13:49:53 -08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-10-06 15:45:42 -07:00
|
|
|
jsipc::JavaScriptShared*
|
2013-07-03 00:24:32 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-03-04 19:25:40 -08:00
|
|
|
PFileSystemRequestChild*
|
|
|
|
ContentChild::AllocPFileSystemRequestChild(const FileSystemParams& aParams)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("Should never get here!");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPFileSystemRequestChild(PFileSystemRequestChild* aFileSystem)
|
|
|
|
{
|
|
|
|
mozilla::dom::FileSystemTaskBase* child =
|
|
|
|
static_cast<mozilla::dom::FileSystemTaskBase*>(aFileSystem);
|
|
|
|
// The reference is increased in FileSystemTaskBase::Start of
|
|
|
|
// FileSystemTaskBase.cpp. We should decrease it after IPC.
|
|
|
|
NS_RELEASE(child);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-01 03:28:18 -07:00
|
|
|
PMobileConnectionChild*
|
|
|
|
ContentChild::SendPMobileConnectionConstructor(PMobileConnectionChild* aActor,
|
|
|
|
const uint32_t& aClientId)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
// Add an extra ref for IPDL. Will be released in
|
|
|
|
// ContentChild::DeallocPMobileConnectionChild().
|
|
|
|
static_cast<MobileConnectionChild*>(aActor)->AddRef();
|
|
|
|
return PContentChild::SendPMobileConnectionConstructor(aActor, aClientId);
|
|
|
|
#else
|
|
|
|
MOZ_CRASH("No support for mobileconnection on this platform!");;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
PMobileConnectionChild*
|
|
|
|
ContentChild::AllocPMobileConnectionChild(const uint32_t& aClientId)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
NS_NOTREACHED("No one should be allocating PMobileConnectionChild actors");
|
|
|
|
return nullptr;
|
|
|
|
#else
|
|
|
|
MOZ_CRASH("No support for mobileconnection on this platform!");;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPMobileConnectionChild(PMobileConnectionChild* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
// MobileConnectionChild is refcounted, must not be freed manually.
|
|
|
|
static_cast<MobileConnectionChild*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
MOZ_CRASH("No support for mobileconnection on this platform!");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-07-14 10:22:26 -07:00
|
|
|
PScreenManagerChild*
|
|
|
|
ContentChild::AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
|
|
|
|
float* aSystemDefaultScale,
|
|
|
|
bool* aSuccess)
|
|
|
|
{
|
|
|
|
// The ContentParent should never attempt to allocate the
|
|
|
|
// nsScreenManagerProxy. Instead, the nsScreenManagerProxy
|
|
|
|
// service is requested and instantiated via XPCOM, and the
|
|
|
|
// constructor of nsScreenManagerProxy sets up the IPC connection.
|
|
|
|
NS_NOTREACHED("Should never get here!");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPScreenManagerChild(PScreenManagerChild* aService)
|
|
|
|
{
|
|
|
|
// nsScreenManagerProxy is AddRef'd in its constructor.
|
|
|
|
nsScreenManagerProxy *child = static_cast<nsScreenManagerProxy*>(aService);
|
|
|
|
child->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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,
|
2014-02-13 14:43:58 -08:00
|
|
|
const uint32_t& aContentDispositionHint,
|
|
|
|
const nsString& aContentDispositionFilename,
|
2013-07-08 08:48:39 -07:00
|
|
|
const bool& aForceSave,
|
|
|
|
const int64_t& aContentLength,
|
2013-09-12 12:24:10 -07:00
|
|
|
const OptionalURIParams& aReferrer,
|
|
|
|
PBrowserChild* aBrowser)
|
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;
|
|
|
|
}
|
|
|
|
|
2014-08-18 02:06:11 -07:00
|
|
|
PCellBroadcastChild*
|
|
|
|
ContentChild::AllocPCellBroadcastChild()
|
|
|
|
{
|
|
|
|
MOZ_CRASH("No one should be allocating PCellBroadcastChild actors");
|
|
|
|
}
|
|
|
|
|
|
|
|
PCellBroadcastChild*
|
|
|
|
ContentChild::SendPCellBroadcastConstructor(PCellBroadcastChild* aActor)
|
|
|
|
{
|
|
|
|
aActor = PContentChild::SendPCellBroadcastConstructor(aActor);
|
|
|
|
if (aActor) {
|
|
|
|
static_cast<CellBroadcastIPCService*>(aActor)->AddRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
return aActor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPCellBroadcastChild(PCellBroadcastChild* aActor)
|
|
|
|
{
|
|
|
|
static_cast<CellBroadcastIPCService*>(aActor)->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;
|
|
|
|
}
|
|
|
|
|
2014-09-25 22:00:24 -07:00
|
|
|
PVoicemailChild*
|
|
|
|
ContentChild::AllocPVoicemailChild()
|
|
|
|
{
|
|
|
|
MOZ_CRASH("No one should be allocating PVoicemailChild actors");
|
|
|
|
}
|
|
|
|
|
|
|
|
PVoicemailChild*
|
|
|
|
ContentChild::SendPVoicemailConstructor(PVoicemailChild* aActor)
|
|
|
|
{
|
|
|
|
aActor = PContentChild::SendPVoicemailConstructor(aActor);
|
|
|
|
if (aActor) {
|
|
|
|
static_cast<VoicemailIPCService*>(aActor)->AddRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
return aActor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPVoicemailChild(PVoicemailChild* aActor)
|
|
|
|
{
|
|
|
|
static_cast<VoicemailIPCService*>(aActor)->Release();
|
|
|
|
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,
|
2014-07-25 13:17:36 -07:00
|
|
|
const nsCString& locale,
|
|
|
|
const bool& reset)
|
2010-03-10 21:33:00 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
2014-07-25 13:17:36 -07:00
|
|
|
chromeRegistry->RegisterRemoteChrome(packages, resources, overrides,
|
|
|
|
locale, reset);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvRegisterChromeItem(const ChromeRegistryItem& item)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
|
|
|
switch (item.type()) {
|
|
|
|
case ChromeRegistryItem::TChromePackage:
|
|
|
|
chromeRegistry->RegisterPackage(item.get_ChromePackage());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ChromeRegistryItem::TOverrideMapping:
|
|
|
|
chromeRegistry->RegisterOverride(item.get_OverrideMapping());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false, "bad chrome item");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
nsCOMPtr<nsIIOService> io (do_GetIOService());
|
|
|
|
NS_ASSERTION(io, "IO Service can not be null");
|
2010-05-11 05:44:12 -07:00
|
|
|
|
2014-05-27 20:04:23 -07:00
|
|
|
io->SetOffline(offline);
|
2011-02-14 14:34:46 -08:00
|
|
|
|
2014-05-27 20:04:23 -07:00
|
|
|
return true;
|
2010-05-11 05:44:12 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-04-21 10:18:53 -07:00
|
|
|
mIdleObservers.Clear();
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-05-20 22:49:36 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvSystemMemoryAvailable(const uint64_t& aGetterId,
|
|
|
|
const uint32_t& aMemoryAvailable)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
nsRefPtr<Promise> p = dont_AddRef(reinterpret_cast<Promise*>(aGetterId));
|
2014-05-20 22:49:36 -07:00
|
|
|
|
2014-05-27 20:04:23 -07:00
|
|
|
if (!aMemoryAvailable) {
|
2014-06-03 08:38:38 -07:00
|
|
|
p->MaybeReject(NS_ERROR_NOT_AVAILABLE);
|
2014-05-27 20:04:23 -07:00
|
|
|
return true;
|
|
|
|
}
|
2014-05-20 22:49:36 -07:00
|
|
|
|
2014-05-27 20:04:23 -07:00
|
|
|
p->MaybeResolve((int)aMemoryAvailable);
|
|
|
|
return true;
|
2014-05-20 22:49:36 -07:00
|
|
|
}
|
|
|
|
|
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) {
|
2014-05-27 20:04:23 -07:00
|
|
|
history->NotifyVisited(newURI);
|
2012-11-09 01:55:54 -08:00
|
|
|
}
|
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,
|
2013-11-06 09:21:15 -08:00
|
|
|
const InfallibleTArray<CpowEntry>& aCpows,
|
|
|
|
const IPC::Principal& aPrincipal)
|
2010-08-31 11:58:35 -07:00
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::sChildProcessManager;
|
|
|
|
if (cpm) {
|
|
|
|
StructuredCloneData cloneData = ipc::UnpackClonedMessageDataForChild(aData);
|
|
|
|
CpowIdHolder cpows(GetCPOWManager(), aCpows);
|
|
|
|
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
|
|
|
|
aMsg, false, &cloneData, &cpows, aPrincipal, nullptr);
|
|
|
|
}
|
|
|
|
return true;
|
2010-08-31 11:58:35 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGeolocationUpdate(const GeoPosition& somewhere)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> gs = do_GetService("@mozilla.org/geolocation/service;1");
|
|
|
|
if (!gs) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
|
|
|
|
gs->Update(position);
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
2010-09-20 21:16:37 -07:00
|
|
|
}
|
|
|
|
|
2014-10-03 07:52:37 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvUpdateDictionaryList(const InfallibleTArray<nsString>& aDictionaries)
|
|
|
|
{
|
|
|
|
mAvailableDictionaries = aDictionaries;
|
|
|
|
mozInlineSpellChecker::UpdateCanEnableInlineSpellChecking();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
|
|
|
{
|
|
|
|
#if MOZ_PERMISSIONS
|
2014-05-27 20:04:23 -07:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
|
|
|
services::GetPermissionManager();
|
|
|
|
nsPermissionManager* permissionManager =
|
|
|
|
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
|
|
|
NS_ABORT_IF_FALSE(permissionManager,
|
|
|
|
"We have no permissionManager in the Content process !");
|
|
|
|
|
|
|
|
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;
|
|
|
|
nsresult rv = secMan->GetAppCodebasePrincipal(uri, permission.appId,
|
2012-08-23 11:38:01 -07:00
|
|
|
permission.isInBrowserElement,
|
|
|
|
getter_AddRefs(principal));
|
2014-05-27 20:04:23 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
2014-09-14 18:33:12 -07:00
|
|
|
// child processes don't care about modification time.
|
|
|
|
int64_t modificationTime = 0;
|
|
|
|
|
2014-05-27 20:04:23 -07:00
|
|
|
permissionManager->AddInternal(principal,
|
|
|
|
nsCString(permission.type),
|
|
|
|
permission.capability,
|
|
|
|
0,
|
|
|
|
permission.expireType,
|
|
|
|
permission.expireTime,
|
2014-09-14 18:33:12 -07:00
|
|
|
modificationTime,
|
2014-05-27 20:04:23 -07:00
|
|
|
nsPermissionManager::eNotify,
|
|
|
|
nsPermissionManager::eNoDBOperation);
|
2010-10-09 11:07:38 -07:00
|
|
|
#endif
|
|
|
|
|
2014-05-27 20:04:23 -07:00
|
|
|
return true;
|
2010-10-09 11:07:38 -07:00
|
|
|
}
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2010-11-24 10:22:40 -08:00
|
|
|
bool
|
2013-10-27 15:38:40 -07:00
|
|
|
ContentChild::RecvScreenSizeChanged(const gfxIntSize& size)
|
2010-11-24 10:22:40 -08:00
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
mScreenSize = size;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Message currently only expected on android");
|
|
|
|
#endif
|
2014-05-27 20:04:23 -07:00
|
|
|
return true;
|
2010-11-24 10:22:40 -08:00
|
|
|
}
|
|
|
|
|
2010-12-11 14:36:08 -08:00
|
|
|
bool
|
|
|
|
ContentChild::RecvFlushMemory(const nsString& reason)
|
|
|
|
{
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
// Don't flush memory in the nuwa process: the GC thread could be frozen.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2010-12-11 14:36:08 -08:00
|
|
|
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.
|
2014-07-28 08:43:00 -07:00
|
|
|
nsCOMPtr<nsIAccessibilityService> accService =
|
|
|
|
services::GetAccessibilityService();
|
2011-07-20 21:37:32 -07:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-13 10:53:51 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGarbageCollect()
|
|
|
|
{
|
2013-12-02 20:07:02 -08:00
|
|
|
// Rebroadcast the "child-gc-request" so that workers will GC.
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
obs->NotifyObservers(nullptr, "child-gc-request", nullptr);
|
|
|
|
}
|
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-12-02 20:07:02 -08:00
|
|
|
// Rebroadcast the "child-cc-request" so that workers will CC.
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
obs->NotifyObservers(nullptr, "child-cc-request", nullptr);
|
|
|
|
}
|
2011-09-13 10:53:51 -07:00
|
|
|
nsJSContext::CycleCollectNow();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-01 04:28:44 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
static void
|
|
|
|
OnFinishNuwaPreparation ()
|
|
|
|
{
|
|
|
|
MakeNuwaProcess();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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();
|
2013-10-01 04:28:44 -07:00
|
|
|
|
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,
|
2014-09-23 23:14:55 -07:00
|
|
|
const nsCString& name, const nsCString& UAName,
|
|
|
|
const nsCString& ID, const nsCString& vendor)
|
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);
|
2014-09-23 23:14:55 -07:00
|
|
|
mAppInfo.ID.Assign(ID);
|
|
|
|
mAppInfo.vendor.Assign(vendor);
|
2013-11-29 01:28:54 -08:00
|
|
|
|
|
|
|
if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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.
|
2013-11-29 01:28:54 -08:00
|
|
|
if ((mIsForApp || mIsForBrowser)
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
&& !IsNuwaProcess()
|
|
|
|
#endif
|
|
|
|
) {
|
2013-01-24 10:39:18 -08:00
|
|
|
PreloadSlowThings();
|
|
|
|
}
|
2013-11-29 01:28:54 -08:00
|
|
|
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
ContentChild::GetSingleton()->RecvGarbageCollect();
|
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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,
|
2013-12-03 01:32:56 -08:00
|
|
|
const bool& aIsSharing,
|
2014-05-13 15:48:04 -07:00
|
|
|
const bool& aIsFormatting,
|
2014-09-21 20:42:33 -07:00
|
|
|
const bool& aIsFake,
|
|
|
|
const bool& aIsUnmounting)
|
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,
|
2014-09-21 20:42:33 -07:00
|
|
|
aIsSharing, aIsFormatting, aIsFake,
|
|
|
|
aIsUnmounting);
|
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;
|
2013-12-03 01:32:56 -08:00
|
|
|
unused << aIsFormatting;
|
2014-05-13 15:48:04 -07:00
|
|
|
unused << aIsFake;
|
2014-09-21 20:42:33 -07:00
|
|
|
unused << aIsUnmounting;
|
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()
|
|
|
|
{
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
// Don't minimize memory in the nuwa process: it will perform GC, but the
|
|
|
|
// GC thread could be frozen.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2013-04-25 17:53:26 -07:00
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
|
|
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
NS_ENSURE_TRUE(mgr, true);
|
|
|
|
|
2014-02-25 07:37:30 -08:00
|
|
|
mgr->MinimizeMemoryUsage(/* callback = */ nullptr);
|
2013-04-25 17:53:26 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-13 01:51:45 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyPhoneStateChange(const nsString& aState)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
os->NotifyObservers(nullptr, "phone-state-changed", aState.get());
|
|
|
|
}
|
|
|
|
return true;
|
2013-09-13 01:51:45 -07:00
|
|
|
}
|
|
|
|
|
2013-12-13 08:28:46 -08:00
|
|
|
void
|
|
|
|
ContentChild::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
MOZ_ASSERT(aObserver, "null idle observer");
|
|
|
|
// Make sure aObserver isn't released while we wait for the parent
|
|
|
|
aObserver->AddRef();
|
|
|
|
SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
|
|
|
mIdleObservers.PutEntry(aObserver);
|
2013-12-13 08:28:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
MOZ_ASSERT(aObserver, "null idle observer");
|
|
|
|
SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
|
|
|
aObserver->Release();
|
|
|
|
mIdleObservers.RemoveEntry(aObserver);
|
2013-12-13 08:28:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyIdleObserver(const uint64_t& aObserver,
|
|
|
|
const nsCString& aTopic,
|
|
|
|
const nsString& aTimeStr)
|
|
|
|
{
|
2014-05-27 20:04:23 -07:00
|
|
|
nsIObserver* observer = reinterpret_cast<nsIObserver*>(aObserver);
|
|
|
|
if (mIdleObservers.Contains(observer)) {
|
|
|
|
observer->Observe(nullptr, aTopic.get(), aTimeStr.get());
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Received notification for an idle observer that was removed.");
|
|
|
|
}
|
|
|
|
return true;
|
2013-12-13 08:28:46 -08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
class CallNuwaSpawn : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
NuwaSpawn();
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In the new process.
|
|
|
|
ContentChild* child = ContentChild::GetSingleton();
|
2014-03-25 21:56:35 -07:00
|
|
|
child->SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false);
|
2013-06-03 03:14:40 -07:00
|
|
|
mozilla::ipc::Transport* transport = child->GetTransport();
|
|
|
|
int fd = transport->GetFileDescriptor();
|
|
|
|
transport->ResetFileDescriptor(fd);
|
|
|
|
|
|
|
|
IToplevelProtocol* toplevel = child->GetFirstOpenedActors();
|
|
|
|
while (toplevel != nullptr) {
|
|
|
|
transport = toplevel->GetTransport();
|
|
|
|
fd = transport->GetFileDescriptor();
|
|
|
|
transport->ResetFileDescriptor(fd);
|
|
|
|
|
|
|
|
toplevel = toplevel->getNext();
|
|
|
|
}
|
2014-02-14 00:43:51 -08:00
|
|
|
|
|
|
|
// Perform other after-fork initializations.
|
2014-09-15 04:10:21 -07:00
|
|
|
InitOnContentProcessCreated();
|
2014-02-14 00:43:51 -08:00
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
DoNuwaFork()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NuwaSpawnPrepare != nullptr,
|
|
|
|
"NuwaSpawnPrepare() is not available!");
|
|
|
|
NuwaSpawnPrepare(); // NuwaSpawn will be blocked.
|
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIRunnable> callSpawn(new CallNuwaSpawn());
|
|
|
|
NS_DispatchToMainThread(callSpawn);
|
|
|
|
}
|
|
|
|
|
|
|
|
// IOThread should be blocked here for waiting NuwaSpawn().
|
|
|
|
NS_ASSERTION(NuwaSpawnWait != nullptr,
|
|
|
|
"NuwaSpawnWait() is not available!");
|
|
|
|
NuwaSpawnWait(); // Now! NuwaSpawn can go.
|
|
|
|
// Here, we can make sure the spawning was finished.
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function should keep IO thread in a stable state and freeze it
|
|
|
|
* until the spawning is finished.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
RunNuwaFork()
|
|
|
|
{
|
|
|
|
if (NuwaCheckpointCurrentThread()) {
|
|
|
|
DoNuwaFork();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvNuwaFork()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (sNuwaForking) { // No reentry.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
sNuwaForking = true;
|
|
|
|
|
2013-11-26 23:59:41 -08:00
|
|
|
// We want to ensure that the PBackground actor gets cloned in the Nuwa
|
|
|
|
// process before we freeze. Also, we have to do this to avoid deadlock.
|
|
|
|
// Protocols that are "opened" (e.g. PBackground, PCompositor) block the
|
|
|
|
// main thread to wait for the IPC thread during the open operation.
|
|
|
|
// NuwaSpawnWait() blocks the IPC thread to wait for the main thread when
|
|
|
|
// the Nuwa process is forked. Unless we ensure that the two cannot happen
|
|
|
|
// at the same time then we risk deadlock. Spinning the event loop here
|
|
|
|
// guarantees the ordering is safe for PBackground.
|
|
|
|
while (!BackgroundChild::GetForCurrentThread()) {
|
2014-02-24 20:16:01 -08:00
|
|
|
if (NS_WARN_IF(!NS_ProcessNextEvent())) {
|
2013-11-26 23:59:41 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
MessageLoop* ioloop = XRE_GetIOMessageLoop();
|
|
|
|
ioloop->PostTask(FROM_HERE, NewRunnableFunction(RunNuwaFork));
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false; // Makes the underlying IPC channel abort.
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-08-28 17:20:27 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvOnAppThemeChanged()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
os->NotifyObservers(nullptr, "app-theme-changed", nullptr);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
} // namespace dom
|
2013-02-14 12:41:30 -08:00
|
|
|
} // namespace mozilla
|
2013-06-03 03:14:40 -07:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
#if defined(MOZ_NUWA_PROCESS)
|
|
|
|
NS_EXPORT void
|
|
|
|
GetProtoFdInfos(NuwaProtoFdInfo* aInfoList,
|
|
|
|
size_t aInfoListSize,
|
|
|
|
size_t* aInfoSize)
|
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
mozilla::dom::ContentChild* content =
|
|
|
|
mozilla::dom::ContentChild::GetSingleton();
|
|
|
|
aInfoList[i].protoId = content->GetProtocolId();
|
|
|
|
aInfoList[i].originFd =
|
|
|
|
content->GetTransport()->GetFileDescriptor();
|
|
|
|
i++;
|
|
|
|
|
|
|
|
for (IToplevelProtocol* actor = content->GetFirstOpenedActors();
|
|
|
|
actor != nullptr;
|
|
|
|
actor = actor->getNext()) {
|
|
|
|
if (i >= aInfoListSize) {
|
|
|
|
NS_RUNTIMEABORT("Too many top level protocols!");
|
|
|
|
}
|
|
|
|
|
|
|
|
aInfoList[i].protoId = actor->GetProtocolId();
|
|
|
|
aInfoList[i].originFd =
|
|
|
|
actor->GetTransport()->GetFileDescriptor();
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i > NUWA_TOPLEVEL_MAX) {
|
|
|
|
NS_RUNTIMEABORT("Too many top level protocols!");
|
|
|
|
}
|
|
|
|
*aInfoSize = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RunAddNewIPCProcess : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RunAddNewIPCProcess(pid_t aPid,
|
|
|
|
nsTArray<mozilla::ipc::ProtocolFdMapping>& aMaps)
|
|
|
|
: mPid(aPid)
|
|
|
|
{
|
|
|
|
mMaps.SwapElements(aMaps);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
mozilla::dom::ContentChild::GetSingleton()->
|
|
|
|
SendAddNewProcess(mPid, mMaps);
|
|
|
|
|
|
|
|
MOZ_ASSERT(sNuwaForking);
|
|
|
|
sNuwaForking = false;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
pid_t mPid;
|
|
|
|
nsTArray<mozilla::ipc::ProtocolFdMapping> mMaps;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AddNewIPCProcess() is called by Nuwa process to tell the parent
|
|
|
|
* process that a new process is created.
|
|
|
|
*
|
|
|
|
* In the newly created process, ResetContentChildTransport() is called to
|
|
|
|
* reset fd for the IPC Channel and the session.
|
|
|
|
*/
|
|
|
|
NS_EXPORT void
|
|
|
|
AddNewIPCProcess(pid_t aPid, NuwaProtoFdInfo* aInfoList, size_t aInfoListSize)
|
|
|
|
{
|
|
|
|
nsTArray<mozilla::ipc::ProtocolFdMapping> maps;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < aInfoListSize; i++) {
|
|
|
|
int _fd = aInfoList[i].newFds[NUWA_NEWFD_PARENT];
|
|
|
|
mozilla::ipc::FileDescriptor fd(_fd);
|
|
|
|
mozilla::ipc::ProtocolFdMapping map(aInfoList[i].protoId, fd);
|
|
|
|
maps.AppendElement(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<RunAddNewIPCProcess> runner = new RunAddNewIPCProcess(aPid, maps);
|
|
|
|
NS_DispatchToMainThread(runner);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_EXPORT void
|
|
|
|
OnNuwaProcessReady()
|
|
|
|
{
|
|
|
|
mozilla::dom::ContentChild* content =
|
|
|
|
mozilla::dom::ContentChild::GetSingleton();
|
|
|
|
content->SendNuwaReady();
|
|
|
|
}
|
2014-03-12 15:48:15 -07:00
|
|
|
|
|
|
|
NS_EXPORT void
|
|
|
|
AfterNuwaFork()
|
|
|
|
{
|
|
|
|
SetCurrentProcessPrivileges(base::PRIVILEGES_DEFAULT);
|
|
|
|
}
|
|
|
|
|
2013-06-03 03:14:40 -07:00
|
|
|
#endif // MOZ_NUWA_PROCESS
|
|
|
|
|
|
|
|
}
|