dom/ipc/ContentChild.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* vim: set sw=4 ts=8 et tw=80 : */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_ContentChild_h
     8 #define mozilla_dom_ContentChild_h
    10 #include "mozilla/Attributes.h"
    11 #include "mozilla/dom/PContentChild.h"
    12 #include "mozilla/dom/ipc/Blob.h"
    13 #include "nsHashKeys.h"
    14 #include "nsIObserver.h"
    15 #include "nsTHashtable.h"
    17 #include "nsWeakPtr.h"
    20 struct ChromePackage;
    21 class nsIDOMBlob;
    22 class nsIObserver;
    23 struct ResourceMapping;
    24 struct OverrideMapping;
    26 namespace mozilla {
    28 namespace ipc {
    29 class OptionalURIParams;
    30 class URIParams;
    31 }// namespace ipc
    33 namespace jsipc {
    34 class JavaScriptChild;
    35 }
    37 namespace layers {
    38 class PCompositorChild;
    39 } // namespace layers
    41 namespace dom {
    43 class AlertObserver;
    44 class PrefObserver;
    45 class ConsoleListener;
    46 class PStorageChild;
    47 class ClonedMessageData;
    48 class PFileDescriptorSetChild;
    50 class ContentChild : public PContentChild
    51 {
    52     typedef mozilla::dom::ClonedMessageData ClonedMessageData;
    53     typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
    54     typedef mozilla::ipc::URIParams URIParams;
    56 public:
    57     ContentChild();
    58     virtual ~ContentChild();
    59     nsrefcnt AddRef() { return 1; }
    60     nsrefcnt Release() { return 1; }
    62     struct AppInfo
    63     {
    64         nsCString version;
    65         nsCString buildID;
    66         nsCString name;
    67         nsCString UAName;
    68     };
    70     bool Init(MessageLoop* aIOLoop,
    71               base::ProcessHandle aParentHandle,
    72               IPC::Channel* aChannel);
    73     void InitProcessAttributes();
    74     void InitXPCOM();
    76     static ContentChild* GetSingleton() {
    77         return sSingleton;
    78     }
    80     const AppInfo& GetAppInfo() {
    81         return mAppInfo;
    82     }
    84     void SetProcessName(const nsAString& aName, bool aDontOverride = false);
    85     void GetProcessName(nsAString& aName);
    86     void GetProcessName(nsACString& aName);
    87     static void AppendProcessId(nsACString& aName);
    89     PCompositorChild*
    90     AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
    91                           base::ProcessId aOtherProcess) MOZ_OVERRIDE;
    92     PImageBridgeChild*
    93     AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
    94                            base::ProcessId aOtherProcess) MOZ_OVERRIDE;
    96     virtual bool RecvSetProcessSandbox() MOZ_OVERRIDE;
    98     PBackgroundChild*
    99     AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
   100                           MOZ_OVERRIDE;
   102     virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext &aContext,
   103                                               const uint32_t &chromeFlags);
   104     virtual bool DeallocPBrowserChild(PBrowserChild*);
   106     virtual PDeviceStorageRequestChild* AllocPDeviceStorageRequestChild(const DeviceStorageParams&);
   107     virtual bool DeallocPDeviceStorageRequestChild(PDeviceStorageRequestChild*);
   109     virtual PFileSystemRequestChild* AllocPFileSystemRequestChild(const FileSystemParams&);
   110     virtual bool DeallocPFileSystemRequestChild(PFileSystemRequestChild*);
   112     virtual PBlobChild* AllocPBlobChild(const BlobConstructorParams& aParams);
   113     virtual bool DeallocPBlobChild(PBlobChild*);
   115     virtual PCrashReporterChild*
   116     AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id,
   117                              const uint32_t& processType) MOZ_OVERRIDE;
   118     virtual bool
   119     DeallocPCrashReporterChild(PCrashReporterChild*) MOZ_OVERRIDE;
   121     virtual PHalChild* AllocPHalChild() MOZ_OVERRIDE;
   122     virtual bool DeallocPHalChild(PHalChild*) MOZ_OVERRIDE;
   124     virtual PIndexedDBChild* AllocPIndexedDBChild() MOZ_OVERRIDE;
   125     virtual bool DeallocPIndexedDBChild(PIndexedDBChild* aActor) MOZ_OVERRIDE;
   127     virtual PMemoryReportRequestChild*
   128     AllocPMemoryReportRequestChild(const uint32_t& generation,
   129                                    const bool &minimizeMemoryUsage,
   130                                    const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
   131     virtual bool
   132     DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) MOZ_OVERRIDE;
   134     virtual bool
   135     RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* child,
   136                                         const uint32_t& generation,
   137                                         const bool &minimizeMemoryUsage,
   138                                         const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
   140     virtual bool
   141     RecvAudioChannelNotify() MOZ_OVERRIDE;
   143     virtual bool
   144     RecvDumpGCAndCCLogsToFile(const nsString& aIdentifier,
   145                               const bool& aDumpAllTraces,
   146                               const bool& aDumpChildProcesses) MOZ_OVERRIDE;
   148     virtual PTestShellChild* AllocPTestShellChild() MOZ_OVERRIDE;
   149     virtual bool DeallocPTestShellChild(PTestShellChild*) MOZ_OVERRIDE;
   150     virtual bool RecvPTestShellConstructor(PTestShellChild*) MOZ_OVERRIDE;
   151     jsipc::JavaScriptChild *GetCPOWManager();
   153     virtual PNeckoChild* AllocPNeckoChild() MOZ_OVERRIDE;
   154     virtual bool DeallocPNeckoChild(PNeckoChild*) MOZ_OVERRIDE;
   156     virtual PExternalHelperAppChild *AllocPExternalHelperAppChild(
   157             const OptionalURIParams& uri,
   158             const nsCString& aMimeContentType,
   159             const nsCString& aContentDisposition,
   160             const uint32_t& aContentDispositionHint,
   161             const nsString& aContentDispositionFilename,
   162             const bool& aForceSave,
   163             const int64_t& aContentLength,
   164             const OptionalURIParams& aReferrer,
   165             PBrowserChild* aBrowser) MOZ_OVERRIDE;
   166     virtual bool DeallocPExternalHelperAppChild(PExternalHelperAppChild *aService) MOZ_OVERRIDE;
   168     virtual PSmsChild* AllocPSmsChild() MOZ_OVERRIDE;
   169     virtual bool DeallocPSmsChild(PSmsChild*) MOZ_OVERRIDE;
   171     virtual PTelephonyChild* AllocPTelephonyChild() MOZ_OVERRIDE;
   172     virtual bool DeallocPTelephonyChild(PTelephonyChild*) MOZ_OVERRIDE;
   174     virtual PStorageChild* AllocPStorageChild() MOZ_OVERRIDE;
   175     virtual bool DeallocPStorageChild(PStorageChild* aActor) MOZ_OVERRIDE;
   177     virtual PBluetoothChild* AllocPBluetoothChild() MOZ_OVERRIDE;
   178     virtual bool DeallocPBluetoothChild(PBluetoothChild* aActor) MOZ_OVERRIDE;
   180     virtual PFMRadioChild* AllocPFMRadioChild() MOZ_OVERRIDE;
   181     virtual bool DeallocPFMRadioChild(PFMRadioChild* aActor) MOZ_OVERRIDE;
   183     virtual PAsmJSCacheEntryChild* AllocPAsmJSCacheEntryChild(
   184                                  const asmjscache::OpenMode& aOpenMode,
   185                                  const asmjscache::WriteParams& aWriteParams,
   186                                  const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
   187     virtual bool DeallocPAsmJSCacheEntryChild(
   188                                     PAsmJSCacheEntryChild* aActor) MOZ_OVERRIDE;
   190     virtual PSpeechSynthesisChild* AllocPSpeechSynthesisChild() MOZ_OVERRIDE;
   191     virtual bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor) MOZ_OVERRIDE;
   193     virtual bool RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
   194                                     const InfallibleTArray<ResourceMapping>& resources,
   195                                     const InfallibleTArray<OverrideMapping>& overrides,
   196                                     const nsCString& locale) MOZ_OVERRIDE;
   198     virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() MOZ_OVERRIDE;
   199     virtual bool DeallocPJavaScriptChild(mozilla::jsipc::PJavaScriptChild*) MOZ_OVERRIDE;
   201     virtual bool RecvSetOffline(const bool& offline) MOZ_OVERRIDE;
   203     virtual bool RecvSpeakerManagerNotify() MOZ_OVERRIDE;
   205     virtual bool RecvNotifyVisited(const URIParams& aURI) MOZ_OVERRIDE;
   206     // auto remove when alertfinished is received.
   207     nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
   209     virtual bool RecvPreferenceUpdate(const PrefSetting& aPref) MOZ_OVERRIDE;
   211     virtual bool RecvNotifyAlertsObserver(const nsCString& aType,
   212                                           const nsString& aData) MOZ_OVERRIDE;
   214     virtual bool RecvAsyncMessage(const nsString& aMsg,
   215                                   const ClonedMessageData& aData,
   216                                   const InfallibleTArray<CpowEntry>& aCpows,
   217                                   const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
   219     virtual bool RecvGeolocationUpdate(const GeoPosition& somewhere) MOZ_OVERRIDE;
   221     virtual bool RecvAddPermission(const IPC::Permission& permission) MOZ_OVERRIDE;
   223     virtual bool RecvScreenSizeChanged(const gfxIntSize &size) MOZ_OVERRIDE;
   225     virtual bool RecvFlushMemory(const nsString& reason) MOZ_OVERRIDE;
   227     virtual bool RecvActivateA11y() MOZ_OVERRIDE;
   229     virtual bool RecvGarbageCollect() MOZ_OVERRIDE;
   230     virtual bool RecvCycleCollect() MOZ_OVERRIDE;
   232     virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID,
   233                              const nsCString& name, const nsCString& UAName) MOZ_OVERRIDE;
   235     virtual bool RecvLastPrivateDocShellDestroyed() MOZ_OVERRIDE;
   237     virtual bool RecvFilePathUpdate(const nsString& aStorageType,
   238                                     const nsString& aStorageName,
   239                                     const nsString& aPath,
   240                                     const nsCString& aReason) MOZ_OVERRIDE;
   241     virtual bool RecvFileSystemUpdate(const nsString& aFsName,
   242                                       const nsString& aVolumeName,
   243                                       const int32_t& aState,
   244                                       const int32_t& aMountGeneration,
   245                                       const bool& aIsMediaPresent,
   246                                       const bool& aIsSharing,
   247                                       const bool& aIsFormatting) MOZ_OVERRIDE;
   249     virtual bool RecvNuwaFork() MOZ_OVERRIDE;
   251     virtual bool
   252     RecvNotifyProcessPriorityChanged(const hal::ProcessPriority& aPriority) MOZ_OVERRIDE;
   253     virtual bool RecvMinimizeMemoryUsage() MOZ_OVERRIDE;
   255     virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI,
   256                                           const uint32_t& aType) MOZ_OVERRIDE;
   257     virtual bool RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType) MOZ_OVERRIDE;
   259     virtual bool RecvNotifyPhoneStateChange(const nsString& state) MOZ_OVERRIDE;
   261     void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
   262     void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
   263     virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
   264                                         const nsCString& aTopic,
   265                                         const nsString& aData) MOZ_OVERRIDE;
   266 #ifdef ANDROID
   267     gfxIntSize GetScreenSize() { return mScreenSize; }
   268 #endif
   270     // Get the directory for IndexedDB files. We query the parent for this and
   271     // cache the value
   272     nsString &GetIndexedDBPath();
   274     uint64_t GetID() { return mID; }
   276     bool IsForApp() { return mIsForApp; }
   277     bool IsForBrowser() { return mIsForBrowser; }
   279     BlobChild* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
   281     virtual PFileDescriptorSetChild*
   282     AllocPFileDescriptorSetChild(const FileDescriptor&) MOZ_OVERRIDE;
   284     virtual bool
   285     DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*) MOZ_OVERRIDE;
   287 protected:
   288     virtual bool RecvPBrowserConstructor(PBrowserChild* actor,
   289                                          const IPCTabContext& context,
   290                                          const uint32_t& chromeFlags) MOZ_OVERRIDE;
   292 private:
   293     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
   295     virtual void ProcessingError(Result what) MOZ_OVERRIDE;
   297     /**
   298      * Exit *now*.  Do not shut down XPCOM, do not pass Go, do not run
   299      * static destructors, do not collect $200.
   300      */
   301     MOZ_NORETURN void QuickExit();
   303     InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
   304     nsRefPtr<ConsoleListener> mConsoleListener;
   306     nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
   308     /**
   309      * An ID unique to the process containing our corresponding
   310      * content parent.
   311      *
   312      * We expect our content parent to set this ID immediately after opening a
   313      * channel to us.
   314      */
   315     uint64_t mID;
   317     AppInfo mAppInfo;
   319 #ifdef ANDROID
   320     gfxIntSize mScreenSize;
   321 #endif
   323     bool mIsForApp;
   324     bool mIsForBrowser;
   325     bool mCanOverrideProcessName;
   326     nsString mProcessName;
   328     static ContentChild* sSingleton;
   330     DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
   331 };
   333 } // namespace dom
   334 } // namespace mozilla
   336 #endif

mercurial