2014-06-06 20:52:15 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 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 mozilla_dom_MediaKeySession_h
|
|
|
|
#define mozilla_dom_MediaKeySession_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "mozilla/dom/Date.h"
|
|
|
|
#include "mozilla/dom/Promise.h"
|
|
|
|
#include "mozilla/dom/MediaKeySessionBinding.h"
|
|
|
|
#include "mozilla/dom/MediaKeysBinding.h"
|
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class CDMProxy;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
2014-10-01 18:43:26 +00:00
|
|
|
class ArrayBufferViewOrArrayBuffer;
|
2014-06-06 20:52:15 +00:00
|
|
|
class MediaKeyError;
|
|
|
|
|
|
|
|
class MediaKeySession MOZ_FINAL : public DOMEventTargetHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaKeySession,
|
|
|
|
DOMEventTargetHelper)
|
|
|
|
public:
|
|
|
|
MediaKeySession(nsPIDOMWindow* aParent,
|
|
|
|
MediaKeys* aKeys,
|
|
|
|
const nsAString& aKeySystem,
|
2014-07-19 01:31:11 +00:00
|
|
|
SessionType aSessionType,
|
|
|
|
ErrorResult& aRv);
|
2014-06-06 20:52:15 +00:00
|
|
|
|
|
|
|
void Init(const nsAString& aSessionId);
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
// Mark this as resultNotAddRefed to return raw pointers
|
|
|
|
MediaKeyError* GetError() const;
|
|
|
|
|
|
|
|
void GetKeySystem(nsString& aRetval) const;
|
|
|
|
|
|
|
|
void GetSessionId(nsString& aRetval) const;
|
|
|
|
|
2014-07-30 06:53:28 +00:00
|
|
|
const nsString& GetSessionId() const;
|
|
|
|
|
2014-06-06 20:52:15 +00:00
|
|
|
// Number of ms since epoch at which expiration occurs, or NaN if unknown.
|
|
|
|
// TODO: The type of this attribute is still under contention.
|
|
|
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=25902
|
|
|
|
double Expiration() const;
|
|
|
|
|
|
|
|
Promise* Closed() const;
|
|
|
|
|
2014-09-23 22:04:49 +00:00
|
|
|
already_AddRefed<Promise> GenerateRequest(const nsAString& aInitDataType,
|
|
|
|
const ArrayBufferViewOrArrayBuffer& aInitData,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<Promise> Load(const nsAString& aSessionId,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2014-08-27 08:46:56 +00:00
|
|
|
already_AddRefed<Promise> Update(const ArrayBufferViewOrArrayBuffer& response,
|
2014-07-19 01:31:11 +00:00
|
|
|
ErrorResult& aRv);
|
2014-06-06 20:52:15 +00:00
|
|
|
|
2014-07-19 01:31:11 +00:00
|
|
|
already_AddRefed<Promise> Close(ErrorResult& aRv);
|
2014-06-06 20:52:15 +00:00
|
|
|
|
2014-07-19 01:31:11 +00:00
|
|
|
already_AddRefed<Promise> Remove(ErrorResult& aRv);
|
2014-06-06 20:52:15 +00:00
|
|
|
|
2014-08-27 08:46:56 +00:00
|
|
|
already_AddRefed<Promise> GetUsableKeyIds(ErrorResult& aRv);
|
|
|
|
|
2014-06-06 20:52:15 +00:00
|
|
|
void DispatchKeyMessage(const nsTArray<uint8_t>& aMessage,
|
2014-07-30 06:53:28 +00:00
|
|
|
const nsAString& aURL);
|
2014-06-06 20:52:15 +00:00
|
|
|
|
|
|
|
void DispatchKeyError(uint32_t system_code);
|
|
|
|
|
2014-10-15 08:33:18 +00:00
|
|
|
void DispatchKeysChange();
|
|
|
|
|
2014-06-06 20:52:15 +00:00
|
|
|
void OnClosed();
|
|
|
|
|
|
|
|
bool IsClosed() const;
|
|
|
|
|
|
|
|
private:
|
2014-07-08 21:23:17 +00:00
|
|
|
~MediaKeySession();
|
|
|
|
|
2014-06-06 20:52:15 +00:00
|
|
|
nsRefPtr<Promise> mClosed;
|
|
|
|
|
|
|
|
nsRefPtr<MediaKeyError> mMediaKeyError;
|
|
|
|
nsRefPtr<MediaKeys> mKeys;
|
|
|
|
const nsString mKeySystem;
|
|
|
|
nsString mSessionId;
|
|
|
|
const SessionType mSessionType;
|
|
|
|
bool mIsClosed;
|
2014-09-23 22:04:49 +00:00
|
|
|
bool mUninitialized;
|
2014-06-06 20:52:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|