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_MEDIA_KEYS_SESSION_PROMISE_H_ | |
6 #define MEDIA_BASE_MEDIA_KEYS_SESSION_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 | |
14 namespace media { | |
15 | |
16 typedef base::Callback<void()> PromiseResolvedCB; | |
17 | |
18 typedef base::Callback<void(const std::string& web_session_id)> | |
19 PromiseResolvedWithSessionCB; | |
20 | |
21 typedef base::Callback<void(const std::string& error_name, | |
22 uint32 system_code, | |
23 const std::string& error_message)> | |
24 PromiseRejectedCB; | |
25 | |
26 // Interface for promises being resolved/rejected in response to various | |
27 // session actions. These may be called synchronously or asynchronously. | |
ddorwin
2014/05/05 18:35:42
Sync is fine as long as we enforce async, which we
| |
28 // Only one method may be called on any promise. It is expected that the | |
29 // caller free the promise once it is resolved/rejected. | |
30 class MEDIA_EXPORT MediaKeysSessionPromise { | |
ddorwin
2014/05/05 18:35:42
The non-session promises are on MKS, but the sessi
ddorwin
2014/05/05 18:44:45
FYI, MediaKeys.setServerCertificate() is now an ex
| |
31 public: | |
32 MediaKeysSessionPromise(PromiseResolvedCB resolve_cb, | |
ddorwin
2014/05/05 18:35:42
It's odd to be passing two different resolve optio
jrummell
2014/05/08 23:37:45
Done.
| |
33 PromiseResolvedWithSessionCB resolve_with_session_cb, | |
34 PromiseRejectedCB rejected_cb); | |
35 virtual ~MediaKeysSessionPromise(); | |
ddorwin
2014/05/05 18:35:42
None of these need to be virtual.
jrummell
2014/05/08 23:37:45
The promises are overridden in a couple of places
| |
36 | |
37 // Used to indicate that UpdateSession()/ReleaseSession() has successfully | |
38 // completed. | |
39 virtual void resolve(); | |
40 | |
41 // Used to indicate that CreateSession()/LoadSession() has successfully | |
42 // completed. |web_session_id| is the ID of the new session created. | |
43 virtual void resolve(const std::string& web_session_id); | |
xhwang
2014/05/05 20:46:42
It's odd to pass Promises with two resolve() funct
jrummell
2014/05/08 23:37:45
Done.
| |
44 | |
45 // Used to indicate that the operation failed. |error_name| should match one | |
46 // of the W3C DOM error names (http://www.w3.org/TR/dom/#error-names-table). | |
47 // |system_code| is a Key System-specific value for the error that occurred, | |
48 // or 0 if there is no associated status code or such status codes are not | |
49 // supported by the Key System. |error_message| is optional. | |
50 virtual void reject(const std::string& error_name, | |
51 uint32 system_code, | |
52 const std::string& error_message); | |
53 | |
54 protected: | |
55 MediaKeysSessionPromise(); | |
56 | |
57 private: | |
58 PromiseResolvedCB resolve_cb_; | |
59 PromiseResolvedWithSessionCB resolve_with_session_cb_; | |
60 PromiseRejectedCB rejected_cb_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(MediaKeysSessionPromise); | |
63 }; | |
64 | |
65 } // namespace media | |
66 | |
67 #endif // MEDIA_BASE_MEDIA_KEYS_SESSION_PROMISE_H_ | |
OLD | NEW |