dom/ipc/ContentChild.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial