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_FetchController_h
8 : #define mozilla_dom_FetchController_h
9 :
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/FetchSignal.h"
12 : #include "nsCycleCollectionParticipant.h"
13 : #include "nsWrapperCache.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class FetchController final : public nsISupports
19 : , public nsWrapperCache
20 : , public FetchSignal::Follower
21 : {
22 : public:
23 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
24 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FetchController)
25 :
26 : static bool
27 : IsEnabled(JSContext* aCx, JSObject* aGlobal);
28 :
29 : static already_AddRefed<FetchController>
30 : Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
31 :
32 : explicit FetchController(nsIGlobalObject* aGlobal);
33 :
34 : JSObject*
35 : WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
36 :
37 : nsIGlobalObject*
38 : GetParentObject() const;
39 :
40 : FetchSignal*
41 : Signal();
42 :
43 : void
44 : Abort();
45 :
46 : void
47 : Follow(FetchSignal& aSignal);
48 :
49 : void
50 : Unfollow(FetchSignal& aSignal);
51 :
52 : FetchSignal*
53 : Following() const;
54 :
55 : // FetchSignal::Follower
56 :
57 : void Aborted() override;
58 :
59 : private:
60 0 : ~FetchController() = default;
61 :
62 : nsCOMPtr<nsIGlobalObject> mGlobal;
63 : RefPtr<FetchSignal> mSignal;
64 :
65 : bool mAborted;
66 : };
67 :
68 : } // dom namespace
69 : } // mozilla namespace
70 :
71 : #endif // mozilla_dom_FetchController_h
|