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
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
#ifndef mozilla_dom_ContentParent_h
|
|
|
|
#define mozilla_dom_ContentParent_h
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "base/waitable_event_watcher.h"
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
#include "mozilla/dom/PContentParent.h"
|
2011-02-16 10:43:23 -08:00
|
|
|
#include "mozilla/dom/PMemoryReportRequestParent.h"
|
2009-08-12 09:18:08 -07:00
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "mozilla/dom/ipc/Blob.h"
|
2012-08-03 12:35:58 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "nsIObserver.h"
|
2010-02-01 17:53:52 -08:00
|
|
|
#include "nsIThreadInternal.h"
|
2010-07-02 08:50:24 -07:00
|
|
|
#include "nsNetUtil.h"
|
2010-07-15 07:04:25 -07:00
|
|
|
#include "nsIPermissionManager.h"
|
2010-09-20 21:16:37 -07:00
|
|
|
#include "nsIDOMGeoPositionCallback.h"
|
2011-02-16 10:43:23 -08:00
|
|
|
#include "nsIMemoryReporter.h"
|
|
|
|
#include "nsCOMArray.h"
|
2012-07-13 14:10:20 -07:00
|
|
|
#include "nsDataHashtable.h"
|
2012-08-01 23:32:04 -07:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2012-08-01 23:02:29 -07:00
|
|
|
#include "nsHashKeys.h"
|
2009-09-02 17:18:27 -07:00
|
|
|
|
2011-08-02 12:57:48 -07:00
|
|
|
class nsFrameMessageManager;
|
2012-08-01 23:02:29 -07:00
|
|
|
class nsIDOMBlob;
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace mozilla {
|
2009-09-09 15:00:14 -07:00
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
namespace ipc {
|
|
|
|
class TestShellParent;
|
|
|
|
}
|
|
|
|
|
2012-07-17 16:59:45 -07:00
|
|
|
namespace layers {
|
|
|
|
class PCompositorParent;
|
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class TabParent;
|
2010-11-18 17:15:23 -08:00
|
|
|
class PStorageParent;
|
2012-08-01 23:02:29 -07:00
|
|
|
class ClonedMessageData;
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
class ContentParent : public PContentParent
|
|
|
|
, public nsIObserver
|
|
|
|
, public nsIThreadObserver
|
2010-09-20 21:16:37 -07:00
|
|
|
, public nsIDOMGeoPositionCallback
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
|
2009-11-11 00:34:08 -08:00
|
|
|
typedef mozilla::ipc::TestShellParent TestShellParent;
|
2012-07-17 16:59:45 -07:00
|
|
|
typedef mozilla::layers::PCompositorParent PCompositorParent;
|
2012-08-01 23:02:29 -07:00
|
|
|
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
2009-08-12 09:18:08 -07:00
|
|
|
|
|
|
|
public:
|
2011-08-02 12:35:42 -07:00
|
|
|
static ContentParent* GetNewOrUsed();
|
2012-07-13 14:10:20 -07:00
|
|
|
|
|
|
|
/**
|
2012-08-08 20:13:12 -07:00
|
|
|
* Get or create a content process for the given app. A given app
|
|
|
|
* (identified by its manifest URL) gets one process all to itself.
|
2012-07-13 14:10:20 -07:00
|
|
|
*
|
2012-08-08 20:13:12 -07:00
|
|
|
* If the given manifest is the empty string, then this method is equivalent
|
|
|
|
* to GetNewOrUsed().
|
2012-07-13 14:10:20 -07:00
|
|
|
*/
|
2012-08-08 20:13:12 -07:00
|
|
|
static ContentParent* GetForApp(const nsAString& aManifestURL);
|
2011-08-02 12:35:42 -07:00
|
|
|
static void GetAll(nsTArray<ContentParent*>& aArray);
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
2010-02-01 17:53:52 -08:00
|
|
|
NS_DECL_NSITHREADOBSERVER
|
2010-09-20 21:16:37 -07:00
|
|
|
NS_DECL_NSIDOMGEOPOSITIONCALLBACK
|
2009-09-02 17:18:27 -07:00
|
|
|
|
2012-08-08 20:13:12 -07:00
|
|
|
/**
|
|
|
|
* Create a new tab.
|
|
|
|
*
|
|
|
|
* |aIsBrowserElement| indicates whether this tab is part of an
|
|
|
|
* <iframe mozbrowser>.
|
|
|
|
* |aAppId| indicates which app the tab belongs to.
|
|
|
|
*/
|
|
|
|
TabParent* CreateTab(PRUint32 aChromeFlags, bool aIsBrowserElement, PRUint32 aAppId);
|
2012-07-17 11:27:27 -07:00
|
|
|
/** Notify that a tab was destroyed during normal operation. */
|
|
|
|
void NotifyTabDestroyed(PBrowserParent* aTab);
|
2009-11-11 00:34:08 -08:00
|
|
|
|
|
|
|
TestShellParent* CreateTestShell();
|
|
|
|
bool DestroyTestShell(TestShellParent* aTestShell);
|
2011-06-23 16:31:58 -07:00
|
|
|
TestShellParent* GetTestShellSingleton();
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2010-03-29 13:29:45 -07:00
|
|
|
void ReportChildAlreadyBlocked();
|
2010-02-01 17:53:52 -08:00
|
|
|
bool RequestRunToCompletion();
|
|
|
|
|
2010-04-11 17:24:45 -07:00
|
|
|
bool IsAlive();
|
2012-07-17 11:27:27 -07:00
|
|
|
bool IsForApp();
|
2010-04-11 17:24:45 -07:00
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
void SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& report);
|
|
|
|
|
2011-06-08 12:56:31 -07:00
|
|
|
GeckoChildProcessHost* Process() {
|
|
|
|
return mSubprocess;
|
|
|
|
}
|
|
|
|
|
2011-08-02 12:35:42 -07:00
|
|
|
bool NeedsPermissionsUpdate() {
|
|
|
|
return mSendPermissionUpdates;
|
|
|
|
}
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
BlobParent* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
|
|
|
|
|
2010-02-01 17:53:52 -08:00
|
|
|
protected:
|
2010-11-24 05:58:21 -08:00
|
|
|
void OnChannelConnected(int32 pid);
|
2010-02-01 17:53:52 -08:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
private:
|
2012-07-13 14:10:20 -07:00
|
|
|
static nsDataHashtable<nsStringHashKey, ContentParent*> *gAppContentParents;
|
|
|
|
static nsTArray<ContentParent*>* gNonAppContentParents;
|
2012-04-19 17:13:20 -07:00
|
|
|
static nsTArray<ContentParent*>* gPrivateContent;
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
// Hide the raw constructor methods since we don't want client code
|
|
|
|
// using them.
|
2010-07-19 11:33:33 -07:00
|
|
|
using PContentParent::SendPBrowserConstructor;
|
|
|
|
using PContentParent::SendPTestShellConstructor;
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2012-07-13 14:10:20 -07:00
|
|
|
ContentParent(const nsAString& aAppManifestURL);
|
2010-07-19 11:33:33 -07:00
|
|
|
virtual ~ContentParent();
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2010-12-26 12:03:52 -08:00
|
|
|
void Init();
|
|
|
|
|
2012-07-17 11:27:27 -07: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.
|
|
|
|
*/
|
|
|
|
void ShutDown();
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
PCompositorParent* AllocPCompositor(mozilla::ipc::Transport* aTransport,
|
2012-07-17 16:59:45 -07:00
|
|
|
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
|
|
|
|
2012-08-08 20:13:12 -07:00
|
|
|
virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserElement, const PRUint32& aAppId);
|
2010-07-19 11:33:33 -07:00
|
|
|
virtual bool DeallocPBrowser(PBrowserParent* frame);
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2012-06-19 16:14:39 -07:00
|
|
|
virtual PDeviceStorageRequestParent* AllocPDeviceStorageRequest(const DeviceStorageParams&);
|
|
|
|
virtual bool DeallocPDeviceStorageRequest(PDeviceStorageRequestParent*);
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
virtual PBlobParent* AllocPBlob(const BlobConstructorParams& aParams);
|
|
|
|
virtual bool DeallocPBlob(PBlobParent*);
|
|
|
|
|
2011-06-08 12:56:31 -07:00
|
|
|
virtual PCrashReporterParent* AllocPCrashReporter(const NativeThreadId& tid,
|
|
|
|
const PRUint32& processType);
|
2010-11-24 06:15:03 -08:00
|
|
|
virtual bool DeallocPCrashReporter(PCrashReporterParent* crashreporter);
|
2011-06-08 12:56:31 -07:00
|
|
|
virtual bool RecvPCrashReporterConstructor(PCrashReporterParent* actor,
|
|
|
|
const NativeThreadId& tid,
|
|
|
|
const PRUint32& processType);
|
2010-11-24 06:15:03 -08:00
|
|
|
|
2012-07-06 11:15:45 -07:00
|
|
|
virtual PHalParent* AllocPHal() MOZ_OVERRIDE;
|
|
|
|
virtual bool DeallocPHal(PHalParent*) MOZ_OVERRIDE;
|
2011-10-05 15:15:45 -07:00
|
|
|
|
2012-07-14 04:24:20 -07:00
|
|
|
virtual PIndexedDBParent* AllocPIndexedDB();
|
|
|
|
|
|
|
|
virtual bool DeallocPIndexedDB(PIndexedDBParent* aActor);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPIndexedDBConstructor(PIndexedDBParent* aActor);
|
|
|
|
|
2011-02-16 10:43:23 -08:00
|
|
|
virtual PMemoryReportRequestParent* AllocPMemoryReportRequest();
|
|
|
|
virtual bool DeallocPMemoryReportRequest(PMemoryReportRequestParent* actor);
|
|
|
|
|
2009-09-22 10:31:11 -07:00
|
|
|
virtual PTestShellParent* AllocPTestShell();
|
|
|
|
virtual bool DeallocPTestShell(PTestShellParent* shell);
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2010-11-16 20:14:19 -08:00
|
|
|
virtual PAudioParent* AllocPAudio(const PRInt32&,
|
|
|
|
const PRInt32&,
|
|
|
|
const PRInt32&);
|
|
|
|
virtual bool DeallocPAudio(PAudioParent*);
|
|
|
|
|
2009-09-22 10:31:11 -07:00
|
|
|
virtual PNeckoParent* AllocPNecko();
|
|
|
|
virtual bool DeallocPNecko(PNeckoParent* necko);
|
2009-08-18 12:05:15 -07:00
|
|
|
|
2010-09-15 15:55:08 -07:00
|
|
|
virtual PExternalHelperAppParent* AllocPExternalHelperApp(
|
|
|
|
const IPC::URI& uri,
|
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
|
|
|
const bool& aForceSave,
|
2010-11-21 11:21:59 -08:00
|
|
|
const PRInt64& aContentLength,
|
|
|
|
const IPC::URI& aReferrer);
|
2010-09-15 15:55:08 -07:00
|
|
|
virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);
|
|
|
|
|
2011-11-20 14:40:53 -08:00
|
|
|
virtual PSmsParent* AllocPSms();
|
|
|
|
virtual bool DeallocPSms(PSmsParent*);
|
|
|
|
|
2010-11-18 17:15:23 -08:00
|
|
|
virtual PStorageParent* AllocPStorage(const StorageConstructData& aData);
|
|
|
|
virtual bool DeallocPStorage(PStorageParent* aActor);
|
|
|
|
|
2010-11-08 18:49:00 -08:00
|
|
|
virtual bool RecvReadPrefsArray(InfallibleTArray<PrefTuple> *retValue);
|
2011-01-12 20:04:42 -08:00
|
|
|
virtual bool RecvReadFontList(InfallibleTArray<FontListEntry>* retValue);
|
2010-05-28 11:09:15 -07:00
|
|
|
|
2010-11-08 18:49:00 -08:00
|
|
|
virtual bool RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions);
|
2011-04-29 16:46:20 -07:00
|
|
|
|
2011-02-28 21:36:43 -08:00
|
|
|
virtual bool RecvSetClipboardText(const nsString& text, const PRInt32& whichClipboard);
|
|
|
|
virtual bool RecvGetClipboardText(const PRInt32& whichClipboard, nsString* text);
|
|
|
|
virtual bool RecvEmptyClipboard();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool RecvClipboardHasText(bool* hasText);
|
2010-05-25 17:13:47 -07:00
|
|
|
|
2011-03-30 11:04:41 -07:00
|
|
|
virtual bool RecvGetSystemColors(const PRUint32& colorsCount, InfallibleTArray<PRUint32>* colors);
|
2011-06-13 14:02:13 -07:00
|
|
|
virtual bool RecvGetIconForExtension(const nsCString& aFileExt, const PRUint32& aIconSize, InfallibleTArray<PRUint8>* bits);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool RecvGetShowPasswordSetting(bool* showPassword);
|
2011-03-30 11:04:41 -07:00
|
|
|
|
2010-07-02 08:50:41 -07:00
|
|
|
virtual bool RecvStartVisitedQuery(const IPC::URI& uri);
|
|
|
|
|
2010-07-02 08:50:24 -07:00
|
|
|
virtual bool RecvVisitURI(const IPC::URI& uri,
|
|
|
|
const IPC::URI& referrer,
|
|
|
|
const PRUint32& flags);
|
|
|
|
|
2010-07-02 08:53:42 -07:00
|
|
|
virtual bool RecvSetURITitle(const IPC::URI& uri,
|
|
|
|
const nsString& title);
|
2010-10-20 08:19:24 -07:00
|
|
|
|
|
|
|
virtual bool RecvShowFilePicker(const PRInt16& mode,
|
|
|
|
const PRInt16& selectedType,
|
2011-09-28 23:19:26 -07:00
|
|
|
const bool& addToRecentDocs,
|
2010-10-20 08:19:24 -07:00
|
|
|
const nsString& title,
|
|
|
|
const nsString& defaultFile,
|
|
|
|
const nsString& defaultExtension,
|
2010-11-08 18:49:00 -08:00
|
|
|
const InfallibleTArray<nsString>& filters,
|
|
|
|
const InfallibleTArray<nsString>& filterNames,
|
|
|
|
InfallibleTArray<nsString>* files,
|
2010-10-20 08:19:24 -07:00
|
|
|
PRInt16* retValue,
|
|
|
|
nsresult* result);
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
virtual bool RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
2011-09-28 23:19:26 -07:00
|
|
|
const nsString& aText, const bool& aTextClickable,
|
2010-09-15 09:44:57 -07:00
|
|
|
const nsString& aCookie, const nsString& aName);
|
2010-07-02 08:53:42 -07:00
|
|
|
|
2010-08-10 10:14:45 -07:00
|
|
|
virtual bool RecvLoadURIExternal(const IPC::URI& uri);
|
|
|
|
|
2012-08-01 23:02:29 -07:00
|
|
|
virtual bool RecvSyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
2010-11-08 18:49:00 -08:00
|
|
|
InfallibleTArray<nsString>* aRetvals);
|
2012-08-01 23:02:29 -07:00
|
|
|
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData);
|
2010-08-31 11:58:35 -07:00
|
|
|
|
2010-11-05 10:43:13 -07:00
|
|
|
virtual bool RecvAddGeolocationListener();
|
|
|
|
virtual bool RecvRemoveGeolocationListener();
|
2010-09-20 21:16:37 -07:00
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
virtual bool RecvConsoleMessage(const nsString& aMessage);
|
|
|
|
virtual bool RecvScriptError(const nsString& aMessage,
|
|
|
|
const nsString& aSourceName,
|
|
|
|
const nsString& aSourceLine,
|
|
|
|
const PRUint32& aLineNumber,
|
|
|
|
const PRUint32& aColNumber,
|
|
|
|
const PRUint32& aFlags,
|
|
|
|
const nsCString& aCategory);
|
|
|
|
|
2012-04-19 17:13:20 -07:00
|
|
|
virtual bool RecvPrivateDocShellsExist(const bool& aExist);
|
2012-08-01 23:32:04 -07:00
|
|
|
|
|
|
|
virtual bool RecvAddFileWatch(const nsString& root);
|
|
|
|
virtual bool RecvRemoveFileWatch(const nsString& root);
|
|
|
|
|
2011-07-12 23:52:31 -07:00
|
|
|
virtual void ProcessingError(Result what) MOZ_OVERRIDE;
|
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
GeckoChildProcessHost* mSubprocess;
|
2010-02-01 17:53:52 -08:00
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
PRInt32 mGeolocationWatchID;
|
2010-02-01 17:53:52 -08:00
|
|
|
int mRunToCompletionDepth;
|
2010-03-29 13:29:45 -07:00
|
|
|
bool mShouldCallUnblockChild;
|
2010-02-01 17:53:52 -08:00
|
|
|
|
2011-02-16 10:43:23 -08: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-11 17:24:45 -07:00
|
|
|
bool mIsAlive;
|
2011-08-02 12:35:42 -07:00
|
|
|
bool mSendPermissionUpdates;
|
2011-08-02 12:57:48 -07:00
|
|
|
|
2012-07-13 14:10:20 -07:00
|
|
|
const nsString mAppManifestURL;
|
2011-08-02 12:57:48 -07:00
|
|
|
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
2011-06-08 12:56:31 -07:00
|
|
|
|
2012-08-03 12:35:58 -07:00
|
|
|
class WatchedFile MOZ_FINAL : public nsIFileUpdateListener {
|
2012-08-01 23:32:04 -07:00
|
|
|
public:
|
|
|
|
WatchedFile(ContentParent* aParent, const nsString& aPath)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mUsageCount(1)
|
|
|
|
{
|
|
|
|
NS_NewLocalFile(aPath, false, getter_AddRefs(mFile));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIFILEUPDATELISTENER
|
|
|
|
|
|
|
|
void Watch() {
|
|
|
|
mFile->Watch(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unwatch() {
|
|
|
|
mFile->Watch(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<ContentParent> mParent;
|
|
|
|
PRInt32 mUsageCount;
|
|
|
|
nsCOMPtr<nsIFile> mFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is a cache of all of the registered file watchers.
|
|
|
|
nsInterfaceHashtable<nsStringHashKey, WatchedFile> mFileWatchers;
|
|
|
|
|
2011-06-08 12:56:31 -07:00
|
|
|
friend class CrashReporterParent;
|
2009-08-12 09:18:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|