gecko-dev/dom/media/eme/DetailedPromise.h
Chris Pearce e156a08c17 Bug 1315850 - Rename DetailedPromise Status enum. r=gerald
X11.h #defines 'Status' and 'Failed' and 'Succeeded' which conflicts with
the enum in DetailedPromise. So rename the 'Status' enum in DetailedPromise
so that the build works on Linux.

Some of my changes here caused DetailedPromise to be included in more
places that it was before, which caused build failures on Linux.

MozReview-Commit-ID: KV5xKixXR3J

--HG--
extra : rebase_source : ef6cab901d74b78f613660f263f5e453d6044536
2017-03-13 10:42:36 +13:00

74 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __DetailedPromise_h__
#define __DetailedPromise_h__
#include "mozilla/dom/Promise.h"
#include "mozilla/Telemetry.h"
#include "EMEUtils.h"
namespace mozilla {
namespace dom {
/*
* This is pretty horrible; bug 1160445.
* Extend Promise to add custom DOMException messages on rejection.
* Get rid of this once we've ironed out EME errors in the wild.
*/
class DetailedPromise : public Promise
{
public:
static already_AddRefed<DetailedPromise>
Create(nsIGlobalObject* aGlobal,
ErrorResult& aRv,
const nsACString& aName);
static already_AddRefed<DetailedPromise>
Create(nsIGlobalObject* aGlobal, ErrorResult& aRv,
const nsACString& aName,
Telemetry::HistogramID aSuccessLatencyProbe,
Telemetry::HistogramID aFailureLatencyProbe);
template <typename T>
void MaybeResolve(const T& aArg)
{
EME_LOG("%s promise resolved", mName.get());
MaybeReportTelemetry(eStatus::kSucceeded);
Promise::MaybeResolve<T>(aArg);
}
void MaybeReject(nsresult aArg) = delete;
void MaybeReject(nsresult aArg, const nsACString& aReason);
void MaybeReject(ErrorResult& aArg) = delete;
void MaybeReject(ErrorResult&, const nsACString& aReason);
private:
explicit DetailedPromise(nsIGlobalObject* aGlobal,
const nsACString& aName);
explicit DetailedPromise(nsIGlobalObject* aGlobal,
const nsACString& aName,
Telemetry::HistogramID aSuccessLatencyProbe,
Telemetry::HistogramID aFailureLatencyProbe);
virtual ~DetailedPromise();
enum eStatus { kSucceeded, kFailed };
void MaybeReportTelemetry(eStatus aStatus);
nsCString mName;
bool mResponded;
TimeStamp mStartTime;
Optional<Telemetry::HistogramID> mSuccessLatencyProbe;
Optional<Telemetry::HistogramID> mFailureLatencyProbe;
};
} // namespace dom
} // namespace mozilla
#endif // __DetailedPromise_h__