Bug 1286798 - Part 48: Add ParseOrigin() method to the quota manager; r=asuth
authorJan Varga <jan.varga@gmail.com>
Thu, 29 Nov 2018 21:49:49 +0100
changeset 508046 f0721a859c7493f831df6e4e25310e9a2021ac5a
parent 508045 b9badcc1709de40910e1c13b7041d3d4b85d2683
child 508047 66d175df810660b322fa907b97320d4a972cf9fa
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1286798
milestone65.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 1286798 - Part 48: Add ParseOrigin() method to the quota manager; r=asuth
dom/quota/ActorsParent.cpp
dom/quota/QuotaManager.h
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -6097,16 +6097,41 @@ QuotaManager::AreOriginsEqualOnDisk(nsAC
   SanitizeOriginString(origin1Sanitized);
 
   nsCString origin2Sanitized(aOrigin2);
   SanitizeOriginString(origin2Sanitized);
 
   return origin1Sanitized == origin2Sanitized;
 }
 
+// static
+bool
+QuotaManager::ParseOrigin(const nsACString& aOrigin,
+                          nsCString& aSpec,
+                          OriginAttributes* aAttrs)
+{
+  MOZ_ASSERT(aAttrs);
+
+  if (aOrigin.Equals(kChromeOrigin)) {
+    aSpec = kChromeOrigin;
+    return true;
+  }
+
+  nsCString sanitizedOrigin(aOrigin);
+  SanitizeOriginString(sanitizedOrigin);
+
+  OriginParser::ResultType result =
+    OriginParser::ParseOrigin(sanitizedOrigin, aSpec, aAttrs);
+  if (NS_WARN_IF(result != OriginParser::ValidOrigin)) {
+    return false;
+  }
+
+  return true;
+}
+
 uint64_t
 QuotaManager::LockedCollectOriginsForEviction(
                                   uint64_t aMinSizeToBeFreed,
                                   nsTArray<RefPtr<DirectoryLockImpl>>& aLocks)
 {
   mQuotaMutex.AssertCurrentThreadOwns();
 
   RefPtr<CollectOriginsHelper> helper =
--- a/dom/quota/QuotaManager.h
+++ b/dom/quota/QuotaManager.h
@@ -27,16 +27,22 @@ class mozIStorageConnection;
 class nsIEventTarget;
 class nsIPrincipal;
 class nsIThread;
 class nsITimer;
 class nsIURI;
 class nsPIDOMWindowOuter;
 class nsIRunnable;
 
+namespace mozilla {
+
+class OriginAttributes;
+
+} // namespace mozilla
+
 BEGIN_QUOTA_NAMESPACE
 
 class DirectoryLockImpl;
 class GroupInfo;
 class GroupInfoPair;
 class OriginInfo;
 class OriginScope;
 class QuotaObject;
@@ -426,16 +432,21 @@ public:
 
   static void
   ChromeOrigin(nsACString& aOrigin);
 
   static bool
   AreOriginsEqualOnDisk(nsACString& aOrigin1,
                         nsACString& aOrigin2);
 
+  static bool
+  ParseOrigin(const nsACString& aOrigin,
+              nsCString& aSpec,
+              OriginAttributes* aAttrs);
+
 private:
   QuotaManager();
 
   virtual ~QuotaManager();
 
   nsresult
   Init(const nsAString& aBaseDirPath);