/work/obj-fuzz/dist/include/mozilla/DetailedPromise.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=2 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 file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef __DetailedPromise_h__ |
8 | | #define __DetailedPromise_h__ |
9 | | |
10 | | #include "mozilla/dom/Promise.h" |
11 | | #include "mozilla/Telemetry.h" |
12 | | #include "EMEUtils.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | /* |
18 | | * This is pretty horrible; bug 1160445. |
19 | | * Extend Promise to add custom DOMException messages on rejection. |
20 | | * Get rid of this once we've ironed out EME errors in the wild. |
21 | | */ |
22 | | class DetailedPromise : public Promise |
23 | | { |
24 | | public: |
25 | | static already_AddRefed<DetailedPromise> |
26 | | Create(nsIGlobalObject* aGlobal, |
27 | | ErrorResult& aRv, |
28 | | const nsACString& aName); |
29 | | |
30 | | static already_AddRefed<DetailedPromise> |
31 | | Create(nsIGlobalObject* aGlobal, ErrorResult& aRv, |
32 | | const nsACString& aName, |
33 | | Telemetry::HistogramID aSuccessLatencyProbe, |
34 | | Telemetry::HistogramID aFailureLatencyProbe); |
35 | | |
36 | | template <typename T> |
37 | | void MaybeResolve(T&& aArg) |
38 | 0 | { |
39 | 0 | EME_LOG("%s promise resolved", mName.get()); |
40 | 0 | MaybeReportTelemetry(eStatus::kSucceeded); |
41 | 0 | Promise::MaybeResolve(std::forward<T>(aArg)); |
42 | 0 | } Unexecuted instantiation: void mozilla::dom::DetailedPromise::MaybeResolve<RefPtr<mozilla::dom::MediaKeySystemAccess>&>(RefPtr<mozilla::dom::MediaKeySystemAccess>&) Unexecuted instantiation: void mozilla::dom::DetailedPromise::MaybeResolve<RefPtr<mozilla::dom::MediaKeySession>&>(RefPtr<mozilla::dom::MediaKeySession>&) Unexecuted instantiation: void mozilla::dom::DetailedPromise::MaybeResolve<RefPtr<mozilla::dom::MediaKeys>&>(RefPtr<mozilla::dom::MediaKeys>&) Unexecuted instantiation: void mozilla::dom::DetailedPromise::MaybeResolve<bool&>(bool&) Unexecuted instantiation: void mozilla::dom::DetailedPromise::MaybeResolve<mozilla::dom::MediaKeyStatus&>(mozilla::dom::MediaKeyStatus&) |
43 | | |
44 | | void MaybeReject(nsresult aArg) = delete; |
45 | | void MaybeReject(nsresult aArg, const nsACString& aReason); |
46 | | |
47 | | void MaybeReject(ErrorResult& aArg) = delete; |
48 | | void MaybeReject(ErrorResult&, const nsACString& aReason); |
49 | | |
50 | | private: |
51 | | explicit DetailedPromise(nsIGlobalObject* aGlobal, |
52 | | const nsACString& aName); |
53 | | |
54 | | explicit DetailedPromise(nsIGlobalObject* aGlobal, |
55 | | const nsACString& aName, |
56 | | Telemetry::HistogramID aSuccessLatencyProbe, |
57 | | Telemetry::HistogramID aFailureLatencyProbe); |
58 | | virtual ~DetailedPromise(); |
59 | | |
60 | | enum eStatus { kSucceeded, kFailed }; |
61 | | void MaybeReportTelemetry(eStatus aStatus); |
62 | | |
63 | | nsCString mName; |
64 | | bool mResponded; |
65 | | TimeStamp mStartTime; |
66 | | Optional<Telemetry::HistogramID> mSuccessLatencyProbe; |
67 | | Optional<Telemetry::HistogramID> mFailureLatencyProbe; |
68 | | }; |
69 | | |
70 | | } // namespace dom |
71 | | } // namespace mozilla |
72 | | |
73 | | #endif // __DetailedPromise_h__ |