Bug 1199295 - Pass right loadingPrincipal to uriloader/prefetch - dom changes (r=smaug)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Fri, 02 Oct 2015 09:10:02 -0700
changeset 299197 31da4a02d8b67b01cf6e88305222036f028312eb
parent 299196 5445f1e97879a4dddb0df195d990f0af2ca5bd44
child 299198 cf9e1eb325c81f51a7ac7b55bfe71853cbf264e9
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1199295
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1199295 - Pass right loadingPrincipal to uriloader/prefetch - dom changes (r=smaug)
dom/base/nsContentSink.cpp
dom/base/nsGlobalWindow.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/offline/nsDOMOfflineResourceList.cpp
dom/offline/nsDOMOfflineResourceList.h
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -1166,17 +1166,18 @@ nsContentSink::ProcessOfflineManifest(co
   case CACHE_SELECTION_NONE:
     break;
   case CACHE_SELECTION_UPDATE: {
     nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
       do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
 
     if (updateService) {
       nsCOMPtr<nsIDOMDocument> domdoc = do_QueryInterface(mDocument);
-      updateService->ScheduleOnDocumentStop(manifestURI, mDocumentURI, domdoc);
+      updateService->ScheduleOnDocumentStop(manifestURI, mDocumentURI,
+                                            mDocument->NodePrincipal(), domdoc);
     }
     break;
   }
   case CACHE_SELECTION_RELOAD: {
     // This situation occurs only for toplevel documents, see bottom
     // of SelectDocAppCache method.
     // The document has been loaded from a different offline cache group than
     // the manifest it refers to, i.e. this is a foreign entry, mark it as such 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4406,32 +4406,32 @@ nsGlobalWindow::IsShowModalDialogEnabled
 
 nsIDOMOfflineResourceList*
 nsGlobalWindow::GetApplicationCache(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mApplicationCache) {
     nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetDocShell()));
-    if (!webNav) {
+    if (!webNav || !mDoc) {
       aError.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
     nsCOMPtr<nsIURI> uri;
     aError = webNav->GetCurrentURI(getter_AddRefs(uri));
     if (aError.Failed()) {
       return nullptr;
     }
 
     nsCOMPtr<nsIURI> manifestURI;
     nsContentUtils::GetOfflineAppManifest(mDoc, getter_AddRefs(manifestURI));
 
     nsRefPtr<nsDOMOfflineResourceList> applicationCache =
-      new nsDOMOfflineResourceList(manifestURI, uri, this);
+      new nsDOMOfflineResourceList(manifestURI, uri, mDoc->NodePrincipal(), this);
 
     applicationCache->Init();
 
     mApplicationCache = applicationCache;
   }
 
   return mApplicationCache;
 }
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2513,16 +2513,17 @@ ContentChild::RecvUnregisterSheet(const 
     }
 
     return true;
 }
 
 POfflineCacheUpdateChild*
 ContentChild::AllocPOfflineCacheUpdateChild(const URIParams& manifestURI,
                                             const URIParams& documentURI,
+                                            const PrincipalInfo& aLoadingPrincipalInfo,
                                             const bool& stickDocument,
                                             const TabId& aTabId)
 {
     NS_RUNTIMEABORT("unused");
     return nullptr;
 }
 
 bool
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -454,16 +454,17 @@ public:
     void GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries);
 
     PBrowserOrId
     GetBrowserOrId(TabChild* aTabChild);
 
     virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdateChild(
             const URIParams& manifestURI,
             const URIParams& documentURI,
+            const PrincipalInfo& aLoadingPrincipalInfo,
             const bool& stickDocument,
             const TabId& aTabId) override;
     virtual bool
     DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) override;
 
     virtual PWebrtcGlobalChild* AllocPWebrtcGlobalChild() override;
     virtual bool DeallocPWebrtcGlobalChild(PWebrtcGlobalChild *aActor) override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5099,16 +5099,17 @@ ContentParent::GetManagedTabContext()
 {
     return Move(ContentProcessManager::GetSingleton()->
         GetTabContextByContentProcess(this->ChildID()));
 }
 
 mozilla::docshell::POfflineCacheUpdateParent*
 ContentParent::AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
                                               const URIParams& aDocumentURI,
+                                              const PrincipalInfo& aLoadingPrincipalInfo,
                                               const bool& aStickDocument,
                                               const TabId& aTabId)
 {
     TabContext tabContext;
     if (!ContentProcessManager::GetSingleton()->
         GetTabContextByProcessAndTabId(this->ChildID(), aTabId, &tabContext)) {
         return nullptr;
     }
@@ -5119,25 +5120,26 @@ ContentParent::AllocPOfflineCacheUpdateP
     // Use this reference as the IPDL reference.
     return update.forget().take();
 }
 
 bool
 ContentParent::RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aActor,
                                                   const URIParams& aManifestURI,
                                                   const URIParams& aDocumentURI,
+                                                  const PrincipalInfo& aLoadingPrincipal,
                                                   const bool& aStickDocument,
                                                   const TabId& aTabId)
 {
     MOZ_ASSERT(aActor);
 
     nsRefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
         static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(aActor);
 
-    nsresult rv = update->Schedule(aManifestURI, aDocumentURI, aStickDocument);
+    nsresult rv = update->Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, aStickDocument);
     if (NS_FAILED(rv) && IsAlive()) {
         // Inform the child of failure.
         unused << update->SendFinish(false, false);
     }
 
     return true;
 }
 
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -76,16 +76,17 @@ class ContentParent final : public PCont
                           , public nsIDOMGeoPositionErrorCallback
                           , public mozilla::LinkedListElement<ContentParent>
 {
     typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost;
     typedef mozilla::ipc::OptionalURIParams OptionalURIParams;
     typedef mozilla::ipc::PFileDescriptorSetParent PFileDescriptorSetParent;
     typedef mozilla::ipc::TestShellParent TestShellParent;
     typedef mozilla::ipc::URIParams URIParams;
+    typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
     typedef mozilla::dom::ClonedMessageData ClonedMessageData;
 
 public:
 #ifdef MOZ_NUWA_PROCESS
     static int32_t NuwaPid() {
         return sNuwaPid;
     }
 
@@ -389,22 +390,24 @@ public:
     virtual bool RecvNotifyTabDestroying(const TabId& aTabId,
                                          const ContentParentId& aCpId) override;
 
     nsTArray<TabContext> GetManagedTabContext();
 
     virtual POfflineCacheUpdateParent*
     AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
                                    const URIParams& aDocumentURI,
+                                   const PrincipalInfo& aLoadingPrincipalInfo,
                                    const bool& aStickDocument,
                                    const TabId& aTabId) override;
     virtual bool
     RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aActor,
                                        const URIParams& aManifestURI,
                                        const URIParams& aDocumentURI,
+                                       const PrincipalInfo& aLoadingPrincipal,
                                        const bool& stickDocument,
                                        const TabId& aTabId) override;
     virtual bool
     DeallocPOfflineCacheUpdateParent(POfflineCacheUpdateParent* aActor) override;
 
     virtual bool RecvSetOfflinePermission(const IPC::Principal& principal) override;
 
     virtual bool RecvFinishShutdown() override;
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -76,21 +76,23 @@ NS_IMPL_EVENT_HANDLER(nsDOMOfflineResour
 NS_IMPL_EVENT_HANDLER(nsDOMOfflineResourceList, downloading)
 NS_IMPL_EVENT_HANDLER(nsDOMOfflineResourceList, progress)
 NS_IMPL_EVENT_HANDLER(nsDOMOfflineResourceList, cached)
 NS_IMPL_EVENT_HANDLER(nsDOMOfflineResourceList, updateready)
 NS_IMPL_EVENT_HANDLER(nsDOMOfflineResourceList, obsolete)
 
 nsDOMOfflineResourceList::nsDOMOfflineResourceList(nsIURI *aManifestURI,
                                                    nsIURI *aDocumentURI,
+                                                   nsIPrincipal *aLoadingPrincipal,
                                                    nsPIDOMWindow *aWindow)
   : DOMEventTargetHelper(aWindow)
   , mInitialized(false)
   , mManifestURI(aManifestURI)
   , mDocumentURI(aDocumentURI)
+  , mLoadingPrincipal(aLoadingPrincipal)
   , mExposeCacheUpdateStatus(true)
   , mStatus(nsIDOMOfflineResourceList::IDLE)
   , mCachedKeys(nullptr)
   , mCachedKeysCount(0)
 {
 }
 
 nsDOMOfflineResourceList::~nsDOMOfflineResourceList()
@@ -461,17 +463,17 @@ nsDOMOfflineResourceList::Update()
   nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
     do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMWindow> window = 
     do_QueryInterface(GetOwner());
 
   nsCOMPtr<nsIOfflineCacheUpdate> update;
-  rv = updateService->ScheduleUpdate(mManifestURI, mDocumentURI,
+  rv = updateService->ScheduleUpdate(mManifestURI, mDocumentURI, mLoadingPrincipal,
                                      window, getter_AddRefs(update));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::SwapCache()
--- a/dom/offline/nsDOMOfflineResourceList.h
+++ b/dom/offline/nsDOMOfflineResourceList.h
@@ -47,16 +47,17 @@ public:
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
                                            mozilla::DOMEventTargetHelper)
 
   nsDOMOfflineResourceList(nsIURI* aManifestURI,
                            nsIURI* aDocumentURI,
+                           nsIPrincipal* aLoadingPrincipal,
                            nsPIDOMWindow* aWindow);
 
   void FirePendingEvents();
   void Disconnect();
 
   nsresult Init();
 
   nsPIDOMWindow* GetParentObject() const
@@ -148,16 +149,17 @@ private:
 
   bool mInitialized;
 
   nsCOMPtr<nsIURI> mManifestURI;
   // AsciiSpec of mManifestURI
   nsCString mManifestSpec;
 
   nsCOMPtr<nsIURI> mDocumentURI;
+  nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
   nsCOMPtr<nsIApplicationCacheService> mApplicationCacheService;
   nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
   nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
   bool mExposeCacheUpdateStatus;
   uint16_t mStatus;
 
   // The set of dynamic keys for this application cache object.
   char **mCachedKeys;