1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 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/Atomics.h"
11 #include "mozilla/dom/BlobImpl.h"
12 #include "mozilla/dom/GetFilesHelper.h"
13 #include "mozilla/dom/PContentChild.h"
14 #include "mozilla/dom/ProcessActor.h"
15 #include "mozilla/dom/RemoteType.h"
16 #include "mozilla/Hal.h"
17 #include "mozilla/ipc/InputStreamUtils.h"
18 #include "mozilla/ipc/ProtocolUtils.h"
19 #include "mozilla/StaticPtr.h"
20 #include "mozilla/UniquePtr.h"
21 #include "nsClassHashtable.h"
23 #include "nsHashKeys.h"
24 #include "nsIDOMProcessChild.h"
25 #include "nsRefPtrHashtable.h"
27 #include "nsTArrayForwardDeclare.h"
28 #include "nsTHashSet.h"
30 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
34 #if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
35 # include "mozilla/PSandboxTestingChild.h"
40 struct SubstitutionMapping
;
41 struct OverrideMapping
;
42 class nsIDomainPolicy
;
43 class nsIURIClassifierCallback
;
44 class nsDocShellLoadState
;
46 class nsIOpenWindowInfo
;
49 class RemoteSpellcheckEngineChild
;
50 class ChildProfilerController
;
51 class BenchmarkStorageChild
;
54 class UntypedEndpoint
;
58 class PScriptCacheChild
;
62 enum class ThemeChangeKind
: uint8_t;
71 class ConsoleListener
;
72 class ClonedMessageData
;
75 enum class CallerType
: uint32_t;
77 class ContentChild final
: public PContentChild
,
78 public nsIDOMProcessChild
,
79 public mozilla::ipc::IShmemAllocator
,
81 using ClonedMessageData
= mozilla::dom::ClonedMessageData
;
82 using FileDescriptor
= mozilla::ipc::FileDescriptor
;
84 friend class PContentChild
;
87 NS_DECL_NSIDOMPROCESSCHILD
90 virtual ~ContentChild();
91 NS_IMETHOD
QueryInterface(REFNSIID aIID
, void** aInstancePtr
) override
;
92 NS_IMETHOD_(MozExternalRefCountType
) AddRef(void) override
{ return 1; }
93 NS_IMETHOD_(MozExternalRefCountType
) Release(void) override
{ return 1; }
106 MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
ProvideWindowCommon(
107 NotNull
<BrowserChild
*> aTabOpener
, nsIOpenWindowInfo
* aOpenWindowInfo
,
108 uint32_t aChromeFlags
, bool aCalledFromJS
, nsIURI
* aURI
,
109 const nsAString
& aName
, const nsACString
& aFeatures
, bool aForceNoOpener
,
110 bool aForceNoReferrer
, bool aIsPopupRequested
,
111 nsDocShellLoadState
* aLoadState
, bool* aWindowIsNew
,
112 BrowsingContext
** aReturn
);
114 void Init(mozilla::ipc::UntypedEndpoint
&& aEndpoint
,
115 const char* aParentBuildID
, uint64_t aChildID
, bool aIsForBrowser
);
117 void InitXPCOM(XPCOMInitData
&& aXPCOMInit
,
118 const mozilla::dom::ipc::StructuredCloneData
& aInitialData
,
119 bool aIsReadyForBackgroundProcessing
);
121 void InitSharedUASheets(Maybe
<base::SharedMemoryHandle
>&& aHandle
,
124 void InitGraphicsDeviceData(const ContentDeviceData
& aData
);
126 static ContentChild
* GetSingleton() { return sSingleton
; }
128 const AppInfo
& GetAppInfo() { return mAppInfo
; }
130 void SetProcessName(const nsACString
& aName
,
131 const nsACString
* aETLDplus1
= nullptr,
132 const nsACString
* aCurrentProfile
= nullptr);
134 void GetProcessName(nsACString
& aName
) const;
136 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
137 void GetProfileDir(nsIFile
** aProfileDir
) const {
138 *aProfileDir
= mProfileDir
;
139 NS_IF_ADDREF(*aProfileDir
);
142 void SetProfileDir(nsIFile
* aProfileDir
) { mProfileDir
= aProfileDir
; }
145 bool IsAlive() const;
147 bool IsShuttingDown() const;
149 ipc::SharedMap
* SharedData() { return mSharedData
; };
151 static void AppendProcessId(nsACString
& aName
);
153 static void UpdateCookieStatus(nsIChannel
* aChannel
);
155 mozilla::ipc::IPCResult
RecvInitGMPService(
156 Endpoint
<PGMPServiceChild
>&& aGMPService
);
158 mozilla::ipc::IPCResult
RecvInitProfiler(
159 Endpoint
<PProfilerChild
>&& aEndpoint
);
161 mozilla::ipc::IPCResult
RecvGMPsChanged(
162 nsTArray
<GMPCapabilityData
>&& capabilities
);
164 mozilla::ipc::IPCResult
RecvInitProcessHangMonitor(
165 Endpoint
<PProcessHangMonitorChild
>&& aHangMonitor
);
167 mozilla::ipc::IPCResult
RecvInitRendering(
168 Endpoint
<PCompositorManagerChild
>&& aCompositor
,
169 Endpoint
<PImageBridgeChild
>&& aImageBridge
,
170 Endpoint
<PVRManagerChild
>&& aVRBridge
,
171 Endpoint
<PRemoteDecoderManagerChild
>&& aVideoManager
,
172 nsTArray
<uint32_t>&& namespaces
);
174 mozilla::ipc::IPCResult
RecvReinitRendering(
175 Endpoint
<PCompositorManagerChild
>&& aCompositor
,
176 Endpoint
<PImageBridgeChild
>&& aImageBridge
,
177 Endpoint
<PVRManagerChild
>&& aVRBridge
,
178 Endpoint
<PRemoteDecoderManagerChild
>&& aVideoManager
,
179 nsTArray
<uint32_t>&& namespaces
);
181 mozilla::ipc::IPCResult
RecvReinitRenderingForDeviceReset();
183 mozilla::ipc::IPCResult
RecvSetProcessSandbox(
184 const Maybe
<FileDescriptor
>& aBroker
);
186 PHalChild
* AllocPHalChild();
187 bool DeallocPHalChild(PHalChild
*);
189 PHeapSnapshotTempFileHelperChild
* AllocPHeapSnapshotTempFileHelperChild();
191 bool DeallocPHeapSnapshotTempFileHelperChild(
192 PHeapSnapshotTempFileHelperChild
*);
194 PCycleCollectWithLogsChild
* AllocPCycleCollectWithLogsChild(
195 const bool& aDumpAllTraces
, const FileDescriptor
& aGCLog
,
196 const FileDescriptor
& aCCLog
);
198 bool DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild
* aActor
);
200 virtual mozilla::ipc::IPCResult
RecvPCycleCollectWithLogsConstructor(
201 PCycleCollectWithLogsChild
* aChild
, const bool& aDumpAllTraces
,
202 const FileDescriptor
& aGCLog
, const FileDescriptor
& aCCLog
) override
;
204 PWebBrowserPersistDocumentChild
* AllocPWebBrowserPersistDocumentChild(
205 PBrowserChild
* aBrowser
, const MaybeDiscarded
<BrowsingContext
>& aContext
);
207 virtual mozilla::ipc::IPCResult
RecvPWebBrowserPersistDocumentConstructor(
208 PWebBrowserPersistDocumentChild
* aActor
, PBrowserChild
* aBrowser
,
209 const MaybeDiscarded
<BrowsingContext
>& aContext
) override
;
211 bool DeallocPWebBrowserPersistDocumentChild(
212 PWebBrowserPersistDocumentChild
* aActor
);
214 PTestShellChild
* AllocPTestShellChild();
216 bool DeallocPTestShellChild(PTestShellChild
*);
218 virtual mozilla::ipc::IPCResult
RecvPTestShellConstructor(
219 PTestShellChild
*) override
;
221 PScriptCacheChild
* AllocPScriptCacheChild(const FileDescOrError
& cacheFile
,
222 const bool& wantCacheData
);
224 bool DeallocPScriptCacheChild(PScriptCacheChild
*);
226 virtual mozilla::ipc::IPCResult
RecvPScriptCacheConstructor(
227 PScriptCacheChild
*, const FileDescOrError
& cacheFile
,
228 const bool& wantCacheData
) override
;
230 PRemotePrintJobChild
* AllocPRemotePrintJobChild();
232 PMediaChild
* AllocPMediaChild();
234 bool DeallocPMediaChild(PMediaChild
* aActor
);
236 PBenchmarkStorageChild
* AllocPBenchmarkStorageChild();
238 bool DeallocPBenchmarkStorageChild(PBenchmarkStorageChild
* aActor
);
240 mozilla::ipc::IPCResult
RecvNotifyEmptyHTTPCache();
243 PSpeechSynthesisChild
* AllocPSpeechSynthesisChild();
244 bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild
* aActor
);
247 mozilla::ipc::IPCResult
RecvRegisterChrome(
248 nsTArray
<ChromePackage
>&& packages
,
249 nsTArray
<SubstitutionMapping
>&& resources
,
250 nsTArray
<OverrideMapping
>&& overrides
, const nsCString
& locale
,
252 mozilla::ipc::IPCResult
RecvRegisterChromeItem(
253 const ChromeRegistryItem
& item
);
255 mozilla::ipc::IPCResult
RecvClearStyleSheetCache(
256 const Maybe
<RefPtr
<nsIPrincipal
>>& aForPrincipal
,
257 const Maybe
<nsCString
>& aBaseDomain
);
259 mozilla::ipc::IPCResult
RecvClearImageCacheFromPrincipal(
260 nsIPrincipal
* aPrincipal
);
261 mozilla::ipc::IPCResult
RecvClearImageCacheFromBaseDomain(
262 const nsCString
& aBaseDomain
);
263 mozilla::ipc::IPCResult
RecvClearImageCache(const bool& privateLoader
,
266 PRemoteSpellcheckEngineChild
* AllocPRemoteSpellcheckEngineChild();
268 bool DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild
*);
270 mozilla::ipc::IPCResult
RecvSetOffline(const bool& offline
);
272 mozilla::ipc::IPCResult
RecvSetConnectivity(const bool& connectivity
);
273 mozilla::ipc::IPCResult
RecvSetCaptivePortalState(const int32_t& state
);
274 mozilla::ipc::IPCResult
RecvSetTRRMode(
275 const nsIDNSService::ResolverMode
& mode
,
276 const nsIDNSService::ResolverMode
& modeFromPref
);
278 mozilla::ipc::IPCResult
RecvBidiKeyboardNotify(const bool& isLangRTL
,
279 const bool& haveBidiKeyboards
);
281 mozilla::ipc::IPCResult
RecvNotifyVisited(nsTArray
<VisitedQueryResult
>&&);
283 mozilla::ipc::IPCResult
RecvThemeChanged(FullLookAndFeel
&&,
284 widget::ThemeChangeKind
);
286 // auto remove when alertfinished is received.
287 nsresult
AddRemoteAlertObserver(const nsString
& aData
,
288 nsIObserver
* aObserver
);
290 mozilla::ipc::IPCResult
RecvPreferenceUpdate(const Pref
& aPref
);
291 mozilla::ipc::IPCResult
RecvVarUpdate(const GfxVarUpdate
& pref
);
293 mozilla::ipc::IPCResult
RecvUpdatePerfStatsCollectionMask(
294 const uint64_t& aMask
);
296 mozilla::ipc::IPCResult
RecvCollectPerfStatsJSON(
297 CollectPerfStatsJSONResolver
&& aResolver
);
299 mozilla::ipc::IPCResult
RecvCollectScrollingMetrics(
300 CollectScrollingMetricsResolver
&& aResolver
);
302 mozilla::ipc::IPCResult
RecvNotifyAlertsObserver(const nsCString
& aType
,
303 const nsString
& aData
);
305 mozilla::ipc::IPCResult
RecvLoadProcessScript(const nsString
& aURL
);
307 mozilla::ipc::IPCResult
RecvAsyncMessage(const nsString
& aMsg
,
308 const ClonedMessageData
& aData
);
310 mozilla::ipc::IPCResult
RecvRegisterStringBundles(
311 nsTArray
<StringBundleDescriptor
>&& stringBundles
);
313 mozilla::ipc::IPCResult
RecvUpdateL10nFileSources(
314 nsTArray
<L10nFileSourceDescriptor
>&& aDescriptors
);
316 mozilla::ipc::IPCResult
RecvUpdateSharedData(
317 const FileDescriptor
& aMapFile
, const uint32_t& aMapSize
,
318 nsTArray
<IPCBlob
>&& aBlobs
, nsTArray
<nsCString
>&& aChangedKeys
);
320 mozilla::ipc::IPCResult
RecvFontListChanged();
321 mozilla::ipc::IPCResult
RecvForceGlobalReflow(bool aNeedsReframe
);
323 mozilla::ipc::IPCResult
RecvGeolocationUpdate(nsIDOMGeoPosition
* aPosition
);
325 // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we don't have MOZ_CAN_RUN_SCRIPT bits
327 MOZ_CAN_RUN_SCRIPT_BOUNDARY
328 mozilla::ipc::IPCResult
RecvGeolocationError(const uint16_t& errorCode
);
330 mozilla::ipc::IPCResult
RecvUpdateDictionaryList(
331 nsTArray
<nsCString
>&& aDictionaries
);
333 mozilla::ipc::IPCResult
RecvUpdateFontList(SystemFontList
&&);
334 mozilla::ipc::IPCResult
RecvRebuildFontList(const bool& aFullRebuild
);
335 mozilla::ipc::IPCResult
RecvFontListShmBlockAdded(
336 const uint32_t& aGeneration
, const uint32_t& aIndex
,
337 base::SharedMemoryHandle
&& aHandle
);
339 mozilla::ipc::IPCResult
RecvUpdateAppLocales(
340 nsTArray
<nsCString
>&& aAppLocales
);
341 mozilla::ipc::IPCResult
RecvUpdateRequestedLocales(
342 nsTArray
<nsCString
>&& aRequestedLocales
);
344 mozilla::ipc::IPCResult
RecvSystemTimezoneChanged();
346 mozilla::ipc::IPCResult
RecvAddPermission(const IPC::Permission
& permission
);
348 mozilla::ipc::IPCResult
RecvRemoveAllPermissions();
350 mozilla::ipc::IPCResult
RecvFlushMemory(const nsString
& reason
);
352 mozilla::ipc::IPCResult
RecvActivateA11y();
353 mozilla::ipc::IPCResult
RecvShutdownA11y();
355 mozilla::ipc::IPCResult
RecvApplicationForeground();
356 mozilla::ipc::IPCResult
RecvApplicationBackground();
357 mozilla::ipc::IPCResult
RecvGarbageCollect();
358 mozilla::ipc::IPCResult
RecvCycleCollect();
359 mozilla::ipc::IPCResult
RecvUnlinkGhosts();
361 mozilla::ipc::IPCResult
RecvAppInfo(
362 const nsCString
& version
, const nsCString
& buildID
, const nsCString
& name
,
363 const nsCString
& UAName
, const nsCString
& ID
, const nsCString
& vendor
,
364 const nsCString
& sourceURL
, const nsCString
& updateURL
);
366 mozilla::ipc::IPCResult
RecvRemoteType(const nsCString
& aRemoteType
,
367 const nsCString
& aProfile
);
371 // Call RemoteTypePrefix() on the result to remove URIs if you want to use
372 // this for telemetry.
373 const nsACString
& GetRemoteType() const override
;
375 mozilla::ipc::IPCResult
RecvInitBlobURLs(
376 nsTArray
<BlobURLRegistrationData
>&& aRegistations
);
378 mozilla::ipc::IPCResult
RecvInitJSActorInfos(
379 nsTArray
<JSProcessActorInfo
>&& aContentInfos
,
380 nsTArray
<JSWindowActorInfo
>&& aWindowInfos
);
382 mozilla::ipc::IPCResult
RecvUnregisterJSWindowActor(const nsCString
& aName
);
384 mozilla::ipc::IPCResult
RecvUnregisterJSProcessActor(const nsCString
& aName
);
386 mozilla::ipc::IPCResult
RecvLastPrivateDocShellDestroyed();
388 mozilla::ipc::IPCResult
RecvNotifyProcessPriorityChanged(
389 const hal::ProcessPriority
& aPriority
);
391 mozilla::ipc::IPCResult
RecvMinimizeMemoryUsage();
393 mozilla::ipc::IPCResult
RecvLoadAndRegisterSheet(nsIURI
* aURI
,
394 const uint32_t& aType
);
396 mozilla::ipc::IPCResult
RecvUnregisterSheet(nsIURI
* aURI
,
397 const uint32_t& aType
);
399 void AddIdleObserver(nsIObserver
* aObserver
, uint32_t aIdleTimeInS
);
401 void RemoveIdleObserver(nsIObserver
* aObserver
, uint32_t aIdleTimeInS
);
403 mozilla::ipc::IPCResult
RecvNotifyIdleObserver(const uint64_t& aObserver
,
404 const nsCString
& aTopic
,
405 const nsString
& aData
);
407 mozilla::ipc::IPCResult
RecvUpdateWindow(const uintptr_t& aChildId
);
409 mozilla::ipc::IPCResult
RecvDomainSetChanged(const uint32_t& aSetType
,
410 const uint32_t& aChangeType
,
413 mozilla::ipc::IPCResult
RecvShutdownConfirmedHP();
415 mozilla::ipc::IPCResult
RecvShutdown();
417 mozilla::ipc::IPCResult
RecvInvokeDragSession(
418 const MaybeDiscarded
<WindowContext
>& aSourceWindowContext
,
419 const MaybeDiscarded
<WindowContext
>& aSourceTopWindowContext
,
420 nsTArray
<IPCTransferableData
>&& aTransferables
, const uint32_t& aAction
);
422 MOZ_CAN_RUN_SCRIPT_BOUNDARY
423 mozilla::ipc::IPCResult
RecvEndDragSession(
424 const bool& aDoneDrag
, const bool& aUserCancelled
,
425 const mozilla::LayoutDeviceIntPoint
& aEndDragPoint
,
426 const uint32_t& aKeyModifiers
, const uint32_t& aDropEffect
);
428 mozilla::ipc::IPCResult
RecvPush(const nsCString
& aScope
,
429 nsIPrincipal
* aPrincipal
,
430 const nsString
& aMessageId
);
432 mozilla::ipc::IPCResult
RecvPushWithData(const nsCString
& aScope
,
433 nsIPrincipal
* aPrincipal
,
434 const nsString
& aMessageId
,
435 nsTArray
<uint8_t>&& aData
);
437 mozilla::ipc::IPCResult
RecvPushSubscriptionChange(const nsCString
& aScope
,
438 nsIPrincipal
* aPrincipal
);
440 mozilla::ipc::IPCResult
RecvPushError(const nsCString
& aScope
,
441 nsIPrincipal
* aPrincipal
,
442 const nsString
& aMessage
,
443 const uint32_t& aFlags
);
445 mozilla::ipc::IPCResult
RecvNotifyPushSubscriptionModifiedObservers(
446 const nsCString
& aScope
, nsIPrincipal
* aPrincipal
);
448 mozilla::ipc::IPCResult
RecvRefreshScreens(
449 nsTArray
<ScreenDetails
>&& aScreens
);
451 mozilla::ipc::IPCResult
RecvNetworkLinkTypeChange(const uint32_t& aType
);
452 uint32_t NetworkLinkType() const { return mNetworkLinkType
; }
454 mozilla::ipc::IPCResult
RecvSocketProcessCrashed();
456 // Get the directory for IndexedDB files. We query the parent for this and
458 nsString
& GetIndexedDBPath();
460 ContentParentId
GetID() const { return mID
; }
462 bool IsForBrowser() const { return mIsForBrowser
; }
464 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
RecvConstructBrowser(
465 ManagedEndpoint
<PBrowserChild
>&& aBrowserEp
,
466 ManagedEndpoint
<PWindowGlobalChild
>&& aWindowEp
, const TabId
& aTabId
,
467 const IPCTabContext
& aContext
, const WindowGlobalInit
& aWindowInit
,
468 const uint32_t& aChromeFlags
, const ContentParentId
& aCpID
,
469 const bool& aIsForBrowser
, const bool& aIsTopLevel
);
471 FORWARD_SHMEM_ALLOCATOR_TO(PContentChild
)
473 void GetAvailableDictionaries(nsTArray
<nsCString
>& aDictionaries
);
476 PWebrtcGlobalChild
* AllocPWebrtcGlobalChild();
477 bool DeallocPWebrtcGlobalChild(PWebrtcGlobalChild
* aActor
);
480 PContentPermissionRequestChild
* AllocPContentPermissionRequestChild(
481 Span
<const PermissionRequest
> aRequests
, nsIPrincipal
* aPrincipal
,
482 nsIPrincipal
* aTopLevelPrincipal
, const bool& aIsHandlingUserInput
,
483 const bool& aMaybeUnsafePermissionDelegate
, const TabId
& aTabId
);
484 bool DeallocPContentPermissionRequestChild(
485 PContentPermissionRequestChild
* actor
);
487 // GetFiles for WebKit/Blink FileSystem API and Directory API must run on the
489 void CreateGetFilesRequest(const nsAString
& aDirectoryPath
,
490 bool aRecursiveFlag
, nsID
& aUUID
,
491 GetFilesHelperChild
* aChild
);
493 void DeleteGetFilesRequest(nsID
& aUUID
, GetFilesHelperChild
* aChild
);
495 mozilla::ipc::IPCResult
RecvGetFilesResponse(
496 const nsID
& aUUID
, const GetFilesResponseResult
& aResult
);
498 mozilla::ipc::IPCResult
RecvBlobURLRegistration(
499 const nsCString
& aURI
, const IPCBlob
& aBlob
, nsIPrincipal
* aPrincipal
,
500 const nsCString
& aPartitionKey
);
502 mozilla::ipc::IPCResult
RecvBlobURLUnregistration(const nsCString
& aURI
);
504 mozilla::ipc::IPCResult
RecvRequestMemoryReport(
505 const uint32_t& generation
, const bool& anonymize
,
506 const bool& minimizeMemoryUsage
, const Maybe
<FileDescriptor
>& DMDFile
,
507 const RequestMemoryReportResolver
& aResolver
);
510 mozilla::ipc::IPCResult
RecvGetUntrustedModulesData(
511 GetUntrustedModulesDataResolver
&& aResolver
);
512 mozilla::ipc::IPCResult
RecvUnblockUntrustedModulesThread();
513 #endif // defined(XP_WIN)
515 mozilla::ipc::IPCResult
RecvSetXPCOMProcessAttributes(
516 XPCOMInitData
&& aXPCOMInit
, const StructuredCloneData
& aInitialData
,
517 FullLookAndFeel
&& aLookAndFeelData
, SystemFontList
&& aFontList
,
518 Maybe
<base::SharedMemoryHandle
>&& aSharedUASheetHandle
,
519 const uintptr_t& aSharedUASheetAddress
,
520 nsTArray
<base::SharedMemoryHandle
>&& aSharedFontListBlocks
,
521 const bool& aIsReadyForBackgroundProcessing
);
523 mozilla::ipc::IPCResult
RecvProvideAnonymousTemporaryFile(
524 const uint64_t& aID
, const FileDescOrError
& aFD
);
526 mozilla::ipc::IPCResult
RecvSetPermissionsWithKey(
527 const nsCString
& aPermissionKey
, nsTArray
<IPC::Permission
>&& aPerms
);
529 mozilla::ipc::IPCResult
RecvShareCodeCoverageMutex(
530 CrossProcessMutexHandle aHandle
);
532 mozilla::ipc::IPCResult
RecvFlushCodeCoverageCounters(
533 FlushCodeCoverageCountersResolver
&& aResolver
);
535 mozilla::ipc::IPCResult
RecvSetInputEventQueueEnabled();
537 mozilla::ipc::IPCResult
RecvFlushInputEventQueue();
539 mozilla::ipc::IPCResult
RecvSuspendInputEventQueue();
541 mozilla::ipc::IPCResult
RecvResumeInputEventQueue();
543 mozilla::ipc::IPCResult
RecvAddDynamicScalars(
544 nsTArray
<DynamicScalarDefinition
>&& aDefs
);
546 // Get a reference to the font list passed from the chrome process,
547 // for use during gfx initialization.
548 SystemFontList
& SystemFontList() { return mFontList
; }
550 nsTArray
<base::SharedMemoryHandle
>& SharedFontListBlocks() {
551 return mSharedFontListBlocks
;
554 // PURLClassifierChild
555 PURLClassifierChild
* AllocPURLClassifierChild(nsIPrincipal
* aPrincipal
,
557 bool DeallocPURLClassifierChild(PURLClassifierChild
* aActor
);
559 // PURLClassifierLocalChild
560 PURLClassifierLocalChild
* AllocPURLClassifierLocalChild(
561 nsIURI
* aUri
, Span
<const IPCURLClassifierFeature
> aFeatures
);
562 bool DeallocPURLClassifierLocalChild(PURLClassifierLocalChild
* aActor
);
564 PLoginReputationChild
* AllocPLoginReputationChild(nsIURI
* aUri
);
566 bool DeallocPLoginReputationChild(PLoginReputationChild
* aActor
);
568 PSessionStorageObserverChild
* AllocPSessionStorageObserverChild();
570 bool DeallocPSessionStorageObserverChild(
571 PSessionStorageObserverChild
* aActor
);
573 FullLookAndFeel
& BorrowLookAndFeelData() { return mLookAndFeelData
; }
576 * Helper function for protocols that use the GPU process when available.
577 * Overrides FatalError to just be a warning when communicating with the
578 * GPU process since we don't want to crash the content process when the
579 * GPU process crashes.
581 static void FatalErrorIfNotUsingGPUProcess(const char* const aErrorMsg
,
582 base::ProcessId aOtherPid
);
584 using AnonymousTemporaryFileCallback
= std::function
<void(PRFileDesc
*)>;
585 nsresult
AsyncOpenAnonymousTemporaryFile(
586 const AnonymousTemporaryFileCallback
& aCallback
);
588 mozilla::ipc::IPCResult
RecvSaveRecording(const FileDescriptor
& aFile
);
590 mozilla::ipc::IPCResult
RecvCrossProcessRedirect(
591 RedirectToRealChannelArgs
&& aArgs
,
592 nsTArray
<Endpoint
<extensions::PStreamFilterParent
>>&& aEndpoints
,
593 CrossProcessRedirectResolver
&& aResolve
);
595 mozilla::ipc::IPCResult
RecvStartDelayedAutoplayMediaComponents(
596 const MaybeDiscarded
<BrowsingContext
>& aContext
);
598 mozilla::ipc::IPCResult
RecvUpdateMediaControlAction(
599 const MaybeDiscarded
<BrowsingContext
>& aContext
,
600 const MediaControlAction
& aAction
);
602 // See `BrowsingContext::mEpochs` for an explanation of this field.
603 uint64_t GetBrowsingContextFieldEpoch() const {
604 return mBrowsingContextFieldEpoch
;
606 uint64_t NextBrowsingContextFieldEpoch() {
607 mBrowsingContextFieldEpoch
++;
608 return mBrowsingContextFieldEpoch
;
611 mozilla::ipc::IPCResult
RecvOnAllowAccessFor(
612 const MaybeDiscarded
<BrowsingContext
>& aContext
,
613 const nsCString
& aTrackingOrigin
, uint32_t aCookieBehavior
,
614 const ContentBlockingNotifier::StorageAccessPermissionGrantedReason
&
617 mozilla::ipc::IPCResult
RecvOnContentBlockingDecision(
618 const MaybeDiscarded
<BrowsingContext
>& aContext
,
619 const ContentBlockingNotifier::BlockingDecision
& aDecision
,
620 uint32_t aRejectedReason
);
623 // Fetch the current number of pending input events.
625 // NOTE: This method performs an atomic read, and is safe to call from all
627 uint32_t GetPendingInputEvents() { return mPendingInputEvents
; }
630 #if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
631 mozilla::ipc::IPCResult
RecvInitSandboxTesting(
632 Endpoint
<PSandboxTestingChild
>&& aEndpoint
);
636 static void ForceKillTimerCallback(nsITimer
* aTimer
, void* aClosure
);
637 void StartForceKillTimer();
639 void ShutdownInternal();
641 mozilla::ipc::IPCResult
GetResultForRenderingInitFailure(
642 base::ProcessId aOtherPid
);
644 virtual void ActorDestroy(ActorDestroyReason why
) override
;
646 virtual void ProcessingError(Result aCode
, const char* aReason
) override
;
648 mozilla::ipc::IPCResult
RecvCreateBrowsingContext(
649 uint64_t aGroupId
, BrowsingContext::IPCInitializer
&& aInit
);
651 mozilla::ipc::IPCResult
RecvDiscardBrowsingContext(
652 const MaybeDiscarded
<BrowsingContext
>& aContext
, bool aDoDiscard
,
653 DiscardBrowsingContextResolver
&& aResolve
);
655 mozilla::ipc::IPCResult
RecvRegisterBrowsingContextGroup(
656 uint64_t aGroupId
, nsTArray
<SyncedContextInitializer
>&& aInits
);
657 mozilla::ipc::IPCResult
RecvDestroyBrowsingContextGroup(uint64_t aGroupId
);
659 mozilla::ipc::IPCResult
RecvWindowClose(
660 const MaybeDiscarded
<BrowsingContext
>& aContext
, bool aTrustedCaller
);
661 mozilla::ipc::IPCResult
RecvWindowFocus(
662 const MaybeDiscarded
<BrowsingContext
>& aContext
, CallerType aCallerType
,
664 mozilla::ipc::IPCResult
RecvWindowBlur(
665 const MaybeDiscarded
<BrowsingContext
>& aContext
, CallerType aCallerType
);
666 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
RecvRaiseWindow(
667 const MaybeDiscarded
<BrowsingContext
>& aContext
, CallerType aCallerType
,
669 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
RecvAdjustWindowFocus(
670 const MaybeDiscarded
<BrowsingContext
>& aContext
, bool aIsVisible
,
672 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
RecvClearFocus(
673 const MaybeDiscarded
<BrowsingContext
>& aContext
);
674 mozilla::ipc::IPCResult
RecvSetFocusedBrowsingContext(
675 const MaybeDiscarded
<BrowsingContext
>& aContext
, uint64_t aActionId
);
676 mozilla::ipc::IPCResult
RecvSetActiveBrowsingContext(
677 const MaybeDiscarded
<BrowsingContext
>& aContext
, uint64_t aActionId
);
678 mozilla::ipc::IPCResult
RecvAbortOrientationPendingPromises(
679 const MaybeDiscarded
<BrowsingContext
>& aContext
);
680 mozilla::ipc::IPCResult
RecvUnsetActiveBrowsingContext(
681 const MaybeDiscarded
<BrowsingContext
>& aContext
, uint64_t aActionId
);
682 mozilla::ipc::IPCResult
RecvSetFocusedElement(
683 const MaybeDiscarded
<BrowsingContext
>& aContext
, bool aNeedsFocus
);
684 mozilla::ipc::IPCResult
RecvFinalizeFocusOuter(
685 const MaybeDiscarded
<BrowsingContext
>& aContext
, bool aCanFocus
,
686 CallerType aCallerType
);
687 MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult
RecvBlurToChild(
688 const MaybeDiscarded
<BrowsingContext
>& aFocusedBrowsingContext
,
689 const MaybeDiscarded
<BrowsingContext
>& aBrowsingContextToClear
,
690 const MaybeDiscarded
<BrowsingContext
>& aAncestorBrowsingContextToFocus
,
691 bool aIsLeavingDocument
, bool aAdjustWidget
, uint64_t aActionId
);
692 mozilla::ipc::IPCResult
RecvSetupFocusedAndActive(
693 const MaybeDiscarded
<BrowsingContext
>& aFocusedBrowsingContext
,
694 uint64_t aActionIdForFocused
,
695 const MaybeDiscarded
<BrowsingContext
>& aActiveBrowsingContext
,
696 uint64_t aActionIdForActive
);
697 mozilla::ipc::IPCResult
RecvReviseActiveBrowsingContext(
698 uint64_t aOldActionId
,
699 const MaybeDiscarded
<BrowsingContext
>& aActiveBrowsingContext
,
700 uint64_t aNewActionId
);
701 mozilla::ipc::IPCResult
RecvReviseFocusedBrowsingContext(
702 uint64_t aOldActionId
,
703 const MaybeDiscarded
<BrowsingContext
>& aFocusedBrowsingContext
,
704 uint64_t aNewActionId
);
705 mozilla::ipc::IPCResult
RecvMaybeExitFullscreen(
706 const MaybeDiscarded
<BrowsingContext
>& aContext
);
708 mozilla::ipc::IPCResult
RecvWindowPostMessage(
709 const MaybeDiscarded
<BrowsingContext
>& aContext
,
710 const ClonedOrErrorMessageData
& aMessage
, const PostMessageData
& aData
);
712 mozilla::ipc::IPCResult
RecvCommitBrowsingContextTransaction(
713 const MaybeDiscarded
<BrowsingContext
>& aContext
,
714 BrowsingContext::BaseTransaction
&& aTransaction
, uint64_t aEpoch
);
716 mozilla::ipc::IPCResult
RecvCommitWindowContextTransaction(
717 const MaybeDiscarded
<WindowContext
>& aContext
,
718 WindowContext::BaseTransaction
&& aTransaction
, uint64_t aEpoch
);
720 mozilla::ipc::IPCResult
RecvCreateWindowContext(
721 WindowContext::IPCInitializer
&& aInit
);
722 mozilla::ipc::IPCResult
RecvDiscardWindowContext(
723 uint64_t aContextId
, DiscardWindowContextResolver
&& aResolve
);
725 mozilla::ipc::IPCResult
RecvScriptError(
726 const nsString
& aMessage
, const nsString
& aSourceName
,
727 const nsString
& aSourceLine
, const uint32_t& aLineNumber
,
728 const uint32_t& aColNumber
, const uint32_t& aFlags
,
729 const nsCString
& aCategory
, const bool& aFromPrivateWindow
,
730 const uint64_t& aInnerWindowId
, const bool& aFromChromeContext
);
732 mozilla::ipc::IPCResult
RecvReportFrameTimingData(
733 const LoadInfoArgs
& loadInfoArgs
, const nsString
& entryName
,
734 const nsString
& initiatorType
, UniquePtr
<PerformanceTimingData
>&& aData
);
736 mozilla::ipc::IPCResult
RecvLoadURI(
737 const MaybeDiscarded
<BrowsingContext
>& aContext
,
738 nsDocShellLoadState
* aLoadState
, bool aSetNavigating
,
739 LoadURIResolver
&& aResolve
);
741 mozilla::ipc::IPCResult
RecvInternalLoad(nsDocShellLoadState
* aLoadState
);
743 mozilla::ipc::IPCResult
RecvDisplayLoadError(
744 const MaybeDiscarded
<BrowsingContext
>& aContext
, const nsAString
& aURI
);
746 mozilla::ipc::IPCResult
RecvGoBack(
747 const MaybeDiscarded
<BrowsingContext
>& aContext
,
748 const Maybe
<int32_t>& aCancelContentJSEpoch
, bool aRequireUserInteraction
,
749 bool aUserActivation
);
750 mozilla::ipc::IPCResult
RecvGoForward(
751 const MaybeDiscarded
<BrowsingContext
>& aContext
,
752 const Maybe
<int32_t>& aCancelContentJSEpoch
, bool aRequireUserInteraction
,
753 bool aUserActivation
);
754 mozilla::ipc::IPCResult
RecvGoToIndex(
755 const MaybeDiscarded
<BrowsingContext
>& aContext
, const int32_t& aIndex
,
756 const Maybe
<int32_t>& aCancelContentJSEpoch
, bool aUserActivation
);
757 mozilla::ipc::IPCResult
RecvReload(
758 const MaybeDiscarded
<BrowsingContext
>& aContext
,
759 const uint32_t aReloadFlags
);
760 mozilla::ipc::IPCResult
RecvStopLoad(
761 const MaybeDiscarded
<BrowsingContext
>& aContext
,
762 const uint32_t aStopFlags
);
764 mozilla::ipc::IPCResult
RecvRawMessage(
765 const JSActorMessageMeta
& aMeta
, const Maybe
<ClonedMessageData
>& aData
,
766 const Maybe
<ClonedMessageData
>& aStack
);
768 already_AddRefed
<JSActor
> InitJSActor(JS::Handle
<JSObject
*> aMaybeActor
,
769 const nsACString
& aName
,
770 ErrorResult
& aRv
) override
;
771 mozilla::ipc::IProtocol
* AsNativeActor() override
{ return this; }
773 mozilla::ipc::IPCResult
RecvHistoryCommitIndexAndLength(
774 const MaybeDiscarded
<BrowsingContext
>& aContext
, const uint32_t& aIndex
,
775 const uint32_t& aLength
, const nsID
& aChangeID
);
777 mozilla::ipc::IPCResult
RecvGetLayoutHistoryState(
778 const MaybeDiscarded
<BrowsingContext
>& aContext
,
779 GetLayoutHistoryStateResolver
&& aResolver
);
781 mozilla::ipc::IPCResult
RecvDispatchLocationChangeEvent(
782 const MaybeDiscarded
<BrowsingContext
>& aContext
);
784 mozilla::ipc::IPCResult
RecvDispatchBeforeUnloadToSubtree(
785 const MaybeDiscarded
<BrowsingContext
>& aStartingAt
,
786 DispatchBeforeUnloadToSubtreeResolver
&& aResolver
);
788 mozilla::ipc::IPCResult
RecvDecoderSupportedMimeTypes(
789 nsTArray
<nsCString
>&& aSupportedTypes
);
791 mozilla::ipc::IPCResult
RecvInitNextGenLocalStorageEnabled(
792 const bool& aEnabled
);
795 static void DispatchBeforeUnloadToSubtree(
796 BrowsingContext
* aStartingAt
,
797 const DispatchBeforeUnloadToSubtreeResolver
& aResolver
);
799 hal::ProcessPriority
GetProcessPriority() const { return mProcessPriority
; }
801 hal::PerformanceHintSession
* PerformanceHintSession() const {
802 return mPerformanceHintSession
.get();
805 // Returns the target work duration for the PerformanceHintSession, based on
806 // the refresh interval. Estimate that we want the tick to complete in at most
807 // half of the refresh period. This is fairly arbitrary and can be tweaked
809 static TimeDuration
GetPerformanceHintTarget(TimeDuration aRefreshInterval
) {
810 return aRefreshInterval
/ int64_t(2);
814 void AddProfileToProcessName(const nsACString
& aProfile
);
815 mozilla::ipc::IPCResult
RecvFlushFOGData(FlushFOGDataResolver
&& aResolver
);
817 mozilla::ipc::IPCResult
RecvUpdateMediaCodecsSupported(
818 RemoteDecodeIn aLocation
, const media::MediaCodecsSupported
& aSupported
);
821 virtual void OnChannelReceivedMessage(const Message
& aMsg
) override
;
823 virtual PContentChild::Result
OnMessageReceived(const Message
& aMsg
) override
;
825 virtual PContentChild::Result
OnMessageReceived(
826 const Message
& aMsg
, UniquePtr
<Message
>& aReply
) override
;
829 void ConfigureThreadPerformanceHints(const hal::ProcessPriority
& aPriority
);
831 nsTArray
<mozilla::UniquePtr
<AlertObserver
>> mAlertObservers
;
832 RefPtr
<ConsoleListener
> mConsoleListener
;
834 nsTHashSet
<nsIObserver
*> mIdleObservers
;
836 nsTArray
<nsCString
> mAvailableDictionaries
;
838 // Temporary storage for a list of available fonts, passed from the
839 // parent process and used to initialize gfx in the child. Currently used
840 // only on MacOSX and Linux.
841 dom::SystemFontList mFontList
;
842 // Temporary storage for look and feel data.
843 FullLookAndFeel mLookAndFeelData
;
844 // Temporary storage for list of shared-fontlist memory blocks.
845 nsTArray
<base::SharedMemoryHandle
> mSharedFontListBlocks
;
848 * An ID unique to the process containing our corresponding
851 * We expect our content parent to set this ID immediately after opening a
859 nsCString mRemoteType
= NOT_REMOTE_TYPE
;
861 nsCString mProcessName
;
863 static ContentChild
* sSingleton
;
865 class ShutdownCanary
;
866 static StaticAutoPtr
<ShutdownCanary
> sShutdownCanary
;
868 nsCOMPtr
<nsIDomainPolicy
> mPolicy
;
869 nsCOMPtr
<nsITimer
> mForceKillTimer
;
871 RefPtr
<ipc::SharedMap
> mSharedData
;
873 RefPtr
<ChildProfilerController
> mProfilerController
;
875 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
876 nsCOMPtr
<nsIFile
> mProfileDir
;
879 // Hashtable to keep track of the pending GetFilesHelper objects.
880 // This GetFilesHelperChild objects are removed when RecvGetFilesResponse is
882 nsRefPtrHashtable
<nsIDHashKey
, GetFilesHelperChild
> mGetFilesPendingRequests
;
884 nsClassHashtable
<nsUint64HashKey
, AnonymousTemporaryFileCallback
>
885 mPendingAnonymousTemporaryFiles
;
887 mozilla::Atomic
<bool> mShuttingDown
;
890 // NOTE: This member is atomic because it can be accessed from
892 mozilla::Atomic
<uint32_t> mPendingInputEvents
;
895 uint32_t mNetworkLinkType
= 0;
897 // See `BrowsingContext::mEpochs` for an explanation of this field.
898 uint64_t mBrowsingContextFieldEpoch
= 0;
900 hal::ProcessPriority mProcessPriority
= hal::PROCESS_PRIORITY_UNKNOWN
;
902 // Session created when the process priority is FOREGROUND to ensure high
903 // priority scheduling of important threads. (Currently main thread and style
904 // threads.) The work duration is reported by the RefreshDriverTimer.
905 UniquePtr
<hal::PerformanceHintSession
> mPerformanceHintSession
;
908 inline nsISupports
* ToSupports(mozilla::dom::ContentChild
* aContentChild
) {
909 return static_cast<nsIDOMProcessChild
*>(aContentChild
);
913 } // namespace mozilla
915 #endif // mozilla_dom_ContentChild_h