Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=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/. */
6 :
7 : #ifndef mozilla_dom_ContentParent_h
8 : #define mozilla_dom_ContentParent_h
9 :
10 : #include "mozilla/dom/PContentParent.h"
11 : #include "mozilla/dom/nsIContentParent.h"
12 : #include "mozilla/gfx/gfxVarReceiver.h"
13 : #include "mozilla/gfx/GPUProcessListener.h"
14 : #include "mozilla/Attributes.h"
15 : #include "mozilla/FileUtils.h"
16 : #include "mozilla/HalTypes.h"
17 : #include "mozilla/LinkedList.h"
18 : #include "mozilla/MemoryReportingProcess.h"
19 : #include "mozilla/StaticPtr.h"
20 : #include "mozilla/TimeStamp.h"
21 : #include "mozilla/UniquePtr.h"
22 :
23 : #include "ContentProcessHost.h"
24 : #include "nsDataHashtable.h"
25 : #include "nsPluginTags.h"
26 : #include "nsFrameMessageManager.h"
27 : #include "nsHashKeys.h"
28 : #include "nsIInterfaceRequestor.h"
29 : #include "nsIObserver.h"
30 : #include "nsIThreadInternal.h"
31 : #include "nsIDOMGeoPositionCallback.h"
32 : #include "nsIDOMGeoPositionErrorCallback.h"
33 : #include "nsRefPtrHashtable.h"
34 : #include "PermissionMessageUtils.h"
35 : #include "DriverCrashGuard.h"
36 :
37 : #define CHILD_PROCESS_SHUTDOWN_MESSAGE NS_LITERAL_STRING("child-process-shutdown")
38 :
39 : // These must match the similar ones in E10SUtils.jsm.
40 : // Process names as reported by about:memory are defined in
41 : // ContentChild:RecvRemoteType. Add your value there too or it will be called
42 : // "Web Content".
43 : #define DEFAULT_REMOTE_TYPE "web"
44 : #define FILE_REMOTE_TYPE "file"
45 : #define EXTENSION_REMOTE_TYPE "extension"
46 :
47 : // This must start with the DEFAULT_REMOTE_TYPE above.
48 : #define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation"
49 :
50 : class nsConsoleService;
51 : class nsIContentProcessInfo;
52 : class nsICycleCollectorLogSink;
53 : class nsIDumpGCAndCCLogsCallback;
54 : class nsITabParent;
55 : class nsITimer;
56 : class ParentIdleListener;
57 : class nsIWidget;
58 :
59 : namespace mozilla {
60 : class PRemoteSpellcheckEngineParent;
61 :
62 : #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
63 : class SandboxBroker;
64 : class SandboxBrokerPolicyFactory;
65 : #endif
66 :
67 : class PreallocatedProcessManagerImpl;
68 :
69 : using mozilla::loader::PScriptCacheParent;
70 :
71 : namespace embedding {
72 : class PrintingParent;
73 : }
74 :
75 : namespace ipc {
76 : class CrashReporterHost;
77 : class OptionalURIParams;
78 : class PFileDescriptorSetParent;
79 : class URIParams;
80 : class TestShellParent;
81 : #ifdef FUZZING
82 : class ProtocolFuzzerHelper;
83 : #endif
84 : } // namespace ipc
85 :
86 : namespace jsipc {
87 : class PJavaScriptParent;
88 : } // namespace jsipc
89 :
90 : namespace layers {
91 : struct TextureFactoryIdentifier;
92 : } // namespace layers
93 :
94 : namespace layout {
95 : class PRenderFrameParent;
96 : } // namespace layout
97 :
98 : namespace dom {
99 :
100 : class Element;
101 : class TabParent;
102 : class ClonedMessageData;
103 : class MemoryReport;
104 : class TabContext;
105 : class ContentBridgeParent;
106 : class GetFilesHelper;
107 : class MemoryReportRequestHost;
108 :
109 : class ContentParent final : public PContentParent
110 : , public nsIContentParent
111 : , public nsIObserver
112 : , public nsIDOMGeoPositionCallback
113 : , public nsIDOMGeoPositionErrorCallback
114 : , public nsIInterfaceRequestor
115 : , public gfx::gfxVarReceiver
116 : , public mozilla::LinkedListElement<ContentParent>
117 : , public gfx::GPUProcessListener
118 : , public mozilla::MemoryReportingProcess
119 : {
120 : typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
121 : typedef mozilla::ipc::PFileDescriptorSetParent PFileDescriptorSetParent;
122 : typedef mozilla::ipc::TestShellParent TestShellParent;
123 : typedef mozilla::ipc::URIParams URIParams;
124 : typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
125 : typedef mozilla::dom::ClonedMessageData ClonedMessageData;
126 :
127 : friend class ContentProcessHost;
128 : friend class mozilla::PreallocatedProcessManagerImpl;
129 : #ifdef FUZZING
130 : friend class mozilla::ipc::ProtocolFuzzerHelper;
131 : #endif
132 :
133 : public:
134 :
135 0 : virtual bool IsContentParent() const override { return true; }
136 :
137 : /**
138 : * Create a subprocess suitable for use later as a content process.
139 : */
140 : static already_AddRefed<ContentParent> PreallocateProcess();
141 :
142 : /**
143 : * Start up the content-process machinery. This might include
144 : * scheduling pre-launch tasks.
145 : */
146 : static void StartUp();
147 :
148 : /** Shut down the content-process machinery. */
149 : static void ShutDown();
150 :
151 : static uint32_t GetPoolSize(const nsAString& aContentProcessType);
152 :
153 : static uint32_t GetMaxProcessCount(const nsAString& aContentProcessType);
154 :
155 : static bool IsMaxProcessCountReached(const nsAString& aContentProcessType);
156 :
157 : static void ReleaseCachedProcesses();
158 :
159 : /**
160 : * Picks a random content parent from |aContentParents| with a given |aOpener|
161 : * respecting the index limit set by |aMaxContentParents|.
162 : * Returns null if non available.
163 : */
164 : static already_AddRefed<ContentParent>
165 : MinTabSelect(const nsTArray<ContentParent*>& aContentParents,
166 : ContentParent* aOpener,
167 : int32_t maxContentParents);
168 :
169 : /**
170 : * Get or create a content process for:
171 : * 1. browser iframe
172 : * 2. remote xul <browser>
173 : * 3. normal iframe
174 : */
175 : static already_AddRefed<ContentParent>
176 : GetNewOrUsedBrowserProcess(const nsAString& aRemoteType,
177 : hal::ProcessPriority aPriority =
178 : hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
179 : ContentParent* aOpener = nullptr,
180 : bool aPreferUsed = false);
181 :
182 : /**
183 : * Get or create a content process for a JS plugin. aPluginID is the id of the JS plugin
184 : * (@see nsFakePlugin::mId). There is a maximum of one process per JS plugin.
185 : */
186 : static already_AddRefed<ContentParent>
187 : GetNewOrUsedJSPluginProcess(uint32_t aPluginID,
188 : const hal::ProcessPriority& aPriority);
189 :
190 : /**
191 : * Get or create a content process for the given TabContext. aFrameElement
192 : * should be the frame/iframe element with which this process will
193 : * associated.
194 : */
195 : static TabParent*
196 : CreateBrowser(const TabContext& aContext,
197 : Element* aFrameElement,
198 : ContentParent* aOpenerContentParent,
199 : TabParent* aSameTabGroupAs,
200 : uint64_t aNextTabParentId);
201 :
202 : static void GetAll(nsTArray<ContentParent*>& aArray);
203 :
204 : static void GetAllEvenIfDead(nsTArray<ContentParent*>& aArray);
205 :
206 : const nsAString& GetRemoteType() const;
207 :
208 0 : virtual void DoGetRemoteType(nsAString& aRemoteType, ErrorResult& aError) const override
209 : {
210 0 : aRemoteType = GetRemoteType();
211 0 : }
212 :
213 : enum CPIteratorPolicy {
214 : eLive,
215 : eAll
216 : };
217 :
218 : class ContentParentIterator {
219 : private:
220 : ContentParent* mCurrent;
221 : CPIteratorPolicy mPolicy;
222 :
223 : public:
224 : ContentParentIterator(CPIteratorPolicy aPolicy, ContentParent* aCurrent)
225 : : mCurrent(aCurrent),
226 : mPolicy(aPolicy)
227 : {
228 : }
229 :
230 2 : ContentParentIterator begin()
231 : {
232 : // Move the cursor to the first element that matches the policy.
233 2 : while (mPolicy != eAll && mCurrent && !mCurrent->mIsAlive) {
234 0 : mCurrent = mCurrent->LinkedListElement<ContentParent>::getNext();
235 : }
236 :
237 2 : return *this;
238 : }
239 : ContentParentIterator end()
240 : {
241 0 : return ContentParentIterator(mPolicy, nullptr);
242 : }
243 :
244 2 : const ContentParentIterator& operator++()
245 : {
246 2 : MOZ_ASSERT(mCurrent);
247 : do {
248 2 : mCurrent = mCurrent->LinkedListElement<ContentParent>::getNext();
249 2 : } while (mPolicy != eAll && mCurrent && !mCurrent->mIsAlive);
250 :
251 2 : return *this;
252 : }
253 :
254 2 : bool operator!=(const ContentParentIterator& aOther)
255 : {
256 2 : MOZ_ASSERT(mPolicy == aOther.mPolicy);
257 2 : return mCurrent != aOther.mCurrent;
258 : }
259 :
260 : ContentParent* operator*()
261 : {
262 : return mCurrent;
263 : }
264 : };
265 :
266 2 : static ContentParentIterator AllProcesses(CPIteratorPolicy aPolicy)
267 : {
268 : ContentParent* first =
269 2 : sContentParents ? sContentParents->getFirst() : nullptr;
270 2 : return ContentParentIterator(aPolicy, first);
271 : }
272 :
273 : static bool IgnoreIPCPrincipal();
274 :
275 : static void NotifyUpdatedDictionaries();
276 :
277 : static void NotifyUpdatedFonts();
278 :
279 : #if defined(XP_WIN)
280 : /**
281 : * Windows helper for firing off an update window request to a plugin
282 : * instance.
283 : *
284 : * aWidget - the eWindowType_plugin_ipc_chrome widget associated with
285 : * this plugin window.
286 : */
287 : static void SendAsyncUpdate(nsIWidget* aWidget);
288 : #endif
289 :
290 : // Let managees query if it is safe to send messages.
291 : bool IsDestroyed() const { return !mIPCOpen; }
292 :
293 : virtual mozilla::ipc::IPCResult RecvCreateChildProcess(const IPCTabContext& aContext,
294 : const hal::ProcessPriority& aPriority,
295 : const TabId& aOpenerTabId,
296 : const TabId& aTabId,
297 : ContentParentId* aCpId,
298 : bool* aIsForBrowser) override;
299 :
300 : virtual mozilla::ipc::IPCResult RecvBridgeToChildProcess(const ContentParentId& aCpId,
301 : Endpoint<PContentBridgeParent>* aEndpoint) override;
302 :
303 : virtual mozilla::ipc::IPCResult RecvCreateGMPService() override;
304 :
305 : virtual mozilla::ipc::IPCResult RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv,
306 : uint32_t* aRunID,
307 : Endpoint<PPluginModuleParent>* aEndpoint) override;
308 :
309 : virtual mozilla::ipc::IPCResult RecvMaybeReloadPlugins() override;
310 :
311 : virtual mozilla::ipc::IPCResult RecvConnectPluginBridge(const uint32_t& aPluginId,
312 : nsresult* aRv,
313 : Endpoint<PPluginModuleParent>* aEndpoint) override;
314 :
315 : virtual mozilla::ipc::IPCResult RecvUngrabPointer(const uint32_t& aTime) override;
316 :
317 : virtual mozilla::ipc::IPCResult RecvRemovePermission(const IPC::Principal& aPrincipal,
318 : const nsCString& aPermissionType,
319 : nsresult* aRv) override;
320 :
321 0 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ContentParent, nsIObserver)
322 :
323 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
324 : NS_DECL_NSIOBSERVER
325 : NS_DECL_NSIDOMGEOPOSITIONCALLBACK
326 : NS_DECL_NSIDOMGEOPOSITIONERRORCALLBACK
327 : NS_DECL_NSIINTERFACEREQUESTOR
328 :
329 : /**
330 : * MessageManagerCallback methods that we override.
331 : */
332 : virtual bool DoLoadMessageManagerScript(const nsAString& aURL,
333 : bool aRunInGlobalScope) override;
334 :
335 : virtual nsresult DoSendAsyncMessage(JSContext* aCx,
336 : const nsAString& aMessage,
337 : StructuredCloneData& aData,
338 : JS::Handle<JSObject *> aCpows,
339 : nsIPrincipal* aPrincipal) override;
340 :
341 : /** Notify that a tab is beginning its destruction sequence. */
342 : static void NotifyTabDestroying(const TabId& aTabId,
343 : const ContentParentId& aCpId);
344 :
345 : /** Notify that a tab was destroyed during normal operation. */
346 : void NotifyTabDestroyed(const TabId& aTabId,
347 : bool aNotifiedDestroying);
348 :
349 : TestShellParent* CreateTestShell();
350 :
351 : bool DestroyTestShell(TestShellParent* aTestShell);
352 :
353 : TestShellParent* GetTestShellSingleton();
354 :
355 : jsipc::CPOWManager* GetCPOWManager() override;
356 :
357 : static void
358 : UnregisterRemoteFrame(const TabId& aTabId,
359 : const ContentParentId& aCpId,
360 : bool aMarkedDestroying);
361 :
362 : void ReportChildAlreadyBlocked();
363 :
364 : bool RequestRunToCompletion();
365 :
366 : void UpdateCookieStatus(nsIChannel *aChannel);
367 :
368 : bool IsAvailable() const
369 : {
370 : return mIsAvailable;
371 : }
372 : bool IsAlive() const override;
373 :
374 : virtual bool IsForBrowser() const override
375 : {
376 : return mIsForBrowser;
377 : }
378 : virtual bool IsForJSPlugin() const override
379 : {
380 : return mJSPluginID != nsFakePluginTag::NOT_JSPLUGIN;
381 : }
382 :
383 : ContentProcessHost* Process() const
384 : {
385 : return mSubprocess;
386 : }
387 :
388 : ContentParent* Opener() const
389 : {
390 : return mOpener;
391 : }
392 : nsIContentProcessInfo* ScriptableHelper() const
393 : {
394 : return mScriptableHelper;
395 : }
396 :
397 : bool NeedsPermissionsUpdate(const nsACString& aPermissionKey) const;
398 :
399 : /**
400 : * Kill our subprocess and make sure it dies. Should only be used
401 : * in emergency situations since it bypasses the normal shutdown
402 : * process.
403 : *
404 : * WARNING: aReason appears in telemetry, so any new value passed in requires
405 : * data review.
406 : */
407 : void KillHard(const char* aWhy);
408 :
409 0 : ContentParentId ChildID() const override { return mChildID; }
410 :
411 : /**
412 : * Get a user-friendly name for this ContentParent. We make no guarantees
413 : * about this name: It might not be unique, apps can spoof special names,
414 : * etc. So please don't use this name to make any decisions about the
415 : * ContentParent based on the value returned here.
416 : */
417 : void FriendlyName(nsAString& aName, bool aAnonymize = false);
418 :
419 : virtual void OnChannelError() override;
420 :
421 : virtual mozilla::ipc::IPCResult
422 : RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) override;
423 :
424 : virtual PNeckoParent* AllocPNeckoParent() override;
425 :
426 : virtual mozilla::ipc::IPCResult RecvPNeckoConstructor(PNeckoParent* aActor) override
427 : {
428 : return PContentParent::RecvPNeckoConstructor(aActor);
429 : }
430 :
431 : virtual PPrintingParent* AllocPPrintingParent() override;
432 :
433 : virtual bool DeallocPPrintingParent(PPrintingParent* aActor) override;
434 :
435 : #if defined(NS_PRINTING)
436 : /**
437 : * @return the PrintingParent for this ContentParent.
438 : */
439 : already_AddRefed<embedding::PrintingParent> GetPrintingParent();
440 : #endif
441 :
442 : virtual mozilla::ipc::IPCResult
443 : RecvInitStreamFilter(const uint64_t& aChannelId,
444 : const nsString& aAddonId,
445 : InitStreamFilterResolver&& aResolver) override;
446 :
447 : virtual PChildToParentStreamParent* AllocPChildToParentStreamParent() override;
448 : virtual bool
449 : DeallocPChildToParentStreamParent(PChildToParentStreamParent* aActor) override;
450 :
451 : virtual PParentToChildStreamParent*
452 : SendPParentToChildStreamConstructor(PParentToChildStreamParent*) override;
453 :
454 : virtual PFileDescriptorSetParent*
455 : SendPFileDescriptorSetConstructor(const FileDescriptor&) override;
456 :
457 : virtual PParentToChildStreamParent* AllocPParentToChildStreamParent() override;
458 : virtual bool
459 : DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor) override;
460 :
461 : virtual PHalParent* AllocPHalParent() override;
462 :
463 : virtual mozilla::ipc::IPCResult RecvPHalConstructor(PHalParent* aActor) override
464 : {
465 : return PContentParent::RecvPHalConstructor(aActor);
466 : }
467 :
468 : virtual PHeapSnapshotTempFileHelperParent*
469 : AllocPHeapSnapshotTempFileHelperParent() override;
470 :
471 : virtual PJavaScriptParent*
472 : AllocPJavaScriptParent() override;
473 :
474 : virtual mozilla::ipc::IPCResult
475 : RecvPJavaScriptConstructor(PJavaScriptParent* aActor) override
476 : {
477 : return PContentParent::RecvPJavaScriptConstructor(aActor);
478 : }
479 :
480 : virtual PRemoteSpellcheckEngineParent* AllocPRemoteSpellcheckEngineParent() override;
481 :
482 : virtual mozilla::ipc::IPCResult RecvRecordingDeviceEvents(const nsString& aRecordingStatus,
483 : const nsString& aPageURL,
484 : const bool& aIsAudio,
485 : const bool& aIsVideo) override;
486 :
487 : bool CycleCollectWithLogs(bool aDumpAllTraces,
488 : nsICycleCollectorLogSink* aSink,
489 : nsIDumpGCAndCCLogsCallback* aCallback);
490 :
491 : virtual mozilla::ipc::IPCResult RecvUnregisterRemoteFrame(const TabId& aTabId,
492 : const ContentParentId& aCpId,
493 : const bool& aMarkedDestroying) override;
494 :
495 : virtual mozilla::ipc::IPCResult RecvNotifyTabDestroying(const TabId& aTabId,
496 : const ContentParentId& aCpId) override;
497 :
498 : nsTArray<TabContext> GetManagedTabContext();
499 :
500 : virtual POfflineCacheUpdateParent*
501 : AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
502 : const URIParams& aDocumentURI,
503 : const PrincipalInfo& aLoadingPrincipalInfo,
504 : const bool& aStickDocument) override;
505 :
506 : virtual mozilla::ipc::IPCResult
507 : RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aActor,
508 : const URIParams& aManifestURI,
509 : const URIParams& aDocumentURI,
510 : const PrincipalInfo& aLoadingPrincipal,
511 : const bool& stickDocument) override;
512 :
513 : virtual bool
514 : DeallocPOfflineCacheUpdateParent(POfflineCacheUpdateParent* aActor) override;
515 :
516 : virtual mozilla::ipc::IPCResult RecvSetOfflinePermission(const IPC::Principal& principal) override;
517 :
518 : virtual mozilla::ipc::IPCResult RecvFinishShutdown() override;
519 :
520 : void MaybeInvokeDragSession(TabParent* aParent);
521 :
522 : virtual PContentPermissionRequestParent*
523 : AllocPContentPermissionRequestParent(const InfallibleTArray<PermissionRequest>& aRequests,
524 : const IPC::Principal& aPrincipal,
525 : const bool& aIsTrusted,
526 : const TabId& aTabId) override;
527 :
528 : virtual bool
529 : DeallocPContentPermissionRequestParent(PContentPermissionRequestParent* actor) override;
530 :
531 : virtual bool HandleWindowsMessages(const Message& aMsg) const override;
532 :
533 : void ForkNewProcess(bool aBlocking);
534 :
535 : virtual mozilla::ipc::IPCResult
536 : RecvCreateWindow(PBrowserParent* aThisTabParent,
537 : PBrowserParent* aNewTab,
538 : layout::PRenderFrameParent* aRenderFrame,
539 : const uint32_t& aChromeFlags,
540 : const bool& aCalledFromJS,
541 : const bool& aPositionSpecified,
542 : const bool& aSizeSpecified,
543 : const OptionalURIParams& aURIToLoad,
544 : const nsCString& aFeatures,
545 : const nsCString& aBaseURI,
546 : const float& aFullZoom,
547 : const IPC::Principal& aTriggeringPrincipal,
548 : const uint32_t& aReferrerPolicy,
549 : CreateWindowResolver&& aResolve) override;
550 :
551 : virtual mozilla::ipc::IPCResult RecvCreateWindowInDifferentProcess(
552 : PBrowserParent* aThisTab,
553 : const uint32_t& aChromeFlags,
554 : const bool& aCalledFromJS,
555 : const bool& aPositionSpecified,
556 : const bool& aSizeSpecified,
557 : const OptionalURIParams& aURIToLoad,
558 : const nsCString& aFeatures,
559 : const nsCString& aBaseURI,
560 : const float& aFullZoom,
561 : const nsString& aName,
562 : const IPC::Principal& aTriggeringPrincipal,
563 : const uint32_t& aReferrerPolicy) override;
564 :
565 : static bool AllocateLayerTreeId(TabParent* aTabParent, layers::LayersId* aId);
566 :
567 : static void
568 : BroadcastBlobURLRegistration(const nsACString& aURI,
569 : BlobImpl* aBlobImpl,
570 : nsIPrincipal* aPrincipal,
571 : ContentParent* aIgnoreThisCP = nullptr);
572 :
573 : static void
574 : BroadcastBlobURLUnregistration(const nsACString& aURI,
575 : ContentParent* aIgnoreThisCP = nullptr);
576 :
577 : virtual mozilla::ipc::IPCResult
578 : RecvStoreAndBroadcastBlobURLRegistration(const nsCString& aURI,
579 : const IPCBlob& aBlob,
580 : const Principal& aPrincipal) override;
581 :
582 : virtual mozilla::ipc::IPCResult
583 : RecvUnstoreAndBroadcastBlobURLUnregistration(const nsCString& aURI) override;
584 :
585 : virtual mozilla::ipc::IPCResult
586 : RecvGetA11yContentId(uint32_t* aContentId) override;
587 :
588 : virtual mozilla::ipc::IPCResult
589 : RecvA11yHandlerControl(const uint32_t& aPid,
590 : const IHandlerControlHolder& aHandlerControl) override;
591 :
592 : virtual int32_t Pid() const override;
593 :
594 : // PURLClassifierParent.
595 : virtual PURLClassifierParent*
596 : AllocPURLClassifierParent(const Principal& aPrincipal,
597 : const bool& aUseTrackingProtection,
598 : bool* aSuccess) override;
599 : virtual mozilla::ipc::IPCResult
600 : RecvPURLClassifierConstructor(PURLClassifierParent* aActor,
601 : const Principal& aPrincipal,
602 : const bool& aUseTrackingProtection,
603 : bool* aSuccess) override;
604 :
605 : // PURLClassifierLocalParent.
606 : virtual PURLClassifierLocalParent*
607 : AllocPURLClassifierLocalParent(const URIParams& aURI,
608 : const nsCString& aTables) override;
609 : virtual mozilla::ipc::IPCResult
610 : RecvPURLClassifierLocalConstructor(PURLClassifierLocalParent* aActor,
611 : const URIParams& aURI,
612 : const nsCString& aTables) override;
613 :
614 : virtual PLoginReputationParent*
615 : AllocPLoginReputationParent(const URIParams& aURI) override;
616 :
617 : virtual mozilla::ipc::IPCResult
618 : RecvPLoginReputationConstructor(PLoginReputationParent* aActor,
619 : const URIParams& aURI) override;
620 :
621 : virtual bool
622 : DeallocPLoginReputationParent(PLoginReputationParent* aActor) override;
623 :
624 0 : virtual bool SendActivate(PBrowserParent* aTab) override
625 : {
626 0 : return PContentParent::SendActivate(aTab);
627 : }
628 :
629 0 : virtual bool SendDeactivate(PBrowserParent* aTab) override
630 : {
631 0 : return PContentParent::SendDeactivate(aTab);
632 : }
633 :
634 : virtual bool
635 : DeallocPURLClassifierLocalParent(PURLClassifierLocalParent* aActor) override;
636 :
637 : virtual bool
638 : DeallocPURLClassifierParent(PURLClassifierParent* aActor) override;
639 :
640 : virtual mozilla::ipc::IPCResult
641 : RecvClassifyLocal(const URIParams& aURI,
642 : const nsCString& aTables,
643 : nsresult* aRv,
644 : nsTArray<nsCString>* aResults) override;
645 :
646 : // Use the PHangMonitor channel to ask the child to repaint a tab.
647 : void PaintTabWhileInterruptingJS(TabParent* aTabParent, bool aForceRepaint, uint64_t aLayerObserverEpoch);
648 :
649 : // This function is called when we are about to load a document from an
650 : // HTTP(S), FTP or wyciwyg channel for a content process. It is a useful
651 : // place to start to kick off work as early as possible in response to such
652 : // document loads.
653 : nsresult AboutToLoadHttpFtpWyciwygDocumentForChild(nsIChannel* aChannel);
654 :
655 : nsresult TransmitPermissionsForPrincipal(nsIPrincipal* aPrincipal);
656 :
657 : void OnCompositorDeviceReset() override;
658 :
659 : virtual PClientOpenWindowOpParent*
660 : AllocPClientOpenWindowOpParent(const ClientOpenWindowArgs& aArgs) override;
661 :
662 : virtual bool
663 : DeallocPClientOpenWindowOpParent(PClientOpenWindowOpParent* aActor) override;
664 :
665 : static hal::ProcessPriority GetInitialProcessPriority(Element* aFrameElement);
666 :
667 : // Control the priority of the IPC messages for input events.
668 : void SetInputPriorityEventEnabled(bool aEnabled);
669 : bool IsInputPriorityEventEnabled()
670 : {
671 : return mIsInputPriorityEventEnabled;
672 : }
673 :
674 : static bool IsInputEventQueueSupported();
675 :
676 : protected:
677 : void OnChannelConnected(int32_t pid) override;
678 :
679 : virtual void ActorDestroy(ActorDestroyReason why) override;
680 :
681 : bool ShouldContinueFromReplyTimeout() override;
682 :
683 : void OnVarChanged(const GfxVarUpdate& aVar) override;
684 : void OnCompositorUnexpectedShutdown() override;
685 :
686 : private:
687 : /**
688 : * A map of the remote content process type to a list of content parents
689 : * currently available to host *new* tabs/frames of that type.
690 : *
691 : * If a content process is identified as troubled or dead, it will be
692 : * removed from this list, but will still be in the sContentParents list for
693 : * the GetAll/GetAllEvenIfDead APIs.
694 : */
695 : static nsClassHashtable<nsStringHashKey, nsTArray<ContentParent*>>* sBrowserContentParents;
696 : static nsTArray<ContentParent*>* sPrivateContent;
697 : static nsDataHashtable<nsUint32HashKey, ContentParent*> *sJSPluginContentParents;
698 : static StaticAutoPtr<LinkedList<ContentParent> > sContentParents;
699 :
700 : static ContentBridgeParent* CreateContentBridgeParent(const TabContext& aContext,
701 : const hal::ProcessPriority& aPriority,
702 : const TabId& aOpenerTabId,
703 : const TabId& aTabId);
704 :
705 : // Hide the raw constructor methods since we don't want client code
706 : // using them.
707 : virtual PBrowserParent* SendPBrowserConstructor(
708 : PBrowserParent* actor,
709 : const TabId& aTabId,
710 : const TabId& aSameTabGroupsAs,
711 : const IPCTabContext& context,
712 : const uint32_t& chromeFlags,
713 : const ContentParentId& aCpId,
714 : const bool& aIsForBrowser) override;
715 : using PContentParent::SendPTestShellConstructor;
716 :
717 : // Set aLoadUri to true to load aURIToLoad and to false to only create the
718 : // window. aURIToLoad should always be provided, if available, to ensure
719 : // compatibility with GeckoView.
720 : mozilla::ipc::IPCResult
721 : CommonCreateWindow(PBrowserParent* aThisTab,
722 : bool aSetOpener,
723 : const uint32_t& aChromeFlags,
724 : const bool& aCalledFromJS,
725 : const bool& aPositionSpecified,
726 : const bool& aSizeSpecified,
727 : nsIURI* aURIToLoad,
728 : const nsCString& aFeatures,
729 : const nsCString& aBaseURI,
730 : const float& aFullZoom,
731 : uint64_t aNextTabParentId,
732 : const nsString& aName,
733 : nsresult& aResult,
734 : nsCOMPtr<nsITabParent>& aNewTabParent,
735 : bool* aWindowIsNew,
736 : nsIPrincipal* aTriggeringPrincipal,
737 : uint32_t aReferrerPolicy,
738 : bool aLoadUri);
739 :
740 0 : FORWARD_SHMEM_ALLOCATOR_TO(PContentParent)
741 :
742 : explicit ContentParent(int32_t aPluginID)
743 : : ContentParent(nullptr, EmptyString(), aPluginID)
744 : {}
745 : ContentParent(ContentParent* aOpener,
746 : const nsAString& aRemoteType)
747 : : ContentParent(aOpener, aRemoteType, nsFakePluginTag::NOT_JSPLUGIN)
748 : {}
749 :
750 : ContentParent(ContentParent* aOpener,
751 : const nsAString& aRemoteType,
752 : int32_t aPluginID);
753 :
754 : // Launch the subprocess and associated initialization.
755 : // Returns false if the process fails to start.
756 : bool LaunchSubprocess(hal::ProcessPriority aInitialPriority = hal::PROCESS_PRIORITY_FOREGROUND);
757 :
758 : // Common initialization after sub process launch.
759 : void InitInternal(ProcessPriority aPriority);
760 :
761 : virtual ~ContentParent();
762 :
763 : void Init();
764 :
765 : // Some information could be sent to content very early, it
766 : // should be send from this function. This function should only be
767 : // called after the process has been transformed to browser.
768 : void ForwardKnownInfo();
769 :
770 : /**
771 : * We might want to reuse barely used content processes if certain criteria are met.
772 : */
773 : bool TryToRecycle();
774 :
775 : /**
776 : * Removing it from the static array so it won't be returned for new tabs in
777 : * GetNewOrUsedBrowserProcess.
778 : */
779 : void RemoveFromList();
780 :
781 : /**
782 : * Decide whether the process should be kept alive even when it would normally
783 : * be shut down, for example when all its tabs are closed.
784 : */
785 : bool ShouldKeepProcessAlive() const;
786 :
787 : /**
788 : * Mark this ContentParent as "troubled". This means that it is still alive,
789 : * but it won't be returned for new tabs in GetNewOrUsedBrowserProcess.
790 : */
791 : void MarkAsTroubled();
792 :
793 : /**
794 : * Mark this ContentParent as dead for the purposes of Get*().
795 : * This method is idempotent.
796 : */
797 : void MarkAsDead();
798 :
799 : /**
800 : * How we will shut down this ContentParent and its subprocess.
801 : */
802 : enum ShutDownMethod
803 : {
804 : // Send a shutdown message and wait for FinishShutdown call back.
805 : SEND_SHUTDOWN_MESSAGE,
806 : // Close the channel ourselves and let the subprocess clean up itself.
807 : CLOSE_CHANNEL,
808 : // Close the channel with error and let the subprocess clean up itself.
809 : CLOSE_CHANNEL_WITH_ERROR,
810 : };
811 :
812 : /**
813 : * Exit the subprocess and vamoose. After this call IsAlive()
814 : * will return false and this ContentParent will not be returned
815 : * by the Get*() funtions. However, the shutdown sequence itself
816 : * may be asynchronous.
817 : *
818 : * If aMethod is CLOSE_CHANNEL_WITH_ERROR and this is the first call
819 : * to ShutDownProcess, then we'll close our channel using CloseWithError()
820 : * rather than vanilla Close(). CloseWithError() indicates to IPC that this
821 : * is an abnormal shutdown (e.g. a crash).
822 : */
823 : void ShutDownProcess(ShutDownMethod aMethod);
824 :
825 : // Perform any steps necesssary to gracefully shtudown the message
826 : // manager and null out mMessageManager.
827 : void ShutDownMessageManager();
828 :
829 : // Start the force-kill timer on shutdown.
830 : void StartForceKillTimer();
831 :
832 : void OnGenerateMinidumpComplete(bool aDumpResult);
833 :
834 : // Ensure that the permissions for the giben Permission key are set in the
835 : // content process.
836 : //
837 : // See nsIPermissionManager::GetPermissionsForKey for more information on
838 : // these keys.
839 : void EnsurePermissionsByKey(const nsCString& aKey);
840 :
841 : static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
842 :
843 : static bool AllocateLayerTreeId(ContentParent* aContent,
844 : TabParent* aTopLevel, const TabId& aTabId,
845 : layers::LayersId* aId);
846 :
847 : /**
848 : * Get or create the corresponding content parent array to |aContentProcessType|.
849 : */
850 : static nsTArray<ContentParent*>& GetOrCreatePool(const nsAString& aContentProcessType);
851 :
852 : virtual mozilla::ipc::IPCResult RecvInitBackground(Endpoint<mozilla::ipc::PBackgroundParent>&& aEndpoint) override;
853 :
854 : mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport) override;
855 : mozilla::ipc::IPCResult RecvFinishMemoryReport(const uint32_t& aGeneration) override;
856 : mozilla::ipc::IPCResult RecvAddPerformanceMetrics(nsTArray<PerformanceInfo>&& aMetrics) override;
857 :
858 : virtual bool
859 : DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
860 :
861 : virtual bool
862 : DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent*) override;
863 :
864 : virtual PBrowserParent* AllocPBrowserParent(const TabId& aTabId,
865 : const TabId& aSameTabGroupAs,
866 : const IPCTabContext& aContext,
867 : const uint32_t& aChromeFlags,
868 : const ContentParentId& aCpId,
869 : const bool& aIsForBrowser) override;
870 :
871 : virtual bool DeallocPBrowserParent(PBrowserParent* frame) override;
872 :
873 : virtual mozilla::ipc::IPCResult
874 : RecvPBrowserConstructor(PBrowserParent* actor,
875 : const TabId& tabId,
876 : const TabId& sameTabGroupAs,
877 : const IPCTabContext& context,
878 : const uint32_t& chromeFlags,
879 : const ContentParentId& cpId,
880 : const bool& isForBrowser) override;
881 :
882 : virtual PIPCBlobInputStreamParent*
883 : SendPIPCBlobInputStreamConstructor(PIPCBlobInputStreamParent* aActor,
884 : const nsID& aID,
885 : const uint64_t& aSize) override;
886 :
887 : virtual PIPCBlobInputStreamParent*
888 : AllocPIPCBlobInputStreamParent(const nsID& aID,
889 : const uint64_t& aSize) override;
890 :
891 : virtual bool
892 : DeallocPIPCBlobInputStreamParent(PIPCBlobInputStreamParent* aActor) override;
893 :
894 : virtual mozilla::ipc::IPCResult RecvIsSecureURI(const uint32_t& aType, const URIParams& aURI,
895 : const uint32_t& aFlags,
896 : const OriginAttributes& aOriginAttributes,
897 : bool* aIsSecureURI) override;
898 :
899 : virtual mozilla::ipc::IPCResult RecvAccumulateMixedContentHSTS(const URIParams& aURI,
900 : const bool& aActive,
901 : const OriginAttributes& aOriginAttributes) override;
902 :
903 : virtual bool DeallocPHalParent(PHalParent*) override;
904 :
905 : virtual bool
906 : DeallocPHeapSnapshotTempFileHelperParent(PHeapSnapshotTempFileHelperParent*) override;
907 :
908 : virtual PCycleCollectWithLogsParent*
909 : AllocPCycleCollectWithLogsParent(const bool& aDumpAllTraces,
910 : const FileDescriptor& aGCLog,
911 : const FileDescriptor& aCCLog) override;
912 :
913 : virtual bool
914 : DeallocPCycleCollectWithLogsParent(PCycleCollectWithLogsParent* aActor) override;
915 :
916 : virtual PTestShellParent* AllocPTestShellParent() override;
917 :
918 : virtual bool DeallocPTestShellParent(PTestShellParent* shell) override;
919 :
920 : virtual PScriptCacheParent*
921 : AllocPScriptCacheParent(const FileDescOrError& cacheFile,
922 : const bool& wantCacheData) override;
923 :
924 : virtual bool DeallocPScriptCacheParent(PScriptCacheParent* shell) override;
925 :
926 : virtual bool DeallocPNeckoParent(PNeckoParent* necko) override;
927 :
928 : virtual PPSMContentDownloaderParent*
929 : AllocPPSMContentDownloaderParent(const uint32_t& aCertType) override;
930 :
931 : virtual bool
932 : DeallocPPSMContentDownloaderParent(PPSMContentDownloaderParent* aDownloader) override;
933 :
934 : virtual PExternalHelperAppParent*
935 : AllocPExternalHelperAppParent(const OptionalURIParams& aUri,
936 : const nsCString& aMimeContentType,
937 : const nsCString& aContentDisposition,
938 : const uint32_t& aContentDispositionHint,
939 : const nsString& aContentDispositionFilename,
940 : const bool& aForceSave,
941 : const int64_t& aContentLength,
942 : const bool& aWasFileChannel,
943 : const OptionalURIParams& aReferrer,
944 : PBrowserParent* aBrowser) override;
945 :
946 : virtual bool
947 : DeallocPExternalHelperAppParent(PExternalHelperAppParent* aService) override;
948 :
949 : virtual PHandlerServiceParent* AllocPHandlerServiceParent() override;
950 :
951 : virtual bool DeallocPHandlerServiceParent(PHandlerServiceParent*) override;
952 :
953 : virtual PMediaParent* AllocPMediaParent() override;
954 :
955 : virtual bool DeallocPMediaParent(PMediaParent* aActor) override;
956 :
957 : virtual PPresentationParent* AllocPPresentationParent() override;
958 :
959 : virtual bool DeallocPPresentationParent(PPresentationParent* aActor) override;
960 :
961 : virtual mozilla::ipc::IPCResult RecvPPresentationConstructor(PPresentationParent* aActor) override;
962 :
963 : virtual PSpeechSynthesisParent* AllocPSpeechSynthesisParent() override;
964 :
965 : virtual bool
966 : DeallocPSpeechSynthesisParent(PSpeechSynthesisParent* aActor) override;
967 :
968 : virtual mozilla::ipc::IPCResult
969 : RecvPSpeechSynthesisConstructor(PSpeechSynthesisParent* aActor) override;
970 :
971 : virtual PWebBrowserPersistDocumentParent*
972 : AllocPWebBrowserPersistDocumentParent(PBrowserParent* aBrowser,
973 : const uint64_t& aOuterWindowID) override;
974 :
975 : virtual bool
976 : DeallocPWebBrowserPersistDocumentParent(PWebBrowserPersistDocumentParent* aActor) override;
977 :
978 : virtual mozilla::ipc::IPCResult RecvGetGfxVars(InfallibleTArray<GfxVarUpdate>* aVars) override;
979 :
980 : virtual mozilla::ipc::IPCResult RecvReadFontList(InfallibleTArray<FontListEntry>* retValue) override;
981 :
982 : virtual mozilla::ipc::IPCResult RecvSetClipboard(const IPCDataTransfer& aDataTransfer,
983 : const bool& aIsPrivateData,
984 : const IPC::Principal& aRequestingPrincipal,
985 : const uint32_t& aContentPolicyType,
986 : const int32_t& aWhichClipboard) override;
987 :
988 : virtual mozilla::ipc::IPCResult RecvGetClipboard(nsTArray<nsCString>&& aTypes,
989 : const int32_t& aWhichClipboard,
990 : IPCDataTransfer* aDataTransfer) override;
991 :
992 : virtual mozilla::ipc::IPCResult RecvEmptyClipboard(const int32_t& aWhichClipboard) override;
993 :
994 : virtual mozilla::ipc::IPCResult RecvClipboardHasType(nsTArray<nsCString>&& aTypes,
995 : const int32_t& aWhichClipboard,
996 : bool* aHasType) override;
997 :
998 : virtual mozilla::ipc::IPCResult RecvPlaySound(const URIParams& aURI) override;
999 : virtual mozilla::ipc::IPCResult RecvBeep() override;
1000 : virtual mozilla::ipc::IPCResult RecvPlayEventSound(const uint32_t& aEventId) override;
1001 :
1002 : virtual mozilla::ipc::IPCResult RecvGetSystemColors(const uint32_t& colorsCount,
1003 : InfallibleTArray<uint32_t>* colors) override;
1004 :
1005 : virtual mozilla::ipc::IPCResult RecvGetIconForExtension(const nsCString& aFileExt,
1006 : const uint32_t& aIconSize,
1007 : InfallibleTArray<uint8_t>* bits) override;
1008 :
1009 : virtual mozilla::ipc::IPCResult RecvGetShowPasswordSetting(bool* showPassword) override;
1010 :
1011 : virtual mozilla::ipc::IPCResult RecvStartVisitedQuery(const URIParams& uri) override;
1012 :
1013 : virtual mozilla::ipc::IPCResult RecvVisitURI(const URIParams& uri,
1014 : const OptionalURIParams& referrer,
1015 : const uint32_t& flags) override;
1016 :
1017 : virtual mozilla::ipc::IPCResult RecvSetURITitle(const URIParams& uri,
1018 : const nsString& title) override;
1019 :
1020 : bool HasNotificationPermission(const IPC::Principal& aPrincipal);
1021 :
1022 : virtual mozilla::ipc::IPCResult RecvShowAlert(nsIAlertNotification* aAlert) override;
1023 :
1024 : virtual mozilla::ipc::IPCResult RecvCloseAlert(const nsString& aName,
1025 : const IPC::Principal& aPrincipal) override;
1026 :
1027 : virtual mozilla::ipc::IPCResult RecvDisableNotifications(const IPC::Principal& aPrincipal) override;
1028 :
1029 : virtual mozilla::ipc::IPCResult RecvOpenNotificationSettings(const IPC::Principal& aPrincipal) override;
1030 :
1031 : virtual mozilla::ipc::IPCResult RecvLoadURIExternal(const URIParams& uri,
1032 : PBrowserParent* windowContext) override;
1033 : virtual mozilla::ipc::IPCResult RecvExtProtocolChannelConnectParent(const uint32_t& registrarId) override;
1034 :
1035 : virtual mozilla::ipc::IPCResult RecvSyncMessage(const nsString& aMsg,
1036 : const ClonedMessageData& aData,
1037 : InfallibleTArray<CpowEntry>&& aCpows,
1038 : const IPC::Principal& aPrincipal,
1039 : nsTArray<StructuredCloneData>* aRetvals) override;
1040 :
1041 : virtual mozilla::ipc::IPCResult RecvRpcMessage(const nsString& aMsg,
1042 : const ClonedMessageData& aData,
1043 : InfallibleTArray<CpowEntry>&& aCpows,
1044 : const IPC::Principal& aPrincipal,
1045 : nsTArray<StructuredCloneData>* aRetvals) override;
1046 :
1047 : virtual mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMsg,
1048 : InfallibleTArray<CpowEntry>&& aCpows,
1049 : const IPC::Principal& aPrincipal,
1050 : const ClonedMessageData& aData) override;
1051 :
1052 : virtual mozilla::ipc::IPCResult RecvAddGeolocationListener(const IPC::Principal& aPrincipal,
1053 : const bool& aHighAccuracy) override;
1054 : virtual mozilla::ipc::IPCResult RecvRemoveGeolocationListener() override;
1055 :
1056 : virtual mozilla::ipc::IPCResult RecvSetGeolocationHigherAccuracy(const bool& aEnable) override;
1057 :
1058 : virtual mozilla::ipc::IPCResult RecvConsoleMessage(const nsString& aMessage) override;
1059 :
1060 : virtual mozilla::ipc::IPCResult RecvScriptError(const nsString& aMessage,
1061 : const nsString& aSourceName,
1062 : const nsString& aSourceLine,
1063 : const uint32_t& aLineNumber,
1064 : const uint32_t& aColNumber,
1065 : const uint32_t& aFlags,
1066 : const nsCString& aCategory,
1067 : const bool& aIsFromPrivateWindow) override;
1068 :
1069 : virtual mozilla::ipc::IPCResult RecvScriptErrorWithStack(const nsString& aMessage,
1070 : const nsString& aSourceName,
1071 : const nsString& aSourceLine,
1072 : const uint32_t& aLineNumber,
1073 : const uint32_t& aColNumber,
1074 : const uint32_t& aFlags,
1075 : const nsCString& aCategory,
1076 : const bool& aIsFromPrivateWindow,
1077 : const ClonedMessageData& aStack) override;
1078 :
1079 : private:
1080 : mozilla::ipc::IPCResult RecvScriptErrorInternal(const nsString& aMessage,
1081 : const nsString& aSourceName,
1082 : const nsString& aSourceLine,
1083 : const uint32_t& aLineNumber,
1084 : const uint32_t& aColNumber,
1085 : const uint32_t& aFlags,
1086 : const nsCString& aCategory,
1087 : const bool& aIsFromPrivateWindow,
1088 : const ClonedMessageData* aStack = nullptr);
1089 :
1090 : public:
1091 : virtual mozilla::ipc::IPCResult RecvPrivateDocShellsExist(const bool& aExist) override;
1092 :
1093 : virtual mozilla::ipc::IPCResult RecvFirstIdle() override;
1094 :
1095 : virtual mozilla::ipc::IPCResult RecvDeviceReset() override;
1096 :
1097 : virtual mozilla::ipc::IPCResult RecvKeywordToURI(const nsCString& aKeyword,
1098 : nsString* aProviderName,
1099 : RefPtr<nsIInputStream>* aPostData,
1100 : OptionalURIParams* aURI) override;
1101 :
1102 : virtual mozilla::ipc::IPCResult RecvNotifyKeywordSearchLoading(const nsString &aProvider,
1103 : const nsString &aKeyword) override;
1104 :
1105 : virtual mozilla::ipc::IPCResult RecvCopyFavicon(const URIParams& aOldURI,
1106 : const URIParams& aNewURI,
1107 : const IPC::Principal& aLoadingPrincipal,
1108 : const bool& aInPrivateBrowsing) override;
1109 :
1110 : virtual void ProcessingError(Result aCode, const char* aMsgName) override;
1111 :
1112 : virtual mozilla::ipc::IPCResult RecvAllocateLayerTreeId(const ContentParentId& aCpId,
1113 : const TabId& aTabId,
1114 : layers::LayersId* aId) override;
1115 :
1116 : virtual mozilla::ipc::IPCResult RecvDeallocateLayerTreeId(const ContentParentId& aCpId,
1117 : const layers::LayersId& aId) override;
1118 :
1119 : virtual mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
1120 :
1121 : virtual mozilla::ipc::IPCResult
1122 : RecvBeginDriverCrashGuard(const uint32_t& aGuardType,
1123 : bool* aOutCrashed) override;
1124 :
1125 : virtual mozilla::ipc::IPCResult RecvEndDriverCrashGuard(const uint32_t& aGuardType) override;
1126 :
1127 : virtual mozilla::ipc::IPCResult RecvAddIdleObserver(const uint64_t& observerId,
1128 : const uint32_t& aIdleTimeInS) override;
1129 :
1130 : virtual mozilla::ipc::IPCResult RecvRemoveIdleObserver(const uint64_t& observerId,
1131 : const uint32_t& aIdleTimeInS) override;
1132 :
1133 : virtual mozilla::ipc::IPCResult
1134 : RecvBackUpXResources(const FileDescriptor& aXSocketFd) override;
1135 :
1136 : virtual mozilla::ipc::IPCResult
1137 : RecvRequestAnonymousTemporaryFile(const uint64_t& aID) override;
1138 :
1139 : virtual mozilla::ipc::IPCResult
1140 : RecvCreateAudioIPCConnection(CreateAudioIPCConnectionResolver&& aResolver) override;
1141 :
1142 : virtual mozilla::ipc::IPCResult
1143 : RecvKeygenProcessValue(const nsString& oldValue, const nsString& challenge,
1144 : const nsString& keytype, const nsString& keyparams,
1145 : nsString* newValue) override;
1146 :
1147 : virtual mozilla::ipc::IPCResult
1148 : RecvKeygenProvideContent(nsString* aAttribute,
1149 : nsTArray<nsString>* aContent) override;
1150 :
1151 : virtual PFileDescriptorSetParent*
1152 : AllocPFileDescriptorSetParent(const mozilla::ipc::FileDescriptor&) override;
1153 :
1154 : virtual bool
1155 : DeallocPFileDescriptorSetParent(PFileDescriptorSetParent*) override;
1156 :
1157 : virtual PWebrtcGlobalParent* AllocPWebrtcGlobalParent() override;
1158 : virtual bool DeallocPWebrtcGlobalParent(PWebrtcGlobalParent *aActor) override;
1159 :
1160 :
1161 : virtual mozilla::ipc::IPCResult RecvUpdateDropEffect(const uint32_t& aDragAction,
1162 : const uint32_t& aDropEffect) override;
1163 :
1164 : virtual mozilla::ipc::IPCResult RecvShutdownProfile(const nsCString& aProfile) override;
1165 :
1166 : virtual mozilla::ipc::IPCResult RecvGetGraphicsDeviceInitData(ContentDeviceData* aOut) override;
1167 :
1168 : virtual mozilla::ipc::IPCResult RecvGetAndroidSystemInfo(AndroidSystemInfo* aInfo) override;
1169 :
1170 : virtual mozilla::ipc::IPCResult RecvNotifyBenchmarkResult(const nsString& aCodecName,
1171 : const uint32_t& aDecodeFPS) override;
1172 :
1173 : virtual mozilla::ipc::IPCResult RecvNotifyPushObservers(const nsCString& aScope,
1174 : const IPC::Principal& aPrincipal,
1175 : const nsString& aMessageId) override;
1176 :
1177 : virtual mozilla::ipc::IPCResult RecvNotifyPushObserversWithData(const nsCString& aScope,
1178 : const IPC::Principal& aPrincipal,
1179 : const nsString& aMessageId,
1180 : InfallibleTArray<uint8_t>&& aData) override;
1181 :
1182 : virtual mozilla::ipc::IPCResult RecvNotifyPushSubscriptionChangeObservers(const nsCString& aScope,
1183 : const IPC::Principal& aPrincipal) override;
1184 :
1185 : virtual mozilla::ipc::IPCResult RecvNotifyPushSubscriptionModifiedObservers(const nsCString& aScope,
1186 : const IPC::Principal& aPrincipal) override;
1187 :
1188 : virtual mozilla::ipc::IPCResult RecvNotifyLowMemory() override;
1189 :
1190 : virtual mozilla::ipc::IPCResult RecvGetFilesRequest(const nsID& aID,
1191 : const nsString& aDirectoryPath,
1192 : const bool& aRecursiveFlag) override;
1193 :
1194 : virtual mozilla::ipc::IPCResult RecvDeleteGetFilesRequest(const nsID& aID) override;
1195 :
1196 : virtual mozilla::ipc::IPCResult
1197 : RecvFileCreationRequest(const nsID& aID, const nsString& aFullPath,
1198 : const nsString& aType, const nsString& aName,
1199 : const bool& aLastModifiedPassed,
1200 : const int64_t& aLastModified,
1201 : const bool& aExistenceCheck,
1202 : const bool& aIsFromNsIFile) override;
1203 :
1204 : virtual mozilla::ipc::IPCResult RecvAccumulateChildHistograms(
1205 : InfallibleTArray<HistogramAccumulation>&& aAccumulations) override;
1206 : virtual mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistograms(
1207 : InfallibleTArray<KeyedHistogramAccumulation>&& aAccumulations) override;
1208 : virtual mozilla::ipc::IPCResult RecvUpdateChildScalars(
1209 : InfallibleTArray<ScalarAction>&& aScalarActions) override;
1210 : virtual mozilla::ipc::IPCResult RecvUpdateChildKeyedScalars(
1211 : InfallibleTArray<KeyedScalarAction>&& aScalarActions) override;
1212 : virtual mozilla::ipc::IPCResult RecvRecordChildEvents(
1213 : nsTArray<ChildEventData>&& events) override;
1214 : virtual mozilla::ipc::IPCResult RecvRecordDiscardedData(
1215 : const DiscardedData& aDiscardedData) override;
1216 :
1217 : virtual mozilla::ipc::IPCResult RecvBHRThreadHang(
1218 : const HangDetails& aHangDetails) override;
1219 :
1220 : // Notify the ContentChild to enable the input event prioritization when
1221 : // initializing.
1222 : void MaybeEnableRemoteInputEventQueue();
1223 :
1224 : public:
1225 : void SendGetFilesResponseAndForget(const nsID& aID,
1226 : const GetFilesResponseResult& aResult);
1227 :
1228 : bool SendRequestMemoryReport(const uint32_t& aGeneration,
1229 : const bool& aAnonymize,
1230 : const bool& aMinimizeMemoryUsage,
1231 : const MaybeFileDesc& aDMDFile) override;
1232 :
1233 : bool CanCommunicateWith(ContentParentId aOtherProcess);
1234 :
1235 : private:
1236 :
1237 : // If you add strong pointers to cycle collected objects here, be sure to
1238 : // release these objects in ShutDownProcess. See the comment there for more
1239 : // details.
1240 :
1241 : ContentProcessHost* mSubprocess;
1242 : const TimeStamp mLaunchTS; // used to calculate time to start content process
1243 : TimeStamp mActivateTS;
1244 : ContentParent* mOpener;
1245 :
1246 : nsString mRemoteType;
1247 :
1248 : ContentParentId mChildID;
1249 : int32_t mGeolocationWatchID;
1250 :
1251 : // This contains the id for the JS plugin (@see nsFakePluginTag) if this is the
1252 : // ContentParent for a process containing iframes for that JS plugin.
1253 : // If this is not a ContentParent for a JS plugin then it contains the value
1254 : // nsFakePluginTag::NOT_JSPLUGIN.
1255 : int32_t mJSPluginID;
1256 :
1257 : nsCString mKillHardAnnotation;
1258 :
1259 : // After we initiate shutdown, we also start a timer to ensure
1260 : // that even content processes that are 100% blocked (say from
1261 : // SIGSTOP), are still killed eventually. This task enforces that
1262 : // timer.
1263 : nsCOMPtr<nsITimer> mForceKillTimer;
1264 : // How many tabs we're waiting to finish their destruction
1265 : // sequence. Precisely, how many TabParents have called
1266 : // NotifyTabDestroying() but not called NotifyTabDestroyed().
1267 : int32_t mNumDestroyingTabs;
1268 : // True only while this process is in "good health" and may be used for
1269 : // new remote tabs.
1270 : bool mIsAvailable;
1271 : // True only while remote content is being actively used from this process.
1272 : // After mIsAlive goes to false, some previously scheduled IPC traffic may
1273 : // still pass through.
1274 : bool mIsAlive;
1275 :
1276 : bool mIsForBrowser;
1277 :
1278 : // These variables track whether we've called Close() and KillHard() on our
1279 : // channel.
1280 : bool mCalledClose;
1281 : bool mCalledKillHard;
1282 : bool mCreatedPairedMinidumps;
1283 : bool mShutdownPending;
1284 : bool mIPCOpen;
1285 :
1286 : // True if the input event queue on the main thread of the content process is
1287 : // enabled.
1288 : bool mIsRemoteInputEventQueueEnabled;
1289 :
1290 : // True if we send input events with input priority. Otherwise, we send input
1291 : // events with normal priority.
1292 : bool mIsInputPriorityEventEnabled;
1293 :
1294 : RefPtr<nsConsoleService> mConsoleService;
1295 : nsConsoleService* GetConsoleService();
1296 : nsCOMPtr<nsIContentProcessInfo> mScriptableHelper;
1297 :
1298 : nsTArray<nsCOMPtr<nsIObserver>> mIdleListeners;
1299 :
1300 : #ifdef MOZ_X11
1301 : // Dup of child's X socket, used to scope its resources to this
1302 : // object instead of the child process's lifetime.
1303 : ScopedClose mChildXSocketFdDup;
1304 : #endif
1305 :
1306 : PProcessHangMonitorParent* mHangMonitorActor;
1307 :
1308 : UniquePtr<gfx::DriverCrashGuard> mDriverCrashGuard;
1309 : UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;
1310 :
1311 : #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
1312 : mozilla::UniquePtr<SandboxBroker> mSandboxBroker;
1313 : static mozilla::UniquePtr<SandboxBrokerPolicyFactory>
1314 : sSandboxBrokerPolicyFactory;
1315 : #endif
1316 :
1317 : #ifdef NS_PRINTING
1318 : RefPtr<embedding::PrintingParent> mPrintingParent;
1319 : #endif
1320 :
1321 : // This hashtable is used to run GetFilesHelper objects in the parent process.
1322 : // GetFilesHelper can be aborted by receiving RecvDeleteGetFilesRequest.
1323 : nsRefPtrHashtable<nsIDHashKey, GetFilesHelper> mGetFilesPendingRequests;
1324 :
1325 : nsTHashtable<nsCStringHashKey> mActivePermissionKeys;
1326 :
1327 : nsTArray<nsCString> mBlobURLs;
1328 :
1329 : UniquePtr<mozilla::ipc::CrashReporterHost> mCrashReporter;
1330 :
1331 : static uint64_t sNextTabParentId;
1332 : static nsDataHashtable<nsUint64HashKey, TabParent*> sNextTabParents;
1333 : };
1334 :
1335 : } // namespace dom
1336 : } // namespace mozilla
1337 :
1338 : class ParentIdleListener : public nsIObserver
1339 : {
1340 : friend class mozilla::dom::ContentParent;
1341 :
1342 : public:
1343 : NS_DECL_ISUPPORTS
1344 : NS_DECL_NSIOBSERVER
1345 :
1346 : ParentIdleListener(mozilla::dom::ContentParent* aParent,
1347 : uint64_t aObserver, uint32_t aTime)
1348 : : mParent(aParent), mObserver(aObserver), mTime(aTime)
1349 : {}
1350 :
1351 : private:
1352 : virtual ~ParentIdleListener() {}
1353 :
1354 : RefPtr<mozilla::dom::ContentParent> mParent;
1355 : uint64_t mObserver;
1356 : uint32_t mTime;
1357 : };
1358 :
1359 : #endif // mozilla_dom_ContentParent_h
|