summaryrefslogtreecommitdiffstats
path: root/media/mojo/services/mojo_cdm_promise.h
blob: e2797c220444616e7d4bb2d4744be674cb5be5ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_
#define MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_

#include <stdint.h>

#include "base/macros.h"
#include "media/base/cdm_promise.h"
#include "media/mojo/interfaces/content_decryption_module.mojom.h"
#include "media/mojo/services/mojo_type_trait.h"
#include "mojo/public/cpp/bindings/callback.h"

namespace media {

// media::CdmPromiseTemplate implementations backed by mojo::Callbacks.
template <typename... T>
class MojoCdmPromise : public CdmPromiseTemplate<T...> {
 public:
  typedef mojo::Callback<void(interfaces::CdmPromiseResultPtr,
                              typename MojoTypeTrait<T>::MojoType...)>
      CallbackType;

  MojoCdmPromise(const CallbackType& callback);
  ~MojoCdmPromise() final;

  // CdmPromiseTemplate<> implementation.
  void resolve(const T&... result) final;
  void reject(MediaKeys::Exception exception,
              uint32_t system_code,
              const std::string& error_message) final;

 private:
  using CdmPromiseTemplate<T...>::IsPromiseSettled;
  using CdmPromiseTemplate<T...>::MarkPromiseSettled;
  using CdmPromiseTemplate<T...>::RejectPromiseOnDestruction;

  CallbackType callback_;
};

}  // namespace media

#endif  // MEDIA_MOJO_SERVICES_MOJO_CDM_PROMISE_H_