Bug 1776444 [wpt PR 34582] - Revert "Add TimedHTMLParserBudget to fieldtrial_testing_...
[gecko.git] / dom / offline / nsDOMOfflineResourceList.h
blobbdc1c16ff47b2a1b22358d4a1a70732893114ae5
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 nsDOMOfflineResourceList_h___
8 #define nsDOMOfflineResourceList_h___
10 #include "nscore.h"
11 #include "nsTArray.h"
12 #include "nsString.h"
13 #include "nsIURI.h"
14 #include "nsCOMPtr.h"
15 #include "nsWeakReference.h"
16 #include "nsCOMArray.h"
17 #include "nsIObserver.h"
18 #include "nsIScriptContext.h"
19 #include "nsCycleCollectionParticipant.h"
20 #include "nsPIDOMWindow.h"
21 #include "mozilla/DOMEventTargetHelper.h"
22 #include "mozilla/ErrorResult.h"
23 #include "mozilla/Maybe.h"
25 namespace mozilla::dom {
26 class DOMStringList;
27 class Event;
28 } // namespace mozilla::dom
30 class nsDOMOfflineResourceList final : public mozilla::DOMEventTargetHelper,
31 public nsIObserver,
32 public nsSupportsWeakReference {
33 using ErrorResult = mozilla::ErrorResult;
35 public:
36 NS_DECL_ISUPPORTS_INHERITED
37 NS_DECL_NSIOBSERVER
39 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
40 mozilla::DOMEventTargetHelper)
42 nsDOMOfflineResourceList(nsIURI* aManifestURI, nsIURI* aDocumentURI,
43 nsIPrincipal* aLoadingPrincipal,
44 nsPIDOMWindowInner* aWindow);
46 void FirePendingEvents();
47 void Disconnect();
49 nsPIDOMWindowInner* GetParentObject() const { return GetOwner(); }
50 virtual JSObject* WrapObject(JSContext* aCx,
51 JS::Handle<JSObject*> aGivenProto) override;
53 uint16_t GetStatus(ErrorResult& aRv);
55 void Update(ErrorResult& aRv);
57 void SwapCache(ErrorResult& aRv);
59 IMPL_EVENT_HANDLER(checking)
60 IMPL_EVENT_HANDLER(error)
61 IMPL_EVENT_HANDLER(noupdate)
62 IMPL_EVENT_HANDLER(downloading)
63 IMPL_EVENT_HANDLER(progress)
64 IMPL_EVENT_HANDLER(cached)
65 IMPL_EVENT_HANDLER(updateready)
66 IMPL_EVENT_HANDLER(obsolete)
68 already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
69 bool MozHasItem(const nsAString& aURI, ErrorResult& aRv);
70 uint32_t GetMozLength(ErrorResult& aRv);
71 void MozItem(uint32_t aIndex, nsAString& aURI, ErrorResult& aRv);
72 void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aURI,
73 ErrorResult& aRv);
74 uint32_t Length() {
75 mozilla::IgnoredErrorResult rv;
76 uint32_t length = GetMozLength(rv);
77 return rv.Failed() ? 0 : length;
79 void MozAdd(const nsAString& aURI, ErrorResult& aRv);
80 void MozRemove(const nsAString& aURI, ErrorResult& aRv);
82 protected:
83 virtual ~nsDOMOfflineResourceList();
85 private:
86 void SendEvent(const nsAString& aEventName);
88 nsresult GetCacheKey(const nsAString& aURI, nsCString& aKey);
89 nsresult GetCacheKey(nsIURI* aURI, nsCString& aKey);
91 nsresult CacheKeys();
92 void ClearCachedKeys();
95 #endif