Line data Source code
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
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_cache_ManagerId_h
8 : #define mozilla_dom_cache_ManagerId_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/dom/cache/Types.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsError.h"
14 : #include "nsISupportsImpl.h"
15 : #include "nsString.h"
16 :
17 : class nsIPrincipal;
18 :
19 : namespace mozilla {
20 : namespace dom {
21 : namespace cache {
22 :
23 : class ManagerId final
24 : {
25 : public:
26 : // Main thread only
27 : static nsresult Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut);
28 :
29 : // Main thread only
30 : already_AddRefed<nsIPrincipal> Principal() const;
31 :
32 0 : const nsACString& QuotaOrigin() const { return mQuotaOrigin; }
33 :
34 0 : bool operator==(const ManagerId& aOther) const
35 : {
36 0 : return mQuotaOrigin == aOther.mQuotaOrigin;
37 : }
38 :
39 : private:
40 : ManagerId(nsIPrincipal* aPrincipal, const nsACString& aOrigin);
41 : ~ManagerId();
42 :
43 : ManagerId(const ManagerId&) = delete;
44 : ManagerId& operator=(const ManagerId&) = delete;
45 :
46 : // only accessible on main thread
47 : nsCOMPtr<nsIPrincipal> mPrincipal;
48 :
49 : // immutable to allow threadsfe access
50 : const nsCString mQuotaOrigin;
51 :
52 : public:
53 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::dom::cache::ManagerId)
54 : };
55 :
56 : } // namespace cache
57 : } // namespace dom
58 : } // namespace mozilla
59 :
60 : #endif // mozilla_dom_cache_ManagerId_h
|