2009-08-18 19:05:15 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
#ifndef mozilla_dom_ContentParent_h
|
|
|
|
#define mozilla_dom_ContentParent_h
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
#include "base/waitable_event_watcher.h"
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
#include "mozilla/dom/PContentParent.h"
|
2011-02-16 18:43:23 +00:00
|
|
|
#include "mozilla/dom/PMemoryReportRequestParent.h"
|
2009-08-12 16:18:08 +00:00
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "mozilla/dom/ipc/Blob.h"
|
2012-08-03 19:35:58 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
#include "nsIObserver.h"
|
2010-02-02 01:53:52 +00:00
|
|
|
#include "nsIThreadInternal.h"
|
2010-07-02 15:50:24 +00:00
|
|
|
#include "nsNetUtil.h"
|
2010-07-15 14:04:25 +00:00
|
|
|
#include "nsIPermissionManager.h"
|
2010-09-21 04:16:37 +00:00
|
|
|
#include "nsIDOMGeoPositionCallback.h"
|
2011-02-16 18:43:23 +00:00
|
|
|
#include "nsIMemoryReporter.h"
|
|
|
|
#include "nsCOMArray.h"
|
2012-07-13 21:10:20 +00:00
|
|
|
#include "nsDataHashtable.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "nsHashKeys.h"
|
2009-09-03 00:18:27 +00:00
|
|
|
|
2012-08-09 02:58:06 +00:00
|
|
|
class mozIApplication;
|
2011-08-02 19:57:48 +00:00
|
|
|
class nsFrameMessageManager;
|
2012-08-02 06:02:29 +00:00
|
|
|
class nsIDOMBlob;
|
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
namespace mozilla {
|
2009-09-09 22:00:14 +00:00
|
|
|
|
2009-08-12 18:31:48 +00:00
|
|
|
namespace ipc {
|
2012-08-23 19:33:46 +00:00
|
|
|
class OptionalURIParams;
|
|
|
|
class URIParams;
|
2009-08-12 18:31:48 +00:00
|
|
|
class TestShellParent;
|
2012-08-23 19:33:46 +00:00
|
|
|
} // namespace ipc
|
2009-08-12 18:31:48 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
namespace layers {
|
|
|
|
class PCompositorParent;
|
2012-08-23 19:33:46 +00:00
|
|
|
} // namespace layers
|
2012-07-17 23:59:45 +00:00
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class TabParent;
|
2010-11-19 01:15:23 +00:00
|
|
|
class PStorageParent;
|
2012-08-02 06:02:29 +00:00
|
|
|
class ClonedMessageData;
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
class ContentParent : public PContentParent
|
|
|
|
, public nsIObserver
|
|
|
|
, public nsIThreadObserver
|
2010-09-21 04:16:37 +00:00
|
|
|
, public nsIDOMGeoPositionCallback
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
|
|
|
typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
|
2012-08-23 19:33:46 +00:00
|
|
|
typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
|
2009-11-11 08:34:08 +00:00
|
|
|
typedef mozilla::ipc::TestShellParent TestShellParent;
|
2012-08-23 19:33:46 +00:00
|
|
|
typedef mozilla::ipc::URIParams URIParams;
|
2012-07-17 23:59:45 +00:00
|
|
|
typedef mozilla::layers::PCompositorParent PCompositorParent;
|
2012-08-02 06:02:29 +00:00
|
|
|
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
2009-08-12 16:18:08 +00:00
|
|
|
|
|
|
|
public:
|
2012-08-16 01:46:03 +00:00
|
|
|
/**
|
|
|
|
* Start up the content-process machinery. This might include
|
|
|
|
* scheduling pre-launch tasks.
|
|
|
|
*/
|
|
|
|
static void StartUp();
|
|
|
|
/** Shut down the content-process machinery. */
|
|
|
|
static void ShutDown();
|
|
|
|
|
2012-08-23 10:23:43 +00:00
|
|
|
static ContentParent* GetNewOrUsed(bool aForBrowserElement = false);
|
2012-07-13 21:10:20 +00:00
|
|
|
|
|
|
|
/**
|
2012-08-09 02:58:06 +00:00
|
|
|
* Get or create a content process for the given app descriptor,
|
|
|
|
* which may be null. This function will assign processes to app
|
|
|
|
* or non-app browsers by internal heuristics.
|
2012-07-13 21:10:20 +00:00
|
|
|
*
|
2012-08-09 02:58:06 +00:00
|
|
|
* Currently apps are given their own process, and browser tabs
|
|
|
|
* share processes.
|
2012-07-13 21:10:20 +00:00
|
|
|
*/
|
2012-08-09 02:58:06 +00:00
|
|
|
static TabParent* CreateBrowser(mozIApplication* aApp,
|
|
|
|
bool aIsBrowserFrame);
|
|
|
|
|
2011-08-02 19:35:42 +00:00
|
|
|
static void GetAll(nsTArray<ContentParent*>& aArray);
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
2010-02-02 01:53:52 +00:00
|
|
|
NS_DECL_NSITHREADOBSERVER
|
2010-09-21 04:16:37 +00:00
|
|
|
NS_DECL_NSIDOMGEOPOSITIONCALLBACK
|
2009-09-03 00:18:27 +00:00
|
|
|
|
2012-07-17 18:27:27 +00:00
|
|
|
/** Notify that a tab was destroyed during normal operation. */
|
|
|
|
void NotifyTabDestroyed(PBrowserParent* aTab);
|
2009-11-11 08:34:08 +00:00
|
|
|
|
|
|
|
TestShellParent* CreateTestShell();
|
|
|
|
bool DestroyTestShell(TestShellParent* aTestShell);
|
2011-06-23 23:31:58 +00:00
|
|
|
TestShellParent* GetTestShellSingleton();
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2010-03-29 20:29:45 +00:00
|
|
|
void ReportChildAlreadyBlocked();
|
2010-02-02 01:53:52 +00:00
|
|
|
bool RequestRunToCompletion();
|
|
|
|
|
2010-04-12 00:24:45 +00:00
|
|
|
bool IsAlive();
|
2012-07-17 18:27:27 +00:00
|
|
|
bool IsForApp();
|
2010-04-12 00:24:45 +00:00
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
void SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& report);
|
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
GeckoChildProcessHost* Process() {
|
|
|
|
return mSubprocess;
|
|
|
|
}
|
|
|
|
|
2011-08-02 19:35:42 +00:00
|
|
|
bool NeedsPermissionsUpdate() {
|
|
|
|
return mSendPermissionUpdates;
|
|
|
|
}
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
BlobParent* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
|
|
|
|
|
2010-02-02 01:53:52 +00:00
|
|
|
protected:
|
2010-11-24 13:58:21 +00:00
|
|
|
void OnChannelConnected(int32 pid);
|
2010-02-02 01:53:52 +00:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
private:
|
2012-07-13 21:10:20 +00:00
|
|
|
static nsDataHashtable<nsStringHashKey, ContentParent*> *gAppContentParents;
|
|
|
|
static nsTArray<ContentParent*>* gNonAppContentParents;
|
2012-04-20 00:13:20 +00:00
|
|
|
static nsTArray<ContentParent*>* gPrivateContent;
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
static void PreallocateAppProcess();
|
|
|
|
static void DelayedPreallocateAppProcess();
|
|
|
|
static void ScheduleDelayedPreallocateAppProcess();
|
|
|
|
static already_AddRefed<ContentParent> MaybeTakePreallocatedAppProcess();
|
|
|
|
|
2009-08-12 18:31:48 +00:00
|
|
|
// Hide the raw constructor methods since we don't want client code
|
|
|
|
// using them.
|
2010-07-19 18:33:33 +00:00
|
|
|
using PContentParent::SendPBrowserConstructor;
|
|
|
|
using PContentParent::SendPTestShellConstructor;
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2012-08-23 10:23:43 +00:00
|
|
|
ContentParent(const nsAString& aAppManifestURL, bool aIsForBrowser);
|
2010-07-19 18:33:33 +00:00
|
|
|
virtual ~ContentParent();
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2010-12-26 20:03:52 +00:00
|
|
|
void Init();
|
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
// Transform a pre-allocated app process into a "real" app
|
|
|
|
// process, for the specified manifest URL.
|
|
|
|
void SetManifestFromPreallocated(const nsAString& aAppManifestURL);
|
|
|
|
|
2012-07-17 18:27:27 +00:00
|
|
|
/**
|
|
|
|
* Mark this ContentParent as dead for the purposes of Get*().
|
|
|
|
* This method is idempotent.
|
|
|
|
*/
|
|
|
|
void MarkAsDead();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Exit the subprocess and vamoose. After this call IsAlive()
|
|
|
|
* will return false and this ContentParent will not be returned
|
|
|
|
* by the Get*() funtions. However, the shutdown sequence itself
|
|
|
|
* may be asynchronous.
|
|
|
|
*/
|
2012-08-16 01:46:03 +00:00
|
|
|
void ShutDownProcess();
|
2012-07-17 18:27:27 +00:00
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
PCompositorParent* AllocPCompositor(mozilla::ipc::Transport* aTransport,
|
2012-07-17 23:59:45 +00:00
|
|
|
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual PBrowserParent* AllocPBrowser(const uint32_t& aChromeFlags,
|
2012-08-09 02:58:06 +00:00
|
|
|
const bool& aIsBrowserElement,
|
|
|
|
const AppId& aApp);
|
2010-07-19 18:33:33 +00:00
|
|
|
virtual bool DeallocPBrowser(PBrowserParent* frame);
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2012-06-19 23:14:39 +00:00
|
|
|
virtual PDeviceStorageRequestParent* AllocPDeviceStorageRequest(const DeviceStorageParams&);
|
|
|
|
virtual bool DeallocPDeviceStorageRequest(PDeviceStorageRequestParent*);
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
virtual PBlobParent* AllocPBlob(const BlobConstructorParams& aParams);
|
|
|
|
virtual bool DeallocPBlob(PBlobParent*);
|
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
virtual PCrashReporterParent* AllocPCrashReporter(const NativeThreadId& tid,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& processType);
|
2010-11-24 14:15:03 +00:00
|
|
|
virtual bool DeallocPCrashReporter(PCrashReporterParent* crashreporter);
|
2011-06-08 19:56:31 +00:00
|
|
|
virtual bool RecvPCrashReporterConstructor(PCrashReporterParent* actor,
|
|
|
|
const NativeThreadId& tid,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& processType);
|
2010-11-24 14:15:03 +00:00
|
|
|
|
2012-07-06 18:15:45 +00:00
|
|
|
virtual PHalParent* AllocPHal() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPHal(PHalParent*) MOZ_OVERRIDE;
|
2011-10-05 22:15:45 +00:00
|
|
|
|
2012-07-14 11:24:20 +00:00
|
|
|
virtual PIndexedDBParent* AllocPIndexedDB();
|
|
|
|
|
|
|
|
virtual bool DeallocPIndexedDB(PIndexedDBParent* aActor);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBConstructor(PIndexedDBParent* aActor);
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
virtual PMemoryReportRequestParent* AllocPMemoryReportRequest();
|
|
|
|
virtual bool DeallocPMemoryReportRequest(PMemoryReportRequestParent* actor);
|
|
|
|
|
2009-09-22 17:31:11 +00:00
|
|
|
virtual PTestShellParent* AllocPTestShell();
|
|
|
|
virtual bool DeallocPTestShell(PTestShellParent* shell);
|
2009-08-12 18:31:48 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual PAudioParent* AllocPAudio(const int32_t&,
|
|
|
|
const int32_t&,
|
|
|
|
const int32_t&);
|
2010-11-17 04:14:19 +00:00
|
|
|
virtual bool DeallocPAudio(PAudioParent*);
|
|
|
|
|
2009-09-22 17:31:11 +00:00
|
|
|
virtual PNeckoParent* AllocPNecko();
|
|
|
|
virtual bool DeallocPNecko(PNeckoParent* necko);
|
2009-08-18 19:05:15 +00:00
|
|
|
|
2010-09-15 22:55:08 +00:00
|
|
|
virtual PExternalHelperAppParent* AllocPExternalHelperApp(
|
2012-08-23 19:33:46 +00:00
|
|
|
const OptionalURIParams& aUri,
|
2010-09-15 22:55:08 +00:00
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
|
|
|
const bool& aForceSave,
|
2012-08-22 15:56:38 +00:00
|
|
|
const int64_t& aContentLength,
|
2012-08-23 19:33:46 +00:00
|
|
|
const OptionalURIParams& aReferrer);
|
2010-09-15 22:55:08 +00:00
|
|
|
virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);
|
|
|
|
|
2011-11-20 22:40:53 +00:00
|
|
|
virtual PSmsParent* AllocPSms();
|
|
|
|
virtual bool DeallocPSms(PSmsParent*);
|
|
|
|
|
2010-11-19 01:15:23 +00:00
|
|
|
virtual PStorageParent* AllocPStorage(const StorageConstructData& aData);
|
|
|
|
virtual bool DeallocPStorage(PStorageParent* aActor);
|
|
|
|
|
2012-08-22 20:00:21 +00:00
|
|
|
virtual bool RecvReadPrefsArray(InfallibleTArray<PrefSetting>* aPrefs);
|
2011-01-13 04:04:42 +00:00
|
|
|
virtual bool RecvReadFontList(InfallibleTArray<FontListEntry>* retValue);
|
2010-05-28 18:09:15 +00:00
|
|
|
|
2010-11-09 02:49:00 +00:00
|
|
|
virtual bool RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions);
|
2011-04-29 23:46:20 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool RecvSetClipboardText(const nsString& text, const bool& isPrivateData, const int32_t& whichClipboard);
|
|
|
|
virtual bool RecvGetClipboardText(const int32_t& whichClipboard, nsString* text);
|
2011-03-01 05:36:43 +00:00
|
|
|
virtual bool RecvEmptyClipboard();
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool RecvClipboardHasText(bool* hasText);
|
2010-05-26 00:13:47 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool RecvGetSystemColors(const uint32_t& colorsCount, InfallibleTArray<uint32_t>* colors);
|
|
|
|
virtual bool RecvGetIconForExtension(const nsCString& aFileExt, const uint32_t& aIconSize, InfallibleTArray<uint8_t>* bits);
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool RecvGetShowPasswordSetting(bool* showPassword);
|
2011-03-30 18:04:41 +00:00
|
|
|
|
2012-08-23 19:33:46 +00:00
|
|
|
virtual bool RecvStartVisitedQuery(const URIParams& uri);
|
2010-07-02 15:50:41 +00:00
|
|
|
|
2012-08-23 19:33:46 +00:00
|
|
|
virtual bool RecvVisitURI(const URIParams& uri,
|
|
|
|
const OptionalURIParams& referrer,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& flags);
|
2010-07-02 15:50:24 +00:00
|
|
|
|
2012-08-23 19:33:46 +00:00
|
|
|
virtual bool RecvSetURITitle(const URIParams& uri,
|
2010-07-02 15:53:42 +00:00
|
|
|
const nsString& title);
|
2010-10-20 15:19:24 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool RecvShowFilePicker(const int16_t& mode,
|
|
|
|
const int16_t& selectedType,
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool& addToRecentDocs,
|
2010-10-20 15:19:24 +00:00
|
|
|
const nsString& title,
|
|
|
|
const nsString& defaultFile,
|
|
|
|
const nsString& defaultExtension,
|
2010-11-09 02:49:00 +00:00
|
|
|
const InfallibleTArray<nsString>& filters,
|
|
|
|
const InfallibleTArray<nsString>& filterNames,
|
|
|
|
InfallibleTArray<nsString>* files,
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t* retValue,
|
2010-10-20 15:19:24 +00:00
|
|
|
nsresult* result);
|
|
|
|
|
2010-09-15 16:44:57 +00:00
|
|
|
virtual bool RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsString& aText, const bool& aTextClickable,
|
2010-09-15 16:44:57 +00:00
|
|
|
const nsString& aCookie, const nsString& aName);
|
2010-07-02 15:53:42 +00:00
|
|
|
|
2012-08-23 19:33:46 +00:00
|
|
|
virtual bool RecvLoadURIExternal(const URIParams& uri);
|
2010-08-10 17:14:45 +00:00
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
virtual bool RecvSyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
2010-11-09 02:49:00 +00:00
|
|
|
InfallibleTArray<nsString>* aRetvals);
|
2012-08-02 06:02:29 +00:00
|
|
|
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData);
|
2010-08-31 18:58:35 +00:00
|
|
|
|
2010-11-05 17:43:13 +00:00
|
|
|
virtual bool RecvAddGeolocationListener();
|
|
|
|
virtual bool RecvRemoveGeolocationListener();
|
2010-09-21 04:16:37 +00:00
|
|
|
|
2010-09-24 01:39:32 +00:00
|
|
|
virtual bool RecvConsoleMessage(const nsString& aMessage);
|
|
|
|
virtual bool RecvScriptError(const nsString& aMessage,
|
|
|
|
const nsString& aSourceName,
|
|
|
|
const nsString& aSourceLine,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& aLineNumber,
|
|
|
|
const uint32_t& aColNumber,
|
|
|
|
const uint32_t& aFlags,
|
2010-09-24 01:39:32 +00:00
|
|
|
const nsCString& aCategory);
|
|
|
|
|
2012-04-20 00:13:20 +00:00
|
|
|
virtual bool RecvPrivateDocShellsExist(const bool& aExist);
|
2012-08-02 06:32:04 +00:00
|
|
|
|
2011-07-13 06:52:31 +00:00
|
|
|
virtual void ProcessingError(Result what) MOZ_OVERRIDE;
|
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
GeckoChildProcessHost* mSubprocess;
|
2010-02-02 01:53:52 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mGeolocationWatchID;
|
2010-02-02 01:53:52 +00:00
|
|
|
int mRunToCompletionDepth;
|
2010-03-29 20:29:45 +00:00
|
|
|
bool mShouldCallUnblockChild;
|
2010-02-02 01:53:52 +00:00
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
// This is a cache of all of the memory reporters
|
|
|
|
// registered in the child process. To update this, one
|
|
|
|
// can broadcast the topic "child-memory-reporter-request" using
|
|
|
|
// the nsIObserverService.
|
|
|
|
nsCOMArray<nsIMemoryReporter> mMemoryReporters;
|
|
|
|
|
2010-04-12 00:24:45 +00:00
|
|
|
bool mIsAlive;
|
2011-08-02 19:35:42 +00:00
|
|
|
bool mSendPermissionUpdates;
|
2011-08-02 19:57:48 +00:00
|
|
|
|
2012-07-13 21:10:20 +00:00
|
|
|
const nsString mAppManifestURL;
|
2011-08-02 19:57:48 +00:00
|
|
|
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
2011-06-08 19:56:31 +00:00
|
|
|
|
|
|
|
friend class CrashReporterParent;
|
2009-08-12 16:18:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|