Bug 1174868 - Avoid storing RequestContext inside InternalRequest; r=nsm,bkelly,smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 15 Jun 2015 16:12:45 -0400
changeset 267112 00f9709186396cc103330ec431b8d34c7d7dc5bf
parent 267111 a4da65a36e31033a33d9945bdf36706373630360
child 267113 7210dfe7ad781fd39aedea2e78be669c76532c33
push idunknown
push userunknown
push dateunknown
reviewersnsm, bkelly, smaug
bugs1174868
milestone41.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 1174868 - Avoid storing RequestContext inside InternalRequest; r=nsm,bkelly,smaug We are going to infer all RequestContext types from the corresponding nsContentPolicyType. It no longer makes sense to store both of these on InternalRequest. This has the extra benefit that we don't need to worry about keeping them in sync any more.
dom/cache/CacheTypes.ipdlh
dom/cache/DBSchema.cpp
dom/cache/IPCUtils.h
dom/cache/TypeUtils.cpp
dom/fetch/InternalRequest.cpp
dom/fetch/InternalRequest.h
dom/fetch/Request.h
dom/ipc/manifestMessages.js
dom/webidl/Request.webidl
--- a/dom/cache/CacheTypes.ipdlh
+++ b/dom/cache/CacheTypes.ipdlh
@@ -7,17 +7,16 @@ include protocol PCachePushStream;
 include protocol PCacheStreamControl;
 include InputStreamParams;
 include ChannelInfo;
 
 using HeadersGuardEnum from "mozilla/dom/cache/IPCUtils.h";
 using RequestCredentials from "mozilla/dom/cache/IPCUtils.h";
 using RequestMode from "mozilla/dom/cache/IPCUtils.h";
 using RequestCache from "mozilla/dom/cache/IPCUtils.h";
-using RequestContext from "mozilla/dom/cache/IPCUtils.h";
 using ResponseType from "mozilla/dom/cache/IPCUtils.h";
 using mozilla::void_t from "ipc/IPCMessageUtils.h";
 using struct nsID from "nsID.h";
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 
@@ -58,17 +57,16 @@ struct CacheRequest
   nsString urlWithoutQuery;
   HeadersEntry[] headers;
   HeadersGuardEnum headersGuard;
   nsString referrer;
   RequestMode mode;
   RequestCredentials credentials;
   CacheReadStreamOrVoid body;
   uint32_t contentPolicyType;
-  RequestContext context;
   RequestCache requestCache;
 };
 
 union CacheRequestOrVoid
 {
   void_t;
   CacheRequest;
 };
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -24,21 +24,21 @@
 #include "mozilla/dom/ResponseBinding.h"
 #include "nsIContentPolicy.h"
 
 namespace mozilla {
 namespace dom {
 namespace cache {
 namespace db {
 
-const int32_t kMaxWipeSchemaVersion = 12;
+const int32_t kMaxWipeSchemaVersion = 13;
 
 namespace {
 
-const int32_t kLatestSchemaVersion = 12;
+const int32_t kLatestSchemaVersion = 13;
 const int32_t kMaxEntriesPerStatement = 255;
 
 const uint32_t kPageSize = 4 * 1024;
 
 // Grow the database in chunks to reduce fragmentation
 const uint32_t kGrowthSize = 32 * 1024;
 const uint32_t kGrowthPages = kGrowthSize / kPageSize;
 static_assert(kGrowthSize % kPageSize == 0,
@@ -72,49 +72,16 @@ static_assert(int(RequestMode::Same_orig
               int(RequestMode::Cors_with_forced_preflight) == 3 &&
               int(RequestMode::EndGuard_) == 4,
               "RequestMode values are as expected");
 static_assert(int(RequestCredentials::Omit) == 0 &&
               int(RequestCredentials::Same_origin) == 1 &&
               int(RequestCredentials::Include) == 2 &&
               int(RequestCredentials::EndGuard_) == 3,
               "RequestCredentials values are as expected");
-static_assert(int(RequestContext::Audio) == 0 &&
-              int(RequestContext::Beacon) == 1 &&
-              int(RequestContext::Cspreport) == 2 &&
-              int(RequestContext::Download) == 3 &&
-              int(RequestContext::Embed) == 4 &&
-              int(RequestContext::Eventsource) == 5 &&
-              int(RequestContext::Favicon) == 6 &&
-              int(RequestContext::Fetch) == 7 &&
-              int(RequestContext::Font) == 8 &&
-              int(RequestContext::Form) == 9 &&
-              int(RequestContext::Frame) == 10 &&
-              int(RequestContext::Hyperlink) == 11 &&
-              int(RequestContext::Iframe) == 12 &&
-              int(RequestContext::Image) == 13 &&
-              int(RequestContext::Imageset) == 14 &&
-              int(RequestContext::Import) == 15 &&
-              int(RequestContext::Internal) == 16 &&
-              int(RequestContext::Location) == 17 &&
-              int(RequestContext::Manifest) == 18 &&
-              int(RequestContext::Object) == 19 &&
-              int(RequestContext::Ping) == 20 &&
-              int(RequestContext::Plugin) == 21 &&
-              int(RequestContext::Prefetch) == 22 &&
-              int(RequestContext::Script) == 23 &&
-              int(RequestContext::Sharedworker) == 24 &&
-              int(RequestContext::Subresource) == 25 &&
-              int(RequestContext::Style) == 26 &&
-              int(RequestContext::Track) == 27 &&
-              int(RequestContext::Video) == 28 &&
-              int(RequestContext::Worker) == 29 &&
-              int(RequestContext::Xmlhttprequest) == 30 &&
-              int(RequestContext::Xslt) == 31,
-              "RequestContext values are as expected");
 static_assert(int(RequestCache::Default) == 0 &&
               int(RequestCache::No_store) == 1 &&
               int(RequestCache::Reload) == 2 &&
               int(RequestCache::No_cache) == 3 &&
               int(RequestCache::Force_cache) == 4 &&
               int(RequestCache::Only_if_cached) == 5 &&
               int(RequestCache::EndGuard_) == 6,
               "RequestCache values are as expected");
@@ -285,17 +252,16 @@ CreateSchema(mozIStorageConnection* aCon
         "request_method TEXT NOT NULL, "
         "request_url TEXT NOT NULL, "
         "request_url_no_query TEXT NOT NULL, "
         "request_referrer TEXT NOT NULL, "
         "request_headers_guard INTEGER NOT NULL, "
         "request_mode INTEGER NOT NULL, "
         "request_credentials INTEGER NOT NULL, "
         "request_contentpolicytype INTEGER NOT NULL, "
-        "request_context INTEGER NOT NULL, "
         "request_cache INTEGER NOT NULL, "
         "request_body_id TEXT NULL, "
         "response_type INTEGER NOT NULL, "
         "response_url TEXT NOT NULL, "
         "response_status INTEGER NOT NULL, "
         "response_status_text TEXT NOT NULL, "
         "response_headers_guard INTEGER NOT NULL, "
         "response_body_id TEXT NULL, "
@@ -1456,17 +1422,16 @@ InsertEntry(mozIStorageConnection* aConn
       "request_method, "
       "request_url, "
       "request_url_no_query, "
       "request_referrer, "
       "request_headers_guard, "
       "request_mode, "
       "request_credentials, "
       "request_contentpolicytype, "
-      "request_context, "
       "request_cache, "
       "request_body_id, "
       "response_type, "
       "response_url, "
       "response_status, "
       "response_status_text, "
       "response_headers_guard, "
       "response_body_id, "
@@ -1478,17 +1443,16 @@ InsertEntry(mozIStorageConnection* aConn
       ":request_method, "
       ":request_url, "
       ":request_url_no_query, "
       ":request_referrer, "
       ":request_headers_guard, "
       ":request_mode, "
       ":request_credentials, "
       ":request_contentpolicytype, "
-      ":request_context, "
       ":request_cache, "
       ":request_body_id, "
       ":response_type, "
       ":response_url, "
       ":response_status, "
       ":response_status_text, "
       ":response_headers_guard, "
       ":response_body_id, "
@@ -1527,20 +1491,16 @@ InsertEntry(mozIStorageConnection* aConn
   rv = state->BindInt32ByName(NS_LITERAL_CSTRING("request_credentials"),
     static_cast<int32_t>(aRequest.credentials()));
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   rv = state->BindInt32ByName(NS_LITERAL_CSTRING("request_contentpolicytype"),
     static_cast<int32_t>(aRequest.contentPolicyType()));
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
-  rv = state->BindInt32ByName(NS_LITERAL_CSTRING("request_context"),
-    static_cast<int32_t>(aRequest.context()));
-  if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
-
   rv = state->BindInt32ByName(NS_LITERAL_CSTRING("request_cache"),
     static_cast<int32_t>(aRequest.requestCache()));
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   rv = BindId(state, NS_LITERAL_CSTRING("request_body_id"), aRequestBodyId);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   rv = state->BindInt32ByName(NS_LITERAL_CSTRING("response_type"),
@@ -1774,17 +1734,16 @@ ReadRequest(mozIStorageConnection* aConn
       "request_method, "
       "request_url, "
       "request_url_no_query, "
       "request_referrer, "
       "request_headers_guard, "
       "request_mode, "
       "request_credentials, "
       "request_contentpolicytype, "
-      "request_context, "
       "request_cache, "
       "request_body_id "
     "FROM entries "
     "WHERE id=:id;"
   ), getter_AddRefs(state));
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   rv = state->BindInt32ByName(NS_LITERAL_CSTRING("id"), aEntryId);
@@ -1824,35 +1783,29 @@ ReadRequest(mozIStorageConnection* aConn
     static_cast<RequestCredentials>(credentials);
 
   int32_t requestContentPolicyType;
   rv = state->GetInt32(7, &requestContentPolicyType);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
   aSavedRequestOut->mValue.contentPolicyType() =
     static_cast<nsContentPolicyType>(requestContentPolicyType);
 
-  int32_t requestContext;
-  rv = state->GetInt32(8, &requestContext);
-  if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
-  aSavedRequestOut->mValue.context() =
-    static_cast<RequestContext>(requestContext);
-
   int32_t requestCache;
-  rv = state->GetInt32(9, &requestCache);
+  rv = state->GetInt32(8, &requestCache);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
   aSavedRequestOut->mValue.requestCache() =
     static_cast<RequestCache>(requestCache);
 
   bool nullBody = false;
-  rv = state->GetIsNull(10, &nullBody);
+  rv = state->GetIsNull(9, &nullBody);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
   aSavedRequestOut->mHasBodyId = !nullBody;
 
   if (aSavedRequestOut->mHasBodyId) {
-    rv = ExtractId(state, 10, &aSavedRequestOut->mBodyId);
+    rv = ExtractId(state, 9, &aSavedRequestOut->mBodyId);
     if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
   }
 
   rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT "
       "name, "
       "value "
     "FROM request_headers "
--- a/dom/cache/IPCUtils.h
+++ b/dom/cache/IPCUtils.h
@@ -34,21 +34,16 @@ namespace IPC {
                                     mozilla::dom::RequestCredentials::Omit,
                                     mozilla::dom::RequestCredentials::EndGuard_> {};
   template<>
   struct ParamTraits<mozilla::dom::RequestCache> :
     public ContiguousEnumSerializer<mozilla::dom::RequestCache,
                                     mozilla::dom::RequestCache::Default,
                                     mozilla::dom::RequestCache::EndGuard_> {};
   template<>
-  struct ParamTraits<mozilla::dom::RequestContext> :
-    public ContiguousEnumSerializer<mozilla::dom::RequestContext,
-                                    mozilla::dom::RequestContext::Audio,
-                                    mozilla::dom::RequestContext::EndGuard_> {};
-  template<>
   struct ParamTraits<mozilla::dom::ResponseType> :
     public ContiguousEnumSerializer<mozilla::dom::ResponseType,
                                     mozilla::dom::ResponseType::Basic,
                                     mozilla::dom::ResponseType::EndGuard_> {};
   template<>
   struct ParamTraits<mozilla::dom::cache::Namespace> :
     public ContiguousEnumSerializer<mozilla::dom::cache::Namespace,
                                     mozilla::dom::cache::DEFAULT_NAMESPACE,
--- a/dom/cache/TypeUtils.cpp
+++ b/dom/cache/TypeUtils.cpp
@@ -172,17 +172,16 @@ TypeUtils::ToCacheRequest(CacheRequest& 
 
   nsRefPtr<InternalHeaders> headers = aIn->Headers();
   MOZ_ASSERT(headers);
   ToHeadersEntryList(aOut.headers(), headers);
   aOut.headersGuard() = headers->Guard();
   aOut.mode() = aIn->Mode();
   aOut.credentials() = aIn->GetCredentialsMode();
   aOut.contentPolicyType() = aIn->ContentPolicyType();
-  aOut.context() = aIn->Context();
   aOut.requestCache() = aIn->GetCacheMode();
 
   if (aBodyAction == IgnoreBody) {
     aOut.body() = void_t();
     return;
   }
 
   // BodyUsed flag is checked and set previously in ToInternalRequest()
@@ -323,20 +322,16 @@ TypeUtils::ToInternalRequest(const Cache
   nsRefPtr<InternalRequest> internalRequest = new InternalRequest();
 
   internalRequest->SetMethod(aIn.method());
   internalRequest->SetURL(NS_ConvertUTF16toUTF8(aIn.url()));
   internalRequest->SetReferrer(aIn.referrer());
   internalRequest->SetMode(aIn.mode());
   internalRequest->SetCredentialsMode(aIn.credentials());
   internalRequest->SetContentPolicyType(aIn.contentPolicyType());
-  DebugOnly<RequestContext> contextAfterSetContentPolicyType = internalRequest->Context();
-  internalRequest->SetContext(aIn.context());
-  MOZ_ASSERT(contextAfterSetContentPolicyType.value == internalRequest->Context(),
-             "The RequestContext and nsContentPolicyType values should not get out of sync");
   internalRequest->SetCacheMode(aIn.requestCache());
 
   nsRefPtr<InternalHeaders> internalHeaders =
     ToInternalHeaders(aIn.headers(), aIn.headersGuard());
   ErrorResult result;
   internalRequest->Headers()->SetGuard(aIn.headersGuard(), result);
   MOZ_ASSERT(!result.Failed());
   internalRequest->Headers()->Fill(*internalHeaders, result);
--- a/dom/fetch/InternalRequest.cpp
+++ b/dom/fetch/InternalRequest.cpp
@@ -34,17 +34,16 @@ InternalRequest::GetRequestConstructorCo
   // The "client" is not stored in our implementation. Fetch API users should
   // use the appropriate window/document/principal and other Gecko security
   // mechanisms as appropriate.
   copy->mSameOriginDataURL = true;
   copy->mPreserveContentCodings = true;
   // The default referrer is already about:client.
 
   copy->mContentPolicyType = nsIContentPolicy::TYPE_FETCH;
-  copy->mContext = RequestContext::Fetch;
   copy->mMode = mMode;
   copy->mCredentialsMode = mCredentialsMode;
   copy->mCacheMode = mCacheMode;
   copy->mCreatedByFetchEvent = mCreatedByFetchEvent;
   return copy.forget();
 }
 
 already_AddRefed<InternalRequest>
@@ -71,17 +70,16 @@ InternalRequest::Clone()
   return clone.forget();
 }
 
 InternalRequest::InternalRequest(const InternalRequest& aOther)
   : mMethod(aOther.mMethod)
   , mURL(aOther.mURL)
   , mHeaders(new InternalHeaders(*aOther.mHeaders))
   , mContentPolicyType(aOther.mContentPolicyType)
-  , mContext(aOther.mContext)
   , mReferrer(aOther.mReferrer)
   , mMode(aOther.mMode)
   , mCredentialsMode(aOther.mCredentialsMode)
   , mResponseTainting(aOther.mResponseTainting)
   , mCacheMode(aOther.mCacheMode)
   , mAuthenticationFlag(aOther.mAuthenticationFlag)
   , mForceOriginHeader(aOther.mForceOriginHeader)
   , mPreserveContentCodings(aOther.mPreserveContentCodings)
@@ -99,84 +97,91 @@ InternalRequest::InternalRequest(const I
 InternalRequest::~InternalRequest()
 {
 }
 
 void
 InternalRequest::SetContentPolicyType(nsContentPolicyType aContentPolicyType)
 {
   mContentPolicyType = aContentPolicyType;
+}
+
+/* static */
+RequestContext
+InternalRequest::MapContentPolicyTypeToRequestContext(nsContentPolicyType aContentPolicyType)
+{
+  RequestContext context = RequestContext::Internal;
   switch (aContentPolicyType) {
   case nsIContentPolicy::TYPE_OTHER:
-    mContext = RequestContext::Internal;
+    context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_SCRIPT:
-    mContext = RequestContext::Script;
+    context = RequestContext::Script;
     break;
   case nsIContentPolicy::TYPE_IMAGE:
-    mContext = RequestContext::Image;
+    context = RequestContext::Image;
     break;
   case nsIContentPolicy::TYPE_STYLESHEET:
-    mContext = RequestContext::Style;
+    context = RequestContext::Style;
     break;
   case nsIContentPolicy::TYPE_OBJECT:
-    mContext = RequestContext::Object;
+    context = RequestContext::Object;
     break;
   case nsIContentPolicy::TYPE_DOCUMENT:
-    mContext = RequestContext::Internal;
+    context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_SUBDOCUMENT:
-    mContext = RequestContext::Iframe;
+    context = RequestContext::Iframe;
     break;
   case nsIContentPolicy::TYPE_REFRESH:
-    mContext = RequestContext::Internal;
+    context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_XBL:
-    mContext = RequestContext::Internal;
+    context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_PING:
-    mContext = RequestContext::Ping;
+    context = RequestContext::Ping;
     break;
   case nsIContentPolicy::TYPE_XMLHTTPREQUEST:
-    mContext = RequestContext::Xmlhttprequest;
+    context = RequestContext::Xmlhttprequest;
     break;
   case nsIContentPolicy::TYPE_OBJECT_SUBREQUEST:
-    mContext = RequestContext::Plugin;
+    context = RequestContext::Plugin;
     break;
   case nsIContentPolicy::TYPE_DTD:
-    mContext = RequestContext::Internal;
+    context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_FONT:
-    mContext = RequestContext::Font;
+    context = RequestContext::Font;
     break;
   case nsIContentPolicy::TYPE_MEDIA:
-    mContext = RequestContext::Audio;
+    context = RequestContext::Audio;
     break;
   case nsIContentPolicy::TYPE_WEBSOCKET:
-    mContext = RequestContext::Internal;
+    context = RequestContext::Internal;
     break;
   case nsIContentPolicy::TYPE_CSP_REPORT:
-    mContext = RequestContext::Cspreport;
+    context = RequestContext::Cspreport;
     break;
   case nsIContentPolicy::TYPE_XSLT:
-    mContext = RequestContext::Xslt;
+    context = RequestContext::Xslt;
     break;
   case nsIContentPolicy::TYPE_BEACON:
-    mContext = RequestContext::Beacon;
+    context = RequestContext::Beacon;
     break;
   case nsIContentPolicy::TYPE_FETCH:
-    mContext = RequestContext::Fetch;
+    context = RequestContext::Fetch;
     break;
   case nsIContentPolicy::TYPE_IMAGESET:
-    mContext = RequestContext::Imageset;
+    context = RequestContext::Imageset;
     break;
   case nsIContentPolicy::TYPE_WEB_MANIFEST:
-    mContext = RequestContext::Manifest;
+    context = RequestContext::Manifest;
     break;
   default:
     MOZ_ASSERT(false, "Unhandled nsContentPolicyType value");
-    mContext = RequestContext::Internal;
     break;
   }
+  return context;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/fetch/InternalRequest.h
+++ b/dom/fetch/InternalRequest.h
@@ -21,18 +21,17 @@
 #endif
 
 namespace mozilla {
 namespace dom {
 
 /*
  * The mapping of RequestContext and nsContentPolicyType is currently as the
  * following.  Note that this mapping is not perfect yet (see the TODO comments
- * below for examples), so for now we'll have to keep both an mContext and an
- * mContentPolicyType, because we cannot have a two way conversion.
+ * below for examples).
  *
  * RequestContext    | nsContentPolicyType
  * ------------------+--------------------
  * audio             | TYPE_MEDIA
  * beacon            | TYPE_BEACON
  * cspreport         | TYPE_CSP_REPORT
  * download          |
  * embed             | TYPE_OBJECT
@@ -276,23 +275,17 @@ public:
   }
 
   void
   SetContentPolicyType(nsContentPolicyType aContentPolicyType);
 
   RequestContext
   Context() const
   {
-    return mContext;
-  }
-
-  void
-  SetContext(RequestContext aContext)
-  {
-    mContext = aContext;
+    return MapContentPolicyTypeToRequestContext(mContentPolicyType);
   }
 
   bool
   UnsafeRequest() const
   {
     return mUnsafeRequest;
   }
 
@@ -366,23 +359,25 @@ public:
   }
 
 private:
   // Does not copy mBodyStream.  Use fallible Clone() for complete copy.
   explicit InternalRequest(const InternalRequest& aOther);
 
   ~InternalRequest();
 
+  static RequestContext
+  MapContentPolicyTypeToRequestContext(nsContentPolicyType aContentPolicyType);
+
   nsCString mMethod;
   nsCString mURL;
   nsRefPtr<InternalHeaders> mHeaders;
   nsCOMPtr<nsIInputStream> mBodyStream;
 
   nsContentPolicyType mContentPolicyType;
-  RequestContext mContext;
 
   // Empty string: no-referrer
   // "about:client": client (default)
   // URL: an URL
   nsString mReferrer;
 
   RequestMode mMode;
   RequestCredentials mCredentialsMode;
--- a/dom/fetch/Request.h
+++ b/dom/fetch/Request.h
@@ -74,23 +74,16 @@ public:
   }
 
   RequestContext
   Context() const
   {
     return mRequest->Context();
   }
 
-  // [ChromeOnly]
-  void
-  SetContext(RequestContext aContext)
-  {
-    mRequest->SetContext(aContext);
-  }
-
   void
   SetContentPolicyType(nsContentPolicyType aContentPolicyType)
   {
     mRequest->SetContentPolicyType(aContentPolicyType);
   }
 
   void
   GetReferrer(nsAString& aReferrer) const
--- a/dom/ipc/manifestMessages.js
+++ b/dom/ipc/manifestMessages.js
@@ -74,17 +74,17 @@ function fetchManifest() {
     }
     const reqInit = {
       mode: 'cors'
     };
     if (elem.crossOrigin === 'use-credentials') {
       reqInit.credentials = 'include';
     }
     const req = new content.Request(manifestURL, reqInit);
-    req.setContext('manifest');
+    req.setContentPolicyType(Ci.nsIContentPolicy.TYPE_WEB_MANIFEST);
     const response = yield content.fetch(req);
     const manifest = yield processResponse(response, content);
     return manifest;
   });
 }
 
 function canLoadManifest(aElem) {
   const contentPolicy = Cc['@mozilla.org/layout/content-policy;1']
--- a/dom/webidl/Request.webidl
+++ b/dom/webidl/Request.webidl
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this IDL file is
  * https://fetch.spec.whatwg.org/#request-class
  */
 
 typedef (Request or USVString) RequestInfo;
+typedef unsigned long nsContentPolicyType;
 
 [Constructor(RequestInfo input, optional RequestInit init),
  Exposed=(Window,Worker)]
 interface Request {
   readonly attribute ByteString method;
   readonly attribute USVString url;
   [SameObject] readonly attribute Headers headers;
 
@@ -22,17 +23,17 @@ interface Request {
   readonly attribute RequestCredentials credentials;
   readonly attribute RequestCache cache;
 
   [Throws,
    NewObject] Request clone();
 
   // Bug 1124638 - Allow chrome callers to set the context.
   [ChromeOnly]
-  void setContext(RequestContext context);
+  void setContentPolicyType(nsContentPolicyType context);
 };
 Request implements Body;
 
 dictionary RequestInit {
   ByteString method;
   HeadersInit headers;
   BodyInit body;
   RequestMode mode;