Skip to content

Commit

Permalink
bug 1303096 - Stop sending sync messages soon after content process s…
Browse files Browse the repository at this point in the history
…tart-up r=billm
  • Loading branch information
bslassey committed Feb 5, 2017
1 parent b6782eb commit 600308c
Show file tree
Hide file tree
Showing 25 changed files with 734 additions and 294 deletions.
2 changes: 1 addition & 1 deletion caps/DomainPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ CopyURIs(const InfallibleTArray<URIParams>& aDomains, nsIDomainSet* aSet)
}

void
DomainPolicy::ApplyClone(DomainPolicyClone* aClone)
DomainPolicy::ApplyClone(const DomainPolicyClone* aClone)
{
CopyURIs(aClone->blacklist(), mBlacklist);
CopyURIs(aClone->whitelist(), mWhitelist);
Expand Down
3 changes: 2 additions & 1 deletion caps/nsIDomainPolicy.idl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DomainPolicyClone;
%}

[ptr] native DomainPolicyClonePtr(mozilla::dom::DomainPolicyClone);
[ptr] native DomainPolicyCloneConstPtr(const mozilla::dom::DomainPolicyClone);

/*
* When a domain policy is instantiated by invoking activateDomainPolicy() on
Expand All @@ -41,7 +42,7 @@ interface nsIDomainPolicy : nsISupports
void deactivate();

[noscript, notxpcom] void cloneDomainPolicy(in DomainPolicyClonePtr aClone);
[noscript, notxpcom] void applyClone(in DomainPolicyClonePtr aClone);
[noscript, notxpcom] void applyClone(in DomainPolicyCloneConstPtr aClone);
};

[scriptable, builtinclass, uuid(665c981b-0a0f-4229-ac06-a826e02d4f69)]
Expand Down
64 changes: 37 additions & 27 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,24 @@ NS_INTERFACE_MAP_BEGIN(ContentChild)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentChild)
NS_INTERFACE_MAP_END


mozilla::ipc::IPCResult
ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
const StructuredCloneData& aInitialData,
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
{
mLookAndFeelCache = aLookAndFeelIntCache;
InitXPCOM(aXPCOMInit, aInitialData);
InitGraphicsDeviceData();
return IPC_OK();
}

bool
ContentChild::Init(MessageLoop* aIOLoop,
base::ProcessId aParentPid,
IPC::Channel* aChannel)
IPC::Channel* aChannel,
uint64_t aChildID,
bool aIsForBrowser)
{
#ifdef MOZ_WIDGET_GTK
// We need to pass a display down to gtk_init because it's not going to
Expand Down Expand Up @@ -571,7 +585,8 @@ ContentChild::Init(MessageLoop* aIOLoop,
XRE_GetProcessType());
#endif

SendGetProcessAttributes(&mID, &mIsForBrowser);
mID = aChildID;
mIsForBrowser = aIsForBrowser;

#ifdef NS_PRINTING
// Force the creation of the nsPrintingProxy so that it's IPC counterpart,
Expand Down Expand Up @@ -933,8 +948,14 @@ ContentChild::InitGraphicsDeviceData()
}

void
ContentChild::InitXPCOM()
ContentChild::InitXPCOM(const XPCOMInitData& aXPCOMInit,
const mozilla::dom::ipc::StructuredCloneData& aInitialData)
{
SET_PREF_PHASE(pref_initPhase::BEGIN_ALL_PREFS);
for (unsigned int i = 0; i < aXPCOMInit.prefs().Length(); i++) {
Preferences::SetPreference(aXPCOMInit.prefs().ElementAt(i));
}
SET_PREF_PHASE(pref_initPhase::END_ALL_PREFS);
// Do this as early as possible to get the parent process to initialize the
// background thread since we'll likely need database information very soon.
BackgroundChild::Startup();
Expand All @@ -957,42 +978,29 @@ ContentChild::InitXPCOM()
if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
NS_WARNING("Couldn't register console listener for child process");

bool isOffline, isLangRTL, haveBidiKeyboards;
bool isConnected;
int32_t captivePortalState;
ClipboardCapabilities clipboardCaps;
DomainPolicyClone domainPolicy;
StructuredCloneData initialData;
OptionalURIParams userContentSheetURL;

SendGetXPCOMProcessAttributes(&isOffline, &isConnected, &captivePortalState,
&isLangRTL, &haveBidiKeyboards,
&mAvailableDictionaries,
&clipboardCaps, &domainPolicy, &initialData,
&mFontFamilies, &userContentSheetURL,
&mLookAndFeelCache);

RecvSetOffline(isOffline);
RecvSetConnectivity(isConnected);
RecvSetCaptivePortalState(captivePortalState);
RecvBidiKeyboardNotify(isLangRTL, haveBidiKeyboards);
mAvailableDictionaries = aXPCOMInit.dictionaries();

RecvSetOffline(aXPCOMInit.isOffline());
RecvSetConnectivity(aXPCOMInit.isConnected());
RecvSetCaptivePortalState(aXPCOMInit.captivePortalState());
RecvBidiKeyboardNotify(aXPCOMInit.isLangRTL(), aXPCOMInit.haveBidiKeyboards());

// Create the CPOW manager as soon as possible.
SendPJavaScriptConstructor();

if (domainPolicy.active()) {
if (aXPCOMInit.domainPolicy().active()) {
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
MOZ_ASSERT(ssm);
ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
if (!mPolicy) {
MOZ_CRASH("Failed to activate domain policy.");
}
mPolicy->ApplyClone(&domainPolicy);
mPolicy->ApplyClone(&aXPCOMInit.domainPolicy());
}

nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
if (nsCOMPtr<nsIClipboardProxy> clipboardProxy = do_QueryInterface(clipboard)) {
clipboardProxy->SetCapabilities(clipboardCaps);
clipboardProxy->SetCapabilities(aXPCOMInit.clipboardCaps());
}

{
Expand All @@ -1002,7 +1010,9 @@ ContentChild::InitXPCOM()
}
ErrorResult rv;
JS::RootedValue data(jsapi.cx());
initialData.Read(jsapi.cx(), &data, rv);
mozilla::dom::ipc::StructuredCloneData id;
id.Copy(aInitialData);
id.Read(jsapi.cx(), &data, rv);
if (NS_WARN_IF(rv.Failed())) {
MOZ_CRASH();
}
Expand All @@ -1011,7 +1021,7 @@ ContentChild::InitXPCOM()
}

// The stylesheet cache is not ready yet. Store this URL for future use.
nsCOMPtr<nsIURI> ucsURL = DeserializeURI(userContentSheetURL);
nsCOMPtr<nsIURI> ucsURL = DeserializeURI(aXPCOMInit.userContentSheetURL());
nsLayoutStylesheetCache::SetUserContentCSSURL(ucsURL);

// This will register cross-process observer.
Expand Down
12 changes: 10 additions & 2 deletions dom/ipc/ContentChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ class ContentChild final : public PContentChild

bool Init(MessageLoop* aIOLoop,
base::ProcessId aParentPid,
IPC::Channel* aChannel);
IPC::Channel* aChannel,
uint64_t aChildID,
bool aIsForBrowser);

void InitXPCOM();
void InitXPCOM(const XPCOMInitData& aXPCOMInit,
const mozilla::dom::ipc::StructuredCloneData& aInitialData);

void InitGraphicsDeviceData();

Expand Down Expand Up @@ -573,6 +576,11 @@ class ContentChild final : public PContentChild
const bool& minimizeMemoryUsage,
const MaybeFileDesc& DMDFile) override;

virtual mozilla::ipc::IPCResult
RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
const StructuredCloneData& aInitialData,
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override;

#if defined(XP_WIN) && defined(ACCESSIBILITY)
bool
SendGetA11yContentId();
Expand Down
Loading

0 comments on commit 600308c

Please sign in to comment.