OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_CDM_PROMISE_H_ | |
6 #define MEDIA_BASE_CDM_PROMISE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/callback.h" | |
12 #include "media/base/media_export.h" | |
13 #include "media/base/media_keys.h" | |
14 | |
15 namespace media { | |
16 | |
17 typedef base::Callback<void(MediaKeys::Exception exception_code, | |
18 uint32 system_code, | |
19 const std::string& error_message)> | |
20 PromiseRejectedCB; | |
xhwang
2014/05/22 16:44:14
This seems to be only used in class CdmPromise. Ho
jrummell
2014/05/29 00:54:40
Done.
| |
21 | |
22 // Interface for promises being resolved/rejected in response to various | |
23 // session actions. These may be called synchronously or asynchronously. | |
24 // Only one method may be called on any promise. It is expected that the | |
25 // caller free the promise once it is resolved/rejected. | |
26 template <typename T> | |
27 class MEDIA_EXPORT CdmPromise { | |
xhwang
2014/05/23 06:01:23
See above for the idea of having a base class for
jrummell
2014/05/29 00:54:40
Done.
| |
28 public: | |
29 CdmPromise(base::Callback<void(const T&)> resolve_cb, | |
30 PromiseRejectedCB rejected_cb); | |
31 virtual ~CdmPromise(); | |
32 | |
33 // Used to indicate that operation succeeded. | |
34 virtual void resolve(const T& result); | |
35 | |
36 // Used to indicate that the operation failed. |exception_code| must be | |
37 // specified. |system_code| is a Key System-specific value for the error | |
38 // that occurred, or 0 if there is no associated status code or such status | |
39 // codes are not supported by the Key System. |error_message| is optional. | |
40 virtual void reject(MediaKeys::Exception exception_code, | |
41 uint32 system_code, | |
42 const std::string& error_message); | |
43 | |
44 private: | |
45 base::Callback<void(const T&)> resolve_cb_; | |
46 PromiseRejectedCB rejected_cb_; | |
xhwang
2014/05/22 16:44:14
we have |resolve_cb_| but |reject"ed"_cb_|. Shall
jrummell
2014/05/29 00:54:40
Done.
| |
47 bool is_pending_; | |
xhwang
2014/05/22 16:44:14
Add comment for |is_pending_|.
jrummell
2014/05/29 00:54:40
Done.
| |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(CdmPromise); | |
50 }; | |
51 | |
52 // Specialization for no parameter to resolve(). | |
53 template <> | |
54 class MEDIA_EXPORT CdmPromise<void> { | |
55 public: | |
56 CdmPromise(base::Callback<void(void)> resolve_cb, | |
57 PromiseRejectedCB rejected_cb); | |
58 virtual ~CdmPromise(); | |
59 virtual void resolve(); | |
60 virtual void reject(MediaKeys::Exception exception_code, | |
61 uint32 system_code, | |
62 const std::string& error_message); | |
63 | |
64 private: | |
65 base::Callback<void(void)> resolve_cb_; | |
xhwang
2014/05/22 16:44:14
Actually base::Callback<void(void)> == base::Closu
xhwang
2014/05/22 16:44:14
How about having a template class
template <type
jrummell
2014/05/29 00:54:40
I put it this way so that it maps to the basic tem
jrummell
2014/05/29 00:54:40
With the refactoring to CdmPromiseTemplate, not mu
| |
66 PromiseRejectedCB rejected_cb_; | |
67 bool is_pending_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(CdmPromise); | |
70 }; | |
71 | |
72 } // namespace media | |
73 | |
74 #endif // MEDIA_BASE_CDM_PROMISE_H_ | |
OLD | NEW |