Bug 1318764 - Get rid of GetLookAndFeelCache sync IPC message, and send cache with GetXPCOMProcessAttributes instead. r=billm
authorMike Conley <mconley@mozilla.com>
Fri, 18 Nov 2016 15:36:18 -0500
changeset 324008 fec5699c5c50186f4aa9552ce9cf4829642a022f
parent 324004 34fce7c12173bdd6dda54c2ebf6d344252f1ac48
child 324009 b6beaa7870434c26a52d5868dfd6914862f3820c
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbillm
bugs1318764
milestone53.0a1
Bug 1318764 - Get rid of GetLookAndFeelCache sync IPC message, and send cache with GetXPCOMProcessAttributes instead. r=billm MozReview-Commit-ID: 7BzG2WqNYLO
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
widget/nsXPLookAndFeel.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -917,17 +917,19 @@ ContentChild::InitXPCOM()
   DomainPolicyClone domainPolicy;
   StructuredCloneData initialData;
   OptionalURIParams userContentSheetURL;
 
   SendGetXPCOMProcessAttributes(&isOffline, &isConnected, &captivePortalState,
                                 &isLangRTL, &haveBidiKeyboards,
                                 &mAvailableDictionaries,
                                 &clipboardCaps, &domainPolicy, &initialData,
-                                &mFontFamilies, &userContentSheetURL);
+                                &mFontFamilies, &userContentSheetURL,
+                                &mLookAndFeelCache);
+
   RecvSetOffline(isOffline);
   RecvSetConnectivity(isConnected);
   RecvSetCaptivePortalState(captivePortalState);
   RecvBidiKeyboardNotify(isLangRTL, haveBidiKeyboards);
 
   // Create the CPOW manager as soon as possible.
   SendPJavaScriptConstructor();
 
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -26,16 +26,17 @@
 #endif
 
 struct ChromePackage;
 class nsIObserver;
 struct SubstitutionMapping;
 struct OverrideMapping;
 class nsIDomainPolicy;
 class nsIURIClassifierCallback;
+struct LookAndFeelInt;
 
 namespace mozilla {
 class RemoteSpellcheckEngineChild;
 
 namespace ipc {
 class OptionalURIParams;
 class URIParams;
 }// namespace ipc
@@ -616,16 +617,21 @@ public:
 
   virtual PURLClassifierChild*
   AllocPURLClassifierChild(const Principal& aPrincipal,
                            const bool& aUseTrackingProtection,
                            bool* aSuccess) override;
   virtual bool
   DeallocPURLClassifierChild(PURLClassifierChild* aActor) override;
 
+  nsTArray<LookAndFeelInt>&
+  LookAndFeelCache() {
+    return mLookAndFeelCache;
+  }
+
   /**
    * Helper function for protocols that use the GPU process when available.
    * Overrides FatalError to just be a warning when communicating with the
    * GPU process since we don't want to crash the content process when the
    * GPU process crashes.
    */
   static void FatalErrorIfNotUsingGPUProcess(const char* const aProtocolName,
                                              const char* const aErrorMsg,
@@ -645,16 +651,18 @@ private:
   nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
 
   InfallibleTArray<nsString> mAvailableDictionaries;
 
   // Temporary storage for a list of available font families, passed from the
   // parent process and used to initialize gfx in the child. Currently used
   // only on MacOSX.
   InfallibleTArray<mozilla::dom::FontFamilyListEntry> mFontFamilies;
+  // Temporary storage for nsXPLookAndFeel flags.
+  nsTArray<LookAndFeelInt> mLookAndFeelCache;
 
   /**
    * An ID unique to the process containing our corresponding
    * content parent.
    *
    * We expect our content parent to set this ID immediately after opening a
    * channel to us.
    */
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2474,17 +2474,18 @@ ContentParent::RecvGetXPCOMProcessAttrib
                                              int32_t* aCaptivePortalState,
                                              bool* aIsLangRTL,
                                              bool* aHaveBidiKeyboards,
                                              InfallibleTArray<nsString>* dictionaries,
                                              ClipboardCapabilities* clipboardCaps,
                                              DomainPolicyClone* domainPolicy,
                                              StructuredCloneData* aInitialData,
                                              InfallibleTArray<FontFamilyListEntry>* fontFamilies,
-                                             OptionalURIParams* aUserContentCSSURL)
+                                             OptionalURIParams* aUserContentCSSURL,
+                                             nsTArray<LookAndFeelInt>* aLookAndFeelIntCache)
 {
   nsCOMPtr<nsIIOService> io(do_GetIOService());
   MOZ_ASSERT(io, "No IO service?");
   DebugOnly<nsresult> rv = io->GetOffline(aIsOffline);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting offline?");
 
   rv = io->GetConnectivity(aIsConnected);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting connectivity?");
@@ -2539,16 +2540,17 @@ ContentParent::RecvGetXPCOMProcessAttrib
     if (NS_WARN_IF(rv.Failed())) {
       rv.SuppressException();
       return IPC_FAIL_NO_REASON(this);
     }
   }
 
   // This is only implemented (returns a non-empty list) by MacOSX at present.
   gfxPlatform::GetPlatform()->GetSystemFontFamilyList(fontFamilies);
+  *aLookAndFeelIntCache = LookAndFeel::GetIntCache();
 
   // Content processes have no permission to access profile directory, so we
   // send the file URL instead.
   StyleSheet* ucs = nsLayoutStylesheetCache::For(StyleBackendType::Gecko)->UserContentSheet();
   if (ucs) {
     SerializeURI(ucs->GetSheetURI(), *aUserContentCSSURL);
   } else {
     SerializeURI(nullptr, *aUserContentCSSURL);
@@ -3231,23 +3233,16 @@ ContentParent::RecvNSSU2FTokenSign(nsTAr
   free(buffer);
   if (NS_FAILED(rv)) {
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-ContentParent::RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>* aLookAndFeelIntCache)
-{
-  *aLookAndFeelIntCache = LookAndFeel::GetIntCache();
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
 ContentParent::RecvIsSecureURI(const uint32_t& type,
                                const URIParams& uri,
                                const uint32_t& flags,
                                bool* isSecureURI)
 {
   nsCOMPtr<nsISiteSecurityService> sss(do_GetService(NS_SSSERVICE_CONTRACTID));
   if (!sss) {
     return IPC_FAIL_NO_REASON(this);
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -677,17 +677,18 @@ private:
                                 int32_t* aCaptivePortalState,
                                 bool* aIsLangRTL,
                                 bool* aHaveBidiKeyboards,
                                 InfallibleTArray<nsString>* dictionaries,
                                 ClipboardCapabilities* clipboardCaps,
                                 DomainPolicyClone* domainPolicy,
                                 StructuredCloneData* initialData,
                                 InfallibleTArray<FontFamilyListEntry>* fontFamilies,
-                                OptionalURIParams* aUserContentSheetURL) override;
+                                OptionalURIParams* aUserContentSheetURL,
+                                nsTArray<LookAndFeelInt>* aLookAndFeelIntCache) override;
 
   virtual bool
   DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
 
   virtual bool
   DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent*) override;
 
   virtual PBrowserParent* AllocPBrowserParent(const TabId& aTabId,
@@ -923,18 +924,16 @@ private:
 
   virtual mozilla::ipc::IPCResult RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
                                                                       const bool& aHidden) override;
 
   virtual mozilla::ipc::IPCResult RecvAudioChannelServiceStatus(const bool& aTelephonyChannel,
                                                                 const bool& aContentOrNormalChannel,
                                                                 const bool& aAnyChannel) override;
 
-  virtual mozilla::ipc::IPCResult RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>* aLookAndFeelIntCache) override;
-
   virtual mozilla::ipc::IPCResult RecvKeywordToURI(const nsCString& aKeyword,
                                                    nsString* aProviderName,
                                                    OptionalInputStreamParams* aPostData,
                                                    OptionalURIParams* aURI) override;
 
   virtual mozilla::ipc::IPCResult RecvNotifyKeywordSearchLoading(const nsString &aProvider,
                                                                  const nsString &aKeyword) override;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -662,17 +662,18 @@ parent:
     sync GetXPCOMProcessAttributes()
         returns (bool isOffline, bool isConnected, int32_t captivePortalState,
                  bool isLangRTL,
                  bool haveBidiKeyboards, nsString[] dictionaries,
                  ClipboardCapabilities clipboardCaps,
                  DomainPolicyClone domainPolicy,
                  StructuredCloneData initialData,
                  FontFamilyListEntry[] fontFamilies /* used on MacOSX only */,
-                 OptionalURIParams userContentSheetURL);
+                 OptionalURIParams userContentSheetURL,
+                 LookAndFeelInt[] lookAndFeelIntCache);
 
     sync CreateChildProcess(IPCTabContext context,
                             ProcessPriority priority,
                             TabId openerTabId)
         returns (ContentParentId cpId, bool isForBrowser, TabId tabId);
     sync BridgeToChildProcess(ContentParentId cpId);
 
     async CreateGMPService();
@@ -763,19 +764,16 @@ parent:
                          uint8_t[] keyHandle)
         returns (uint8_t[] signature);
 
     sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags)
         returns (bool isSecureURI);
 
     async AccumulateMixedContentHSTS(URIParams uri, bool active, bool hasHSTSPriming);
 
-    sync GetLookAndFeelCache()
-        returns (LookAndFeelInt[] lookAndFeelIntCache);
-
     nested(inside_cpow) async PHal();
 
     async PHeapSnapshotTempFileHelper();
 
     async PNecko();
 
     async PPrinting();
 
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -469,19 +469,19 @@ nsXPLookAndFeel::Init()
   Preferences::AddBoolVarCache(&sFindbarModalHighlight,
                                "findbar.modalHighlight",
                                sFindbarModalHighlight);
 
   if (XRE_IsContentProcess()) {
     mozilla::dom::ContentChild* cc =
       mozilla::dom::ContentChild::GetSingleton();
 
-    nsTArray<LookAndFeelInt> lookAndFeelIntCache;
-    cc->SendGetLookAndFeelCache(&lookAndFeelIntCache);
-    LookAndFeel::SetIntCache(lookAndFeelIntCache);
+    LookAndFeel::SetIntCache(cc->LookAndFeelCache());
+    // This is only ever used once during initialization, and can be cleared now.
+    cc->LookAndFeelCache().Clear();
   }
 }
 
 nsXPLookAndFeel::~nsXPLookAndFeel()
 {
   NS_ASSERTION(sInstance == this,
                "This destroying instance isn't the singleton instance");
   sInstance = nullptr;