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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const std::string& error_message) = 0; | 65 const std::string& error_message) = 0; |
66 | 66 |
67 // Used to determine the template type of CdmPromiseTemplate<T> so that | 67 // Used to determine the template type of CdmPromiseTemplate<T> so that |
68 // saved CdmPromise objects can be cast to the correct templated version. | 68 // saved CdmPromise objects can be cast to the correct templated version. |
69 virtual ResolveParameterType GetResolveParameterType() const = 0; | 69 virtual ResolveParameterType GetResolveParameterType() const = 0; |
70 | 70 |
71 private: | 71 private: |
72 DISALLOW_COPY_AND_ASSIGN(CdmPromise); | 72 DISALLOW_COPY_AND_ASSIGN(CdmPromise); |
73 }; | 73 }; |
74 | 74 |
75 // For some reason the Windows compiler is not happy with the implementation | |
76 // of CdmPromiseTemplate being in the .cc file, so moving it here. | |
77 template <typename... T> | 75 template <typename... T> |
78 struct CdmPromiseTraits {}; | 76 struct CdmPromiseTraits {}; |
79 | 77 |
80 template <> | 78 template <> |
81 struct CdmPromiseTraits<> { | 79 struct MEDIA_EXPORT CdmPromiseTraits<> { |
82 static const CdmPromise::ResolveParameterType kType = CdmPromise::VOID_TYPE; | 80 static const CdmPromise::ResolveParameterType kType; |
83 }; | 81 }; |
84 | 82 |
85 template <> | 83 template <> |
86 struct CdmPromiseTraits<int> { | 84 struct MEDIA_EXPORT CdmPromiseTraits<int> { |
87 static const CdmPromise::ResolveParameterType kType = CdmPromise::INT_TYPE; | 85 static const CdmPromise::ResolveParameterType kType; |
88 }; | 86 }; |
89 | 87 |
90 template <> | 88 template <> |
91 struct CdmPromiseTraits<std::string> { | 89 struct MEDIA_EXPORT CdmPromiseTraits<std::string> { |
92 static const CdmPromise::ResolveParameterType kType = CdmPromise::STRING_TYPE; | 90 static const CdmPromise::ResolveParameterType kType; |
93 }; | 91 }; |
94 | 92 |
95 // This class adds the resolve(T) method. This class is still an interface, and | 93 // This class adds the resolve(T) method. This class is still an interface, and |
96 // is used as the type of promise that gets passed around. | 94 // is used as the type of promise that gets passed around. |
97 template <typename... T> | 95 template <typename... T> |
98 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { | 96 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { |
99 public: | 97 public: |
100 CdmPromiseTemplate() : is_settled_(false) {} | 98 CdmPromiseTemplate() : is_settled_(false) {} |
101 | 99 |
102 virtual ~CdmPromiseTemplate() { DCHECK(is_settled_); } | 100 virtual ~CdmPromiseTemplate() { DCHECK(is_settled_); } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 private: | 135 private: |
138 // Keep track of whether the promise has been resolved or rejected yet. | 136 // Keep track of whether the promise has been resolved or rejected yet. |
139 bool is_settled_; | 137 bool is_settled_; |
140 | 138 |
141 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); | 139 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); |
142 }; | 140 }; |
143 | 141 |
144 } // namespace media | 142 } // namespace media |
145 | 143 |
146 #endif // MEDIA_BASE_CDM_PROMISE_H_ | 144 #endif // MEDIA_BASE_CDM_PROMISE_H_ |
OLD | NEW |