Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: media/base/cdm_promise.h

Issue 496143002: Update Pepper interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reorder Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 PromiseType {
39 UNKNOWN_TYPE,
40 SIMPLE_TYPE,
41 NEW_SESSION_TYPE,
42 KEY_IDS_TYPE
43 };
44
38 typedef base::Callback<void(MediaKeys::Exception exception_code, 45 typedef base::Callback<void(MediaKeys::Exception exception_code,
39 uint32 system_code, 46 uint32 system_code,
40 const std::string& error_message)> 47 const std::string& error_message)>
41 PromiseRejectedCB; 48 PromiseRejectedCB;
42 49
43 virtual ~CdmPromise(); 50 virtual ~CdmPromise();
44 51
45 // Used to indicate that the operation failed. |exception_code| must be 52 // Used to indicate that the operation failed. |exception_code| must be
46 // specified. |system_code| is a Key System-specific value for the error 53 // 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 54 // 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. 55 // codes are not supported by the Key System. |error_message| is optional.
49 virtual void reject(MediaKeys::Exception exception_code, 56 virtual void reject(MediaKeys::Exception exception_code,
ddorwin 2014/08/25 22:55:01 Not now, but this should be _R_eject.
jrummell 2014/08/26 00:19:23 Acknowledged.
50 uint32 system_code, 57 uint32 system_code,
51 const std::string& error_message); 58 const std::string& error_message);
52 59
60 virtual PromiseType Type();
ddorwin 2014/08/25 22:55:01 Since this is a getter, it should be type(). Also,
jrummell 2014/08/26 00:19:23 Done.
61
53 protected: 62 protected:
54 CdmPromise(); 63 CdmPromise();
55 CdmPromise(PromiseRejectedCB reject_cb); 64 CdmPromise(PromiseRejectedCB reject_cb);
56 65
57 // If constructed with a |uma_name| (which must be the name of a 66 // If constructed with a |uma_name| (which must be the name of a
58 // CdmPromiseResult UMA), CdmPromise will report the promise result (success 67 // CdmPromiseResult UMA), CdmPromise will report the promise result (success
59 // or rejection code). 68 // or rejection code).
60 CdmPromise(PromiseRejectedCB reject_cb, const std::string& uma_name); 69 CdmPromise(PromiseRejectedCB reject_cb, const std::string& uma_name);
61 70
62 PromiseRejectedCB reject_cb_; 71 PromiseRejectedCB reject_cb_;
63 72
64 // Keep track of whether the promise hasn't been resolved or rejected yet. 73 // Keep track of whether the promise hasn't been resolved or rejected yet.
65 bool is_pending_; 74 bool is_pending_;
66 75
67 // UMA to report result to. 76 // UMA to report result to.
68 std::string uma_name_; 77 std::string uma_name_;
69 78
70 DISALLOW_COPY_AND_ASSIGN(CdmPromise); 79 DISALLOW_COPY_AND_ASSIGN(CdmPromise);
71 }; 80 };
72 81
73 template <typename T> 82 template <typename T>
74 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise { 83 class MEDIA_EXPORT CdmPromiseTemplate : public CdmPromise {
75 public: 84 public:
76 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb, 85 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb,
77 PromiseRejectedCB rejected_cb); 86 PromiseRejectedCB rejected_cb);
78 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb, 87 CdmPromiseTemplate(base::Callback<void(const T&)> resolve_cb,
79 PromiseRejectedCB rejected_cb, 88 PromiseRejectedCB rejected_cb,
80 const std::string& uma_name); 89 const std::string& uma_name);
81 virtual ~CdmPromiseTemplate(); 90 virtual ~CdmPromiseTemplate();
82 virtual void resolve(const T& result); 91 virtual void resolve(const T& result);
ddorwin 2014/08/25 22:55:01 Not now, but this should be _R_esolve.
jrummell 2014/08/26 00:19:23 Acknowledged.
92 virtual PromiseType Type();
ddorwin 2014/08/25 22:55:01 Do we need this and l60? Would it be better to ini
jrummell 2014/08/26 00:19:23 Since this is a template, I can't find any easy wa
83 93
84 protected: 94 protected:
85 // Allow subclasses to completely override the implementation. 95 // Allow subclasses to completely override the implementation.
86 // TODO(jrummell): Remove when derived class SessionLoadedPromise 96 // TODO(jrummell): Remove when derived class SessionLoadedPromise
87 // (in ppapi_decryptor.cc) is no longer needed. 97 // (in ppapi_decryptor.cc) is no longer needed.
88 CdmPromiseTemplate(); 98 CdmPromiseTemplate();
89 99
90 private: 100 private:
91 base::Callback<void(const T&)> resolve_cb_; 101 base::Callback<void(const T&)> resolve_cb_;
92 102
93 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); 103 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
94 }; 104 };
95 105
96 // Specialization for no parameter to resolve(). 106 // Specialization for no parameter to resolve().
97 template <> 107 template <>
98 class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise { 108 class MEDIA_EXPORT CdmPromiseTemplate<void> : public CdmPromise {
99 public: 109 public:
100 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb, 110 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
101 PromiseRejectedCB rejected_cb); 111 PromiseRejectedCB rejected_cb);
102 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb, 112 CdmPromiseTemplate(base::Callback<void(void)> resolve_cb,
103 PromiseRejectedCB rejected_cb, 113 PromiseRejectedCB rejected_cb,
104 const std::string& uma_name); 114 const std::string& uma_name);
105 virtual ~CdmPromiseTemplate(); 115 virtual ~CdmPromiseTemplate();
106 virtual void resolve(); 116 virtual void resolve();
117 virtual PromiseType Type();
ddorwin 2014/08/25 22:55:01 ditto
jrummell 2014/08/26 00:19:23 Acknowledged.
107 118
108 protected: 119 protected:
109 // Allow subclasses to completely override the implementation. 120 // Allow subclasses to completely override the implementation.
110 CdmPromiseTemplate(); 121 CdmPromiseTemplate();
111 122
112 private: 123 private:
113 base::Callback<void(void)> resolve_cb_; 124 base::Callback<void(void)> resolve_cb_;
114 125
115 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate); 126 DISALLOW_COPY_AND_ASSIGN(CdmPromiseTemplate);
116 }; 127 };
117 128
118 } // namespace media 129 } // namespace media
119 130
120 #endif // MEDIA_BASE_CDM_PROMISE_H_ 131 #endif // MEDIA_BASE_CDM_PROMISE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698