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 #include "media/base/media_keys_session_promise.h" | |
6 | |
7 namespace media { | |
8 | |
9 MediaKeysSessionPromise::MediaKeysSessionPromise() {} | |
10 | |
11 MediaKeysSessionPromise::MediaKeysSessionPromise( | |
12 PromiseResolvedCB resolve_cb, | |
13 PromiseResolvedWithSessionCB resolve_with_session_cb, | |
14 PromiseRejectedCB rejected_cb) | |
15 : resolve_cb_(resolve_cb), | |
16 resolve_with_session_cb_(resolve_with_session_cb), | |
17 rejected_cb_(rejected_cb) { | |
18 DCHECK(!resolve_cb.is_null() || !resolve_with_session_cb.is_null()); | |
19 DCHECK(!rejected_cb_.is_null()); | |
20 } | |
21 | |
22 MediaKeysSessionPromise::~MediaKeysSessionPromise() { | |
xhwang
2014/05/05 20:46:42
We should be able to DCHECK that the promise is al
jrummell
2014/05/08 23:37:45
Good idea. Done.
| |
23 } | |
24 | |
25 void MediaKeysSessionPromise::resolve() { | |
26 if (!resolve_cb_.is_null()) | |
27 resolve_cb_.Run(); | |
28 else | |
29 reject("InvalidStateError", 0, std::string()); | |
xhwang
2014/05/05 20:46:42
When could this happen? Shall we just DCHECK(!reso
jrummell
2014/05/08 23:37:45
Not needed anymore now that the classes are done b
| |
30 } | |
31 | |
32 void MediaKeysSessionPromise::resolve(const std::string& web_session_id) { | |
33 if (!resolve_with_session_cb_.is_null()) | |
34 resolve_with_session_cb_.Run(web_session_id); | |
35 else | |
36 reject("InvalidStateError", 0, std::string()); | |
37 } | |
38 | |
39 void MediaKeysSessionPromise::reject(const std::string& error_name, | |
40 uint32 system_code, | |
41 const std::string& error_message) { | |
42 rejected_cb_.Run(error_name, system_code, error_message); | |
43 } | |
44 | |
45 } // namespace media | |
OLD | NEW |