dom/ipc/ContentChild.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/ipc/ContentChild.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,336 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set sw=4 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_ContentChild_h
    1.11 +#define mozilla_dom_ContentChild_h
    1.12 +
    1.13 +#include "mozilla/Attributes.h"
    1.14 +#include "mozilla/dom/PContentChild.h"
    1.15 +#include "mozilla/dom/ipc/Blob.h"
    1.16 +#include "nsHashKeys.h"
    1.17 +#include "nsIObserver.h"
    1.18 +#include "nsTHashtable.h"
    1.19 +
    1.20 +#include "nsWeakPtr.h"
    1.21 +
    1.22 +
    1.23 +struct ChromePackage;
    1.24 +class nsIDOMBlob;
    1.25 +class nsIObserver;
    1.26 +struct ResourceMapping;
    1.27 +struct OverrideMapping;
    1.28 +
    1.29 +namespace mozilla {
    1.30 +
    1.31 +namespace ipc {
    1.32 +class OptionalURIParams;
    1.33 +class URIParams;
    1.34 +}// namespace ipc
    1.35 +
    1.36 +namespace jsipc {
    1.37 +class JavaScriptChild;
    1.38 +}
    1.39 +
    1.40 +namespace layers {
    1.41 +class PCompositorChild;
    1.42 +} // namespace layers
    1.43 +
    1.44 +namespace dom {
    1.45 +
    1.46 +class AlertObserver;
    1.47 +class PrefObserver;
    1.48 +class ConsoleListener;
    1.49 +class PStorageChild;
    1.50 +class ClonedMessageData;
    1.51 +class PFileDescriptorSetChild;
    1.52 +
    1.53 +class ContentChild : public PContentChild
    1.54 +{
    1.55 +    typedef mozilla::dom::ClonedMessageData ClonedMessageData;
    1.56 +    typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
    1.57 +    typedef mozilla::ipc::URIParams URIParams;
    1.58 +
    1.59 +public:
    1.60 +    ContentChild();
    1.61 +    virtual ~ContentChild();
    1.62 +    nsrefcnt AddRef() { return 1; }
    1.63 +    nsrefcnt Release() { return 1; }
    1.64 +
    1.65 +    struct AppInfo
    1.66 +    {
    1.67 +        nsCString version;
    1.68 +        nsCString buildID;
    1.69 +        nsCString name;
    1.70 +        nsCString UAName;
    1.71 +    };
    1.72 +
    1.73 +    bool Init(MessageLoop* aIOLoop,
    1.74 +              base::ProcessHandle aParentHandle,
    1.75 +              IPC::Channel* aChannel);
    1.76 +    void InitProcessAttributes();
    1.77 +    void InitXPCOM();
    1.78 +
    1.79 +    static ContentChild* GetSingleton() {
    1.80 +        return sSingleton;
    1.81 +    }
    1.82 +
    1.83 +    const AppInfo& GetAppInfo() {
    1.84 +        return mAppInfo;
    1.85 +    }
    1.86 +
    1.87 +    void SetProcessName(const nsAString& aName, bool aDontOverride = false);
    1.88 +    void GetProcessName(nsAString& aName);
    1.89 +    void GetProcessName(nsACString& aName);
    1.90 +    static void AppendProcessId(nsACString& aName);
    1.91 +
    1.92 +    PCompositorChild*
    1.93 +    AllocPCompositorChild(mozilla::ipc::Transport* aTransport,
    1.94 +                          base::ProcessId aOtherProcess) MOZ_OVERRIDE;
    1.95 +    PImageBridgeChild*
    1.96 +    AllocPImageBridgeChild(mozilla::ipc::Transport* aTransport,
    1.97 +                           base::ProcessId aOtherProcess) MOZ_OVERRIDE;
    1.98 +
    1.99 +    virtual bool RecvSetProcessSandbox() MOZ_OVERRIDE;
   1.100 +
   1.101 +    PBackgroundChild*
   1.102 +    AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
   1.103 +                          MOZ_OVERRIDE;
   1.104 +
   1.105 +    virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext &aContext,
   1.106 +                                              const uint32_t &chromeFlags);
   1.107 +    virtual bool DeallocPBrowserChild(PBrowserChild*);
   1.108 +
   1.109 +    virtual PDeviceStorageRequestChild* AllocPDeviceStorageRequestChild(const DeviceStorageParams&);
   1.110 +    virtual bool DeallocPDeviceStorageRequestChild(PDeviceStorageRequestChild*);
   1.111 +
   1.112 +    virtual PFileSystemRequestChild* AllocPFileSystemRequestChild(const FileSystemParams&);
   1.113 +    virtual bool DeallocPFileSystemRequestChild(PFileSystemRequestChild*);
   1.114 +
   1.115 +    virtual PBlobChild* AllocPBlobChild(const BlobConstructorParams& aParams);
   1.116 +    virtual bool DeallocPBlobChild(PBlobChild*);
   1.117 +
   1.118 +    virtual PCrashReporterChild*
   1.119 +    AllocPCrashReporterChild(const mozilla::dom::NativeThreadId& id,
   1.120 +                             const uint32_t& processType) MOZ_OVERRIDE;
   1.121 +    virtual bool
   1.122 +    DeallocPCrashReporterChild(PCrashReporterChild*) MOZ_OVERRIDE;
   1.123 +
   1.124 +    virtual PHalChild* AllocPHalChild() MOZ_OVERRIDE;
   1.125 +    virtual bool DeallocPHalChild(PHalChild*) MOZ_OVERRIDE;
   1.126 +
   1.127 +    virtual PIndexedDBChild* AllocPIndexedDBChild() MOZ_OVERRIDE;
   1.128 +    virtual bool DeallocPIndexedDBChild(PIndexedDBChild* aActor) MOZ_OVERRIDE;
   1.129 +
   1.130 +    virtual PMemoryReportRequestChild*
   1.131 +    AllocPMemoryReportRequestChild(const uint32_t& generation,
   1.132 +                                   const bool &minimizeMemoryUsage,
   1.133 +                                   const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
   1.134 +    virtual bool
   1.135 +    DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) MOZ_OVERRIDE;
   1.136 +
   1.137 +    virtual bool
   1.138 +    RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* child,
   1.139 +                                        const uint32_t& generation,
   1.140 +                                        const bool &minimizeMemoryUsage,
   1.141 +                                        const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
   1.142 +
   1.143 +    virtual bool
   1.144 +    RecvAudioChannelNotify() MOZ_OVERRIDE;
   1.145 +
   1.146 +    virtual bool
   1.147 +    RecvDumpGCAndCCLogsToFile(const nsString& aIdentifier,
   1.148 +                              const bool& aDumpAllTraces,
   1.149 +                              const bool& aDumpChildProcesses) MOZ_OVERRIDE;
   1.150 +
   1.151 +    virtual PTestShellChild* AllocPTestShellChild() MOZ_OVERRIDE;
   1.152 +    virtual bool DeallocPTestShellChild(PTestShellChild*) MOZ_OVERRIDE;
   1.153 +    virtual bool RecvPTestShellConstructor(PTestShellChild*) MOZ_OVERRIDE;
   1.154 +    jsipc::JavaScriptChild *GetCPOWManager();
   1.155 +
   1.156 +    virtual PNeckoChild* AllocPNeckoChild() MOZ_OVERRIDE;
   1.157 +    virtual bool DeallocPNeckoChild(PNeckoChild*) MOZ_OVERRIDE;
   1.158 +
   1.159 +    virtual PExternalHelperAppChild *AllocPExternalHelperAppChild(
   1.160 +            const OptionalURIParams& uri,
   1.161 +            const nsCString& aMimeContentType,
   1.162 +            const nsCString& aContentDisposition,
   1.163 +            const uint32_t& aContentDispositionHint,
   1.164 +            const nsString& aContentDispositionFilename,
   1.165 +            const bool& aForceSave,
   1.166 +            const int64_t& aContentLength,
   1.167 +            const OptionalURIParams& aReferrer,
   1.168 +            PBrowserChild* aBrowser) MOZ_OVERRIDE;
   1.169 +    virtual bool DeallocPExternalHelperAppChild(PExternalHelperAppChild *aService) MOZ_OVERRIDE;
   1.170 +
   1.171 +    virtual PSmsChild* AllocPSmsChild() MOZ_OVERRIDE;
   1.172 +    virtual bool DeallocPSmsChild(PSmsChild*) MOZ_OVERRIDE;
   1.173 +
   1.174 +    virtual PTelephonyChild* AllocPTelephonyChild() MOZ_OVERRIDE;
   1.175 +    virtual bool DeallocPTelephonyChild(PTelephonyChild*) MOZ_OVERRIDE;
   1.176 +
   1.177 +    virtual PStorageChild* AllocPStorageChild() MOZ_OVERRIDE;
   1.178 +    virtual bool DeallocPStorageChild(PStorageChild* aActor) MOZ_OVERRIDE;
   1.179 +
   1.180 +    virtual PBluetoothChild* AllocPBluetoothChild() MOZ_OVERRIDE;
   1.181 +    virtual bool DeallocPBluetoothChild(PBluetoothChild* aActor) MOZ_OVERRIDE;
   1.182 +
   1.183 +    virtual PFMRadioChild* AllocPFMRadioChild() MOZ_OVERRIDE;
   1.184 +    virtual bool DeallocPFMRadioChild(PFMRadioChild* aActor) MOZ_OVERRIDE;
   1.185 +
   1.186 +    virtual PAsmJSCacheEntryChild* AllocPAsmJSCacheEntryChild(
   1.187 +                                 const asmjscache::OpenMode& aOpenMode,
   1.188 +                                 const asmjscache::WriteParams& aWriteParams,
   1.189 +                                 const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
   1.190 +    virtual bool DeallocPAsmJSCacheEntryChild(
   1.191 +                                    PAsmJSCacheEntryChild* aActor) MOZ_OVERRIDE;
   1.192 +
   1.193 +    virtual PSpeechSynthesisChild* AllocPSpeechSynthesisChild() MOZ_OVERRIDE;
   1.194 +    virtual bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor) MOZ_OVERRIDE;
   1.195 +
   1.196 +    virtual bool RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
   1.197 +                                    const InfallibleTArray<ResourceMapping>& resources,
   1.198 +                                    const InfallibleTArray<OverrideMapping>& overrides,
   1.199 +                                    const nsCString& locale) MOZ_OVERRIDE;
   1.200 +
   1.201 +    virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() MOZ_OVERRIDE;
   1.202 +    virtual bool DeallocPJavaScriptChild(mozilla::jsipc::PJavaScriptChild*) MOZ_OVERRIDE;
   1.203 +
   1.204 +    virtual bool RecvSetOffline(const bool& offline) MOZ_OVERRIDE;
   1.205 +
   1.206 +    virtual bool RecvSpeakerManagerNotify() MOZ_OVERRIDE;
   1.207 +
   1.208 +    virtual bool RecvNotifyVisited(const URIParams& aURI) MOZ_OVERRIDE;
   1.209 +    // auto remove when alertfinished is received.
   1.210 +    nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
   1.211 +
   1.212 +    virtual bool RecvPreferenceUpdate(const PrefSetting& aPref) MOZ_OVERRIDE;
   1.213 +
   1.214 +    virtual bool RecvNotifyAlertsObserver(const nsCString& aType,
   1.215 +                                          const nsString& aData) MOZ_OVERRIDE;
   1.216 +
   1.217 +    virtual bool RecvAsyncMessage(const nsString& aMsg,
   1.218 +                                  const ClonedMessageData& aData,
   1.219 +                                  const InfallibleTArray<CpowEntry>& aCpows,
   1.220 +                                  const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
   1.221 +
   1.222 +    virtual bool RecvGeolocationUpdate(const GeoPosition& somewhere) MOZ_OVERRIDE;
   1.223 +
   1.224 +    virtual bool RecvAddPermission(const IPC::Permission& permission) MOZ_OVERRIDE;
   1.225 +
   1.226 +    virtual bool RecvScreenSizeChanged(const gfxIntSize &size) MOZ_OVERRIDE;
   1.227 +
   1.228 +    virtual bool RecvFlushMemory(const nsString& reason) MOZ_OVERRIDE;
   1.229 +
   1.230 +    virtual bool RecvActivateA11y() MOZ_OVERRIDE;
   1.231 +
   1.232 +    virtual bool RecvGarbageCollect() MOZ_OVERRIDE;
   1.233 +    virtual bool RecvCycleCollect() MOZ_OVERRIDE;
   1.234 +
   1.235 +    virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID,
   1.236 +                             const nsCString& name, const nsCString& UAName) MOZ_OVERRIDE;
   1.237 +
   1.238 +    virtual bool RecvLastPrivateDocShellDestroyed() MOZ_OVERRIDE;
   1.239 +
   1.240 +    virtual bool RecvFilePathUpdate(const nsString& aStorageType,
   1.241 +                                    const nsString& aStorageName,
   1.242 +                                    const nsString& aPath,
   1.243 +                                    const nsCString& aReason) MOZ_OVERRIDE;
   1.244 +    virtual bool RecvFileSystemUpdate(const nsString& aFsName,
   1.245 +                                      const nsString& aVolumeName,
   1.246 +                                      const int32_t& aState,
   1.247 +                                      const int32_t& aMountGeneration,
   1.248 +                                      const bool& aIsMediaPresent,
   1.249 +                                      const bool& aIsSharing,
   1.250 +                                      const bool& aIsFormatting) MOZ_OVERRIDE;
   1.251 +
   1.252 +    virtual bool RecvNuwaFork() MOZ_OVERRIDE;
   1.253 +
   1.254 +    virtual bool
   1.255 +    RecvNotifyProcessPriorityChanged(const hal::ProcessPriority& aPriority) MOZ_OVERRIDE;
   1.256 +    virtual bool RecvMinimizeMemoryUsage() MOZ_OVERRIDE;
   1.257 +
   1.258 +    virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI,
   1.259 +                                          const uint32_t& aType) MOZ_OVERRIDE;
   1.260 +    virtual bool RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType) MOZ_OVERRIDE;
   1.261 +
   1.262 +    virtual bool RecvNotifyPhoneStateChange(const nsString& state) MOZ_OVERRIDE;
   1.263 +
   1.264 +    void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
   1.265 +    void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
   1.266 +    virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
   1.267 +                                        const nsCString& aTopic,
   1.268 +                                        const nsString& aData) MOZ_OVERRIDE;
   1.269 +#ifdef ANDROID
   1.270 +    gfxIntSize GetScreenSize() { return mScreenSize; }
   1.271 +#endif
   1.272 +
   1.273 +    // Get the directory for IndexedDB files. We query the parent for this and
   1.274 +    // cache the value
   1.275 +    nsString &GetIndexedDBPath();
   1.276 +
   1.277 +    uint64_t GetID() { return mID; }
   1.278 +
   1.279 +    bool IsForApp() { return mIsForApp; }
   1.280 +    bool IsForBrowser() { return mIsForBrowser; }
   1.281 +
   1.282 +    BlobChild* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
   1.283 +
   1.284 +    virtual PFileDescriptorSetChild*
   1.285 +    AllocPFileDescriptorSetChild(const FileDescriptor&) MOZ_OVERRIDE;
   1.286 +
   1.287 +    virtual bool
   1.288 +    DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*) MOZ_OVERRIDE;
   1.289 +
   1.290 +protected:
   1.291 +    virtual bool RecvPBrowserConstructor(PBrowserChild* actor,
   1.292 +                                         const IPCTabContext& context,
   1.293 +                                         const uint32_t& chromeFlags) MOZ_OVERRIDE;
   1.294 +
   1.295 +private:
   1.296 +    virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
   1.297 +
   1.298 +    virtual void ProcessingError(Result what) MOZ_OVERRIDE;
   1.299 +
   1.300 +    /**
   1.301 +     * Exit *now*.  Do not shut down XPCOM, do not pass Go, do not run
   1.302 +     * static destructors, do not collect $200.
   1.303 +     */
   1.304 +    MOZ_NORETURN void QuickExit();
   1.305 +
   1.306 +    InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
   1.307 +    nsRefPtr<ConsoleListener> mConsoleListener;
   1.308 +
   1.309 +    nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
   1.310 +
   1.311 +    /**
   1.312 +     * An ID unique to the process containing our corresponding
   1.313 +     * content parent.
   1.314 +     *
   1.315 +     * We expect our content parent to set this ID immediately after opening a
   1.316 +     * channel to us.
   1.317 +     */
   1.318 +    uint64_t mID;
   1.319 +
   1.320 +    AppInfo mAppInfo;
   1.321 +
   1.322 +#ifdef ANDROID
   1.323 +    gfxIntSize mScreenSize;
   1.324 +#endif
   1.325 +
   1.326 +    bool mIsForApp;
   1.327 +    bool mIsForBrowser;
   1.328 +    bool mCanOverrideProcessName;
   1.329 +    nsString mProcessName;
   1.330 +
   1.331 +    static ContentChild* sSingleton;
   1.332 +
   1.333 +    DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
   1.334 +};
   1.335 +
   1.336 +} // namespace dom
   1.337 +} // namespace mozilla
   1.338 +
   1.339 +#endif

mercurial