Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / quota / StorageOriginAttributes.h
blobb68fdc804bafc914c7a4726f90d9585373c1de9a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_QUOTA_STORAGEORIGINATTRIBUTES_H_
8 #define DOM_QUOTA_STORAGEORIGINATTRIBUTES_H_
10 #include "mozilla/OriginAttributes.h"
12 namespace mozilla {
14 // A class which can handle origin attributes which are not fully supported
15 // in OriginAttributes class anymore.
16 class StorageOriginAttributes {
17 public:
18 StorageOriginAttributes() : mInIsolatedMozBrowser(false) {}
20 explicit StorageOriginAttributes(bool aInIsolatedMozBrowser)
21 : mInIsolatedMozBrowser(aInIsolatedMozBrowser) {}
23 bool InIsolatedMozBrowser() const { return mInIsolatedMozBrowser; }
25 uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; }
27 // New getters can be added here incrementally.
29 void SetInIsolatedMozBrowser(bool aInIsolatedMozBrowser) {
30 mInIsolatedMozBrowser = aInIsolatedMozBrowser;
33 void SetUserContextId(uint32_t aUserContextId) {
34 mOriginAttributes.mUserContextId = aUserContextId;
37 // New setters can be added here incrementally.
39 // Serializes/Deserializes non-default values into the suffix format, i.e.
40 // |^key1=value1&key2=value2|. If there are no non-default attributes, this
41 // returns an empty string
42 void CreateSuffix(nsACString& aStr) const;
44 [[nodiscard]] bool PopulateFromSuffix(const nsACString& aStr);
46 // Populates the attributes from a string like
47 // |uri^key1=value1&key2=value2| and returns the uri without the suffix.
48 [[nodiscard]] bool PopulateFromOrigin(const nsACString& aOrigin,
49 nsACString& aOriginNoSuffix);
51 private:
52 OriginAttributes mOriginAttributes;
54 bool mInIsolatedMozBrowser;
57 } // namespace mozilla
59 #endif // DOM_QUOTA_STORAGEORIGINATTRIBUTES_H_