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