| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // Used to determine the template type of CdmPromiseTemplate<T> so that | 50 // Used to determine the template type of CdmPromiseTemplate<T> so that |
| 51 // saved CdmPromise objects can be cast to the correct templated version. | 51 // saved CdmPromise objects can be cast to the correct templated version. |
| 52 virtual ResolveParameterType GetResolveParameterType() const = 0; | 52 virtual ResolveParameterType GetResolveParameterType() const = 0; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(CdmPromise); | 55 DISALLOW_COPY_AND_ASSIGN(CdmPromise); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // For some reason the Windows compiler is not happy with the implementation | 58 // For some reason the Windows compiler is not happy with the implementation |
| 59 // of CdmPromiseTemplate being in the .cc file, so moving it here. | 59 // of CdmPromiseTemplate being in the .cc file, so moving it here. |
| 60 namespace { | |
| 61 | |
| 62 template <typename... T> | 60 template <typename... T> |
| 63 struct CdmPromiseTraits {}; | 61 struct CdmPromiseTraits {}; |
| 64 | 62 |
| 65 template <> | 63 template <> |
| 66 struct CdmPromiseTraits<> { | 64 struct CdmPromiseTraits<> { |
| 67 static const CdmPromise::ResolveParameterType kType = CdmPromise::VOID_TYPE; | 65 static const CdmPromise::ResolveParameterType kType = CdmPromise::VOID_TYPE; |
| 68 }; | 66 }; |
| 69 | 67 |
| 70 template <> | 68 template <> |
| 71 struct CdmPromiseTraits<std::string> { | 69 struct CdmPromiseTraits<std::string> { |
| 72 static const CdmPromise::ResolveParameterType kType = CdmPromise::STRING_TYPE; | 70 static const CdmPromise::ResolveParameterType kType = CdmPromise::STRING_TYPE; |
| 73 }; | 71 }; |
| 74 | 72 |
| 75 } // namespace | |
| 76 | |
| 77 // This class adds the resolve(T) method. This class is still an interface, and | 73 // This class adds the resolve(T) method. This class is still an interface, and |
| 78 // is used as the type of promise that gets passed around. | 74 // is used as the type of promise that gets passed around. |
| 79 template <typename... T> | 75 template <typename... T> |
| 80 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { | 76 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { |
| 81 public: | 77 public: |
| 82 CdmPromiseTemplate() : is_settled_(false) {} | 78 CdmPromiseTemplate() : is_settled_(false) {} |
| 83 | 79 |
| 84 virtual ~CdmPromiseTemplate() { DCHECK(is_settled_); } | 80 virtual ~CdmPromiseTemplate() { DCHECK(is_settled_); } |
| 85 | 81 |
| 86 virtual void resolve(const T&... result) = 0; | 82 virtual void resolve(const T&... result) = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 106 private: | 102 private: |
| 107 // Keep track of whether the promise has been resolved or rejected yet. | 103 // Keep track of whether the promise has been resolved or rejected yet. |
| 108 bool is_settled_; | 104 bool is_settled_; |
| 109 | 105 |
| 110 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); | 106 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); |
| 111 }; | 107 }; |
| 112 | 108 |
| 113 } // namespace media | 109 } // namespace media |
| 114 | 110 |
| 115 #endif // MEDIA_BASE_CDM_PROMISE_H_ | 111 #endif // MEDIA_BASE_CDM_PROMISE_H_ |
| OLD | NEW |