Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 NOT_SUPPORTED_ERROR, | 28 NOT_SUPPORTED_ERROR, |
| 29 INVALID_STATE_ERROR, | 29 INVALID_STATE_ERROR, |
| 30 INVALID_ACCESS_ERROR, | 30 INVALID_ACCESS_ERROR, |
| 31 QUOTA_EXCEEDED_ERROR, | 31 QUOTA_EXCEEDED_ERROR, |
| 32 UNKNOWN_ERROR, | 32 UNKNOWN_ERROR, |
| 33 CLIENT_ERROR, | 33 CLIENT_ERROR, |
| 34 OUTPUT_ERROR, | 34 OUTPUT_ERROR, |
| 35 NUM_RESULT_CODES | 35 NUM_RESULT_CODES |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 enum ResolveParameterType { | |
| 39 VOID_TYPE, | |
| 40 STRING_TYPE, | |
| 41 KEY_IDS_VECTOR_TYPE, | |
|
xhwang
2014/08/27 22:49:26
nit: no trailing comma to be consistent
jrummell
2014/08/27 23:05:13
Done. The enum above has NUM_RESULT_CODES as alway
| |
| 42 }; | |
| 43 | |
| 38 typedef base::Callback<void(MediaKeys::Exception exception_code, | 44 typedef base::Callback<void(MediaKeys::Exception exception_code, |
| 39 uint32 system_code, | 45 uint32 system_code, |
| 40 const std::string& error_message)> | 46 const std::string& error_message)> |
| 41 PromiseRejectedCB; | 47 PromiseRejectedCB; |
| 42 | 48 |
| 43 virtual ~CdmPromise(); | 49 virtual ~CdmPromise(); |
| 44 | 50 |
| 45 // Used to indicate that the operation failed. |exception_code| must be | 51 // Used to indicate that the operation failed. |exception_code| must be |
| 46 // specified. |system_code| is a Key System-specific value for the error | 52 // specified. |system_code| is a Key System-specific value for the error |
| 47 // that occurred, or 0 if there is no associated status code or such status | 53 // that occurred, or 0 if there is no associated status code or such status |
| 48 // codes are not supported by the Key System. |error_message| is optional. | 54 // codes are not supported by the Key System. |error_message| is optional. |
| 49 virtual void reject(MediaKeys::Exception exception_code, | 55 virtual void reject(MediaKeys::Exception exception_code, |
| 50 uint32 system_code, | 56 uint32 system_code, |
| 51 const std::string& error_message); | 57 const std::string& error_message); |
| 52 | 58 |
| 59 virtual ResolveParameterType GetResolveParameterType() const = 0; | |
| 60 | |
| 53 protected: | 61 protected: |
| 54 CdmPromise(); | 62 CdmPromise(); |
| 55 CdmPromise(PromiseRejectedCB reject_cb); | 63 CdmPromise(PromiseRejectedCB reject_cb); |
| 56 | 64 |
| 57 // If constructed with a |uma_name| (which must be the name of a | 65 // If constructed with a |uma_name| (which must be the name of a |
| 58 // CdmPromiseResult UMA), CdmPromise will report the promise result (success | 66 // CdmPromiseResult UMA), CdmPromise will report the promise result (success |
| 59 // or rejection code). | 67 // or rejection code). |
| 60 CdmPromise(PromiseRejectedCB reject_cb, const std::string& uma_name); | 68 CdmPromise(PromiseRejectedCB reject_cb, const std::string& uma_name); |
| 61 | 69 |
| 62 PromiseRejectedCB reject_cb_; | 70 PromiseRejectedCB reject_cb_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 73 template <typename T> | 81 template <typename T> |
| 74 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { | 82 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { |
| 75 public: | 83 public: |
| 76 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb, | 84 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb, |
| 77 PromiseRejectedCB rejected_cb); | 85 PromiseRejectedCB rejected_cb); |
| 78 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb, | 86 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb, |
| 79 PromiseRejectedCB rejected_cb, | 87 PromiseRejectedCB rejected_cb, |
| 80 const std::string& uma_name); | 88 const std::string& uma_name); |
| 81 virtual ~CdmPromiseTemplate(); | 89 virtual ~CdmPromiseTemplate(); |
| 82 virtual void resolve(const T& result); | 90 virtual void resolve(const T& result); |
| 91 virtual ResolveParameterType GetResolveParameterType() const OVERRIDE; | |
| 83 | 92 |
| 84 protected: | 93 protected: |
| 85 // Allow subclasses to completely override the implementation. | 94 // Allow subclasses to completely override the implementation. |
| 86 // TODO(jrummell): Remove when derived class SessionLoadedPromise | 95 // TODO(jrummell): Remove when derived class SessionLoadedPromise |
| 87 // (in ppapi_decryptor.cc) is no longer needed. | 96 // (in ppapi_decryptor.cc) is no longer needed. |
| 88 CdmPromiseTemplate(); | 97 CdmPromiseTemplate(); |
| 89 | 98 |
| 90 private: | 99 private: |
| 91 base::Callback<void(const T&)> resolve_cb_; | 100 base::Callback<void(const T&)> resolve_cb_; |
| 92 | 101 |
| 93 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); | 102 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); |
| 94 }; | 103 }; |
| 95 | 104 |
| 96 // Specialization for no parameter to resolve(). | 105 // Specialization for no parameter to resolve(). |
| 97 template <> | 106 template <> |
| 98 class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise { | 107 class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise { |
| 99 public: | 108 public: |
| 100 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb, | 109 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb, |
| 101 PromiseRejectedCB rejected_cb); | 110 PromiseRejectedCB rejected_cb); |
| 102 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb, | 111 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb, |
| 103 PromiseRejectedCB rejected_cb, | 112 PromiseRejectedCB rejected_cb, |
| 104 const std::string& uma_name); | 113 const std::string& uma_name); |
| 105 virtual ~CdmPromiseTemplate(); | 114 virtual ~CdmPromiseTemplate(); |
| 106 virtual void resolve(); | 115 virtual void resolve(); |
| 116 virtual ResolveParameterType GetResolveParameterType() const OVERRIDE; | |
| 107 | 117 |
| 108 protected: | 118 protected: |
| 109 // Allow subclasses to completely override the implementation. | 119 // Allow subclasses to completely override the implementation. |
| 110 CdmPromiseTemplate(); | 120 CdmPromiseTemplate(); |
| 111 | 121 |
| 112 private: | 122 private: |
| 113 base::Callback<void(void)> resolve_cb_; | 123 base::Callback<void(void)> resolve_cb_; |
| 114 | 124 |
| 115 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); | 125 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); |
| 116 }; | 126 }; |
| 117 | 127 |
| 118 } // namespace media | 128 } // namespace media |
| 119 | 129 |
| 120 #endif // MEDIA_BASE_CDM_PROMISE_H_ | 130 #endif // MEDIA_BASE_CDM_PROMISE_H_ |
| OLD | NEW |