author Ehsan Akhgari <>
Sat, 21 Mar 2015 12:28:04 -0400
changeset 234933 ac4464790ec4896a5188fa50cfc69ae0ffeddc08
parent 234479 0b0c492a33b545fb9daa9b041969e17b5dcbe00e
child 240463 29bf41172acdd5a120955f63983a6625dff84f5a
permissions -rw-r--r--
Bug 1145631 - Part 1: Replace MOZ_OVERRIDE and MOZ_FINAL with override and final in the tree; r=froydnj This patch was automatically generated using the following script: function convert() { echo "Converting $1 to $2..." find . \ ! -wholename "*/.git*" \ ! -wholename "obj-ff-dbg*" \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert MOZ_OVERRIDE override convert MOZ_FINAL final

/* -*- 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 */

#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"
#include "mozilla/dom/MediaKeyMessageEventBinding.h"

struct JSContext;

namespace mozilla {

class CDMProxy;

namespace dom {

class ArrayBufferViewOrArrayBuffer;
class MediaKeyError;
class MediaKeyStatusMap;

class MediaKeySession final : public DOMEventTargetHelper
  MediaKeySession(JSContext* aCx,
                  nsPIDOMWindow* aParent,
                  MediaKeys* aKeys,
                  const nsAString& aKeySystem,
                  SessionType aSessionType,
                  ErrorResult& aRv);

  void SetSessionId(const nsAString& aSessionId);

  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;

  // Mark this as resultNotAddRefed to return raw pointers
  MediaKeyError* GetError() const;

  MediaKeyStatusMap* KeyStatuses() const;

  void GetKeySystem(nsString& aRetval) const;

  void GetSessionId(nsString& aRetval) const;

  const nsString& GetSessionId() const;

  // Number of ms since epoch at which expiration occurs, or NaN if unknown.
  // TODO: The type of this attribute is still under contention.
  double Expiration() const;

  Promise* Closed() const;

  already_AddRefed<Promise> GenerateRequest(const nsAString& aInitDataType,
                                            const ArrayBufferViewOrArrayBuffer& aInitData,
                                            ErrorResult& aRv);

  already_AddRefed<Promise> Load(const nsAString& aSessionId,
                                 ErrorResult& aRv);

  already_AddRefed<Promise> Update(const ArrayBufferViewOrArrayBuffer& response,
                                   ErrorResult& aRv);

  already_AddRefed<Promise> Close(ErrorResult& aRv);

  already_AddRefed<Promise> Remove(ErrorResult& aRv);

  void DispatchKeyMessage(MediaKeyMessageType aMessageType,
                          const nsTArray<uint8_t>& aMessage);

  void DispatchKeyError(uint32_t system_code);

  void DispatchKeyStatusesChange();

  void OnClosed();

  bool IsClosed() const;

  // Process-unique identifier.
  uint32_t Token() const;


  void UpdateKeyStatusMap();

  nsRefPtr<Promise> mClosed;

  nsRefPtr<MediaKeyError> mMediaKeyError;
  nsRefPtr<MediaKeys> mKeys;
  const nsString mKeySystem;
  nsString mSessionId;
  const SessionType mSessionType;
  const uint32_t mToken;
  bool mIsClosed;
  bool mUninitialized;
  nsRefPtr<MediaKeyStatusMap> mKeyStatusMap;

} // namespace dom
} // namespace mozilla