forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_session_cdm_result_promise.h
84 lines (65 loc) · 2.82 KB
/
new_session_cdm_result_promise.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_
#define MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_
#include <stdint.h>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "media/base/cdm_promise.h"
#include "media/blink/media_blink_export.h"
#include "third_party/blink/public/platform/web_content_decryption_module_result.h"
namespace media {
enum class SessionInitStatus {
// Unable to determine the status.
UNKNOWN_STATUS,
// New session has been initialized.
NEW_SESSION,
// CDM could not find the requested session.
SESSION_NOT_FOUND,
// CDM already has a non-closed session that matches the provided
// parameters.
SESSION_ALREADY_EXISTS
};
using SessionInitializedCB =
base::OnceCallback<void(const std::string& session_id,
SessionInitStatus* status)>;
// Special class for resolving a new session promise. Resolving a new session
// promise returns the session ID (as a string), but the blink promise needs
// to get passed a SessionStatus. This class converts the session id to a
// SessionStatus by calling |new_session_created_cb|. The value returned by
// |new_session_created_cb| must be in |expected_statuses| for the promise to
// be resolved. If it's not in the list, the promise will be rejected.
class MEDIA_BLINK_EXPORT NewSessionCdmResultPromise
: public CdmPromiseTemplate<std::string> {
public:
NewSessionCdmResultPromise(
const blink::WebContentDecryptionModuleResult& result,
const std::string& key_system_uma_prefix,
const std::string& uma_name,
SessionInitializedCB new_session_created_cb,
const std::vector<SessionInitStatus>& expected_statuses);
~NewSessionCdmResultPromise() override;
// CdmPromiseTemplate<T> implementation.
void resolve(const std::string& session_id) override;
void reject(CdmPromise::Exception exception_code,
uint32_t system_code,
const std::string& error_message) override;
private:
blink::WebContentDecryptionModuleResult web_cdm_result_;
// UMA prefix and name to report result and time to.
std::string key_system_uma_prefix_;
std::string uma_name_;
// Called on resolve() to convert the session ID into a SessionInitStatus to
// be reported to blink. Returned status must be in |expected_statuses_| or
// else the promise will be rejected.
SessionInitializedCB new_session_created_cb_;
std::vector<SessionInitStatus> expected_statuses_;
// Time when |this| is created.
base::TimeTicks creation_time_;
DISALLOW_COPY_AND_ASSIGN(NewSessionCdmResultPromise);
};
} // namespace media
#endif // MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_