Bug 1156847 - Part 2: Store the security info for a service worker on its WorkerPrivate; r=bent,khuey

This commit is contained in:
Ehsan Akhgari 2015-04-23 18:59:52 -04:00
Родитель 03b15b61fd
Коммит 9d614e4dc8
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -32,6 +32,7 @@
#include "nsIXPConnect.h"
#include "nsPerformance.h"
#include "nsPIDOMWindow.h"
#include "nsSerializationHelper.h"
#include <algorithm>
#include "jsfriendapi.h"
@ -4081,6 +4082,17 @@ WorkerPrivateParent<Derived>::SetPrincipal(nsIPrincipal* aPrincipal,
PrincipalToPrincipalInfo(aPrincipal, mLoadInfo.mPrincipalInfo)));
}
template <class Derived>
void
WorkerPrivateParent<Derived>::SetSecurityInfo(nsISerializable* aSerializable)
{
MOZ_ASSERT(IsServiceWorker());
AssertIsOnMainThread();
nsAutoCString securityInfo;
NS_SerializeToString(aSerializable, securityInfo);
SetSecurityInfo(securityInfo);
}
template <class Derived>
JSContext*
WorkerPrivateParent<Derived>::ParentJSContext() const

Просмотреть файл

@ -37,6 +37,7 @@ class nsIDocument;
class nsIEventTarget;
class nsIPrincipal;
class nsIScriptContext;
class nsISerializable;
class nsIThread;
class nsIThreadInternal;
class nsITimer;
@ -491,6 +492,25 @@ public:
return mLoadInfo.mServiceWorkerCacheName;
}
const nsCString&
GetSecurityInfo() const
{
MOZ_ASSERT(IsServiceWorker());
return mLoadInfo.mSecurityInfo;
}
void
SetSecurityInfo(const nsCString& aSecurityInfo)
{
MOZ_ASSERT(IsServiceWorker());
AssertIsOnMainThread();
MOZ_ASSERT(mLoadInfo.mSecurityInfo.IsEmpty());
mLoadInfo.mSecurityInfo = aSecurityInfo;
}
void
SetSecurityInfo(nsISerializable* aSerializable);
// This is used to handle importScripts(). When the worker is first loaded
// and executed, it happens in a sync loop. At this point it sets
// mLoadingWorkerScript to true. importScripts() calls that occur during the

Просмотреть файл

@ -243,6 +243,8 @@ struct WorkerLoadInfo
nsString mServiceWorkerCacheName;
nsCString mSecurityInfo;
uint64_t mWindowID;
bool mFromWindow;