Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / storage / StorageActivityService.h
blob0b61bd128ab45b6ce35d8592172a296ff85152a3
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/. */
7 #ifndef mozilla_dom_StorageActivityService_h
8 #define mozilla_dom_StorageActivityService_h
10 #include "nsTHashMap.h"
11 #include "nsIObserver.h"
12 #include "nsIStorageActivityService.h"
13 #include "nsWeakReference.h"
15 namespace mozilla {
17 namespace ipc {
18 class PrincipalInfo;
19 } // namespace ipc
21 namespace dom {
23 class StorageActivityService final : public nsIStorageActivityService,
24 public nsIObserver,
25 public nsSupportsWeakReference {
26 public:
27 NS_DECL_ISUPPORTS
28 NS_DECL_NSISTORAGEACTIVITYSERVICE
29 NS_DECL_NSIOBSERVER
31 // Main-thread only.
32 static void SendActivity(nsIPrincipal* aPrincipal);
34 // Thread-safe.
35 static void SendActivity(const mozilla::ipc::PrincipalInfo& aPrincipalInfo);
37 // Thread-safe but for parent process only!
38 static void SendActivity(const nsACString& aOrigin);
40 // Used by XPCOM. Don't use it, use SendActivity() instead.
41 static already_AddRefed<StorageActivityService> GetOrCreate();
43 private:
44 StorageActivityService();
45 ~StorageActivityService();
47 void SendActivityInternal(nsIPrincipal* aPrincipal);
49 void SendActivityInternal(const nsACString& aOrigin);
51 void SendActivityToParent(nsIPrincipal* aPrincipal);
53 void CleanUp();
55 // Activities grouped by origin (+OriginAttributes).
56 nsTHashMap<nsCStringHashKey, PRTime> mActivities;
59 } // namespace dom
60 } // namespace mozilla
62 #endif // mozilla_dom_StorageActivityService_h