Bug 1712849 [wpt PR 29110] - Keep 3D points in a quad coplanar when clamping them...
[gecko.git] / intl / strres / nsStringBundleService.h
blobf6d54227a03263a37a7b918aa709a3f1b6055df1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsStringBundleService_h__
7 #define nsStringBundleService_h__
9 #include "nsCOMPtr.h"
10 #include "nsTHashMap.h"
11 #include "nsHashKeys.h"
12 #include "nsIStringBundle.h"
13 #include "nsIObserver.h"
14 #include "nsWeakReference.h"
15 #include "nsIErrorService.h"
16 #include "nsIMemoryReporter.h"
18 #include "mozilla/LinkedList.h"
19 #include "mozilla/UniquePtr.h"
21 struct bundleCacheEntry_t;
23 class nsStringBundleService : public nsIStringBundleService,
24 public nsIObserver,
25 public nsSupportsWeakReference,
26 public nsIMemoryReporter {
27 MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf);
29 public:
30 nsStringBundleService();
32 nsresult Init();
34 NS_DECL_ISUPPORTS
35 NS_DECL_NSISTRINGBUNDLESERVICE
36 NS_DECL_NSIOBSERVER
38 NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
39 nsISupports* aData, bool anonymize) override {
40 size_t amt = SizeOfIncludingThis(MallocSizeOf);
42 MOZ_COLLECT_REPORT("explicit/string-bundles/service", KIND_HEAP,
43 UNITS_BYTES, amt,
44 "Memory used for StringBundleService overhead");
45 return NS_OK;
48 size_t SizeOfIncludingThis(
49 mozilla::MallocSizeOf aMallocSizeOf) const override;
51 void SendContentBundles(
52 mozilla::dom::ContentParent* aContentParent) const override;
54 void RegisterContentBundle(const nsCString& aBundleURL,
55 const mozilla::ipc::FileDescriptor& aMapFile,
56 size_t aMapSize) override;
58 private:
59 virtual ~nsStringBundleService();
61 void getStringBundle(const char* aUrl, nsIStringBundle** aResult);
62 nsresult FormatWithBundle(nsIStringBundle* bundle, nsresult aStatus,
63 const nsTArray<nsString>& argArray,
64 nsAString& result);
66 void flushBundleCache(bool ignoreShared = true);
68 mozilla::UniquePtr<bundleCacheEntry_t> evictOneEntry();
70 bundleCacheEntry_t* insertIntoCache(already_AddRefed<nsIStringBundle> aBundle,
71 const nsACString& aHashKey);
73 nsTHashMap<nsCStringHashKey, bundleCacheEntry_t*> mBundleMap;
74 // LRU list of cached entries, with the least-recently-used entry first.
75 mozilla::LinkedList<bundleCacheEntry_t> mBundleCache;
76 // List of cached shared-memory string bundles, in arbitrary order.
77 mozilla::AutoCleanLinkedList<bundleCacheEntry_t> mSharedBundles;
79 nsCOMPtr<nsIErrorService> mErrorService;
82 #endif