Shaka Player Embedded
eme_promise.h
Go to the documentation of this file.
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SHAKA_EMBEDDED_EME_PROMISE_H_
16 #define SHAKA_EMBEDDED_EME_PROMISE_H_
17 
18 #include <memory>
19 #include <string>
20 
21 #include "configuration.h"
22 
23 namespace shaka {
24 
25 class Promise;
26 
27 namespace js {
28 namespace eme {
29 class MediaKeys;
30 class MediaKeySession;
31 } // namespace eme
32 } // namespace js
33 
34 namespace eme {
35 
47 class SHAKA_EXPORT EmePromise final {
48  public:
53  EmePromise();
54 
55  EmePromise(const EmePromise& other);
56  EmePromise(EmePromise&& other);
57  ~EmePromise();
58 
59  EmePromise& operator=(const EmePromise& other);
60  EmePromise& operator=(EmePromise&& other);
61 
63  bool valid() const;
64 
69  void Resolve();
70 
75  void ResolveWith(bool value);
76 
81  void Reject(ExceptionType except_type, const std::string& message);
82 
83  private:
84  class Impl;
85 
86  friend class ClearKeyImplementationTest;
87  friend class js::eme::MediaKeys;
89  EmePromise(const Promise& promise, bool has_value);
90  EmePromise(std::shared_ptr<Impl> impl);
91 
92  std::shared_ptr<Impl> impl_;
93 };
94 
95 } // namespace eme
96 } // namespace shaka
97 
98 #endif // SHAKA_EMBEDDED_EME_PROMISE_H_
#define SHAKA_EXPORT
Definition: macros.h:30
const char * message