Bug 1742438 - Cleanup: Move generic WorkerLoadContext fields together, document WorkerLoadContext; r=asuth

And we are done!

Differential Revision: https://phabricator.services.mozilla.com/D146185
This commit is contained in:
Yulia Startsev 2022-07-14 17:07:29 +00:00
Родитель ccd1b4e8bd
Коммит fc9b74bbb7
1 изменённых файлов: 32 добавлений и 4 удалений

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

@ -27,12 +27,44 @@ namespace workerinternals::loader {
class CacheCreator; class CacheCreator;
} }
/*
* WorkerScriptLoadContext (for all workers)
*
* LoadContexts augment the loading of a ScriptLoadRequest. They
* describe how a ScriptLoadRequests loading and evaluation needs to be
* augmented, based on the information provided by the loading context. The
* WorkerLoadContext has the following generic fields applied to all worker
* ScriptLoadRequests (and primarily used for error handling):
*
* * mURI
* Set at worker creation, used when throwing an error.
* * mLoadResult
* Used to store the result of a load. In particular, it is used for
* error handling when a load fails (for example, a malformed URI).
* * mMutedErrorFlag
* Set when we finish loading a script, and used to determine whether a
* given error is thrown or muted.
*
* The rest of the fields on this class focus on enabling the ServiceWorker
* usecase, in particular -- using the Cache API to store the worker so that
* in the case of (for example) a page refresh, the service worker itself is
* persisted so that it can do other work. For more details see the
* CacheLoadHandler.h file.
*
*/
class WorkerLoadContext : public JS::loader::LoadContextBase { class WorkerLoadContext : public JS::loader::LoadContextBase {
public: public:
explicit WorkerLoadContext(); explicit WorkerLoadContext();
~WorkerLoadContext() = default; ~WorkerLoadContext() = default;
/* These fields are used by all workers */
Maybe<bool> mMutedErrorFlag;
nsresult mLoadResult = NS_ERROR_NOT_INITIALIZED;
/* These fields are only used by service workers */
/* TODO: Split out a ServiceWorkerLoadContext */
// This full URL string is populated only if this object is used in a // This full URL string is populated only if this object is used in a
// ServiceWorker. // ServiceWorker.
nsString mFullURL; nsString mFullURL;
@ -47,8 +79,6 @@ class WorkerLoadContext : public JS::loader::LoadContextBase {
// when we're going to have an mCachePromise. // when we're going to have an mCachePromise.
nsCOMPtr<nsIInputStream> mCacheReadStream; nsCOMPtr<nsIInputStream> mCacheReadStream;
nsresult mLoadResult = NS_ERROR_NOT_INITIALIZED;
RefPtr<workerinternals::loader::CacheCreator> mCacheCreator; RefPtr<workerinternals::loader::CacheCreator> mCacheCreator;
void ClearCacheCreator(); void ClearCacheCreator();
@ -80,8 +110,6 @@ class WorkerLoadContext : public JS::loader::LoadContextBase {
CacheStatus mCacheStatus = Uncached; CacheStatus mCacheStatus = Uncached;
Maybe<bool> mMutedErrorFlag;
bool IsAwaitingPromise() const { return bool(mCachePromise); } bool IsAwaitingPromise() const { return bool(mCachePromise); }
}; };