OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_CDM_PROMISE_H_ | 5 #ifndef MEDIA_BASE_CDM_PROMISE_H_ |
6 #define MEDIA_BASE_CDM_PROMISE_H_ | 6 #define MEDIA_BASE_CDM_PROMISE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 virtual ~CdmPromiseTemplate() { DCHECK(is_settled_); } | 90 virtual ~CdmPromiseTemplate() { DCHECK(is_settled_); } |
91 | 91 |
92 virtual void resolve(const T&... result) = 0; | 92 virtual void resolve(const T&... result) = 0; |
93 | 93 |
94 // CdmPromise implementation. | 94 // CdmPromise implementation. |
95 virtual void reject(MediaKeys::Exception exception_code, | 95 virtual void reject(MediaKeys::Exception exception_code, |
96 uint32 system_code, | 96 uint32 system_code, |
97 const std::string& error_message) = 0; | 97 const std::string& error_message) = 0; |
98 | 98 |
99 virtual ResolveParameterType GetResolveParameterType() const override { | 99 ResolveParameterType GetResolveParameterType() const override { |
100 return CdmPromiseTraits<T...>::kType; | 100 return CdmPromiseTraits<T...>::kType; |
101 } | 101 } |
102 | 102 |
103 protected: | 103 protected: |
104 // All implementations must call this method in resolve() and reject() methods | 104 // All implementations must call this method in resolve() and reject() methods |
105 // to indicate that the promise has been settled. | 105 // to indicate that the promise has been settled. |
106 void MarkPromiseSettled() { | 106 void MarkPromiseSettled() { |
107 // Promise can only be settled once. | 107 // Promise can only be settled once. |
108 DCHECK(!is_settled_); | 108 DCHECK(!is_settled_); |
109 is_settled_ = true; | 109 is_settled_ = true; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 // Keep track of whether the promise has been resolved or rejected yet. | 113 // Keep track of whether the promise has been resolved or rejected yet. |
114 bool is_settled_; | 114 bool is_settled_; |
115 | 115 |
116 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); | 116 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); |
117 }; | 117 }; |
118 | 118 |
119 } // namespace media | 119 } // namespace media |
120 | 120 |
121 #endif // MEDIA_BASE_CDM_PROMISE_H_ | 121 #endif // MEDIA_BASE_CDM_PROMISE_H_ |
OLD | NEW |