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

Side by Side Diff: content/renderer/media/cdm_result_promise.h

Issue 651113002: Move CdmResultPromise to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/cdm_result_promise.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_
6 #define CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "media/base/cdm_promise.h"
12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
13
14 namespace content {
15
16 // Used to convert a WebContentDecryptionModuleResult into a CdmPromiseTemplate
17 // so that it can be passed through Chromium. When resolve(T) is called, the
18 // appropriate complete...() method on WebContentDecryptionModuleResult will be
19 // invoked. If reject() is called instead,
20 // WebContentDecryptionModuleResult::completeWithError() is called.
21 // If constructed with a |uma_name|, CdmResultPromise will report the promise
22 // result (success or rejection code) to UMA.
23 template <typename... T>
24 class CdmResultPromise : public media::CdmPromiseTemplate<T...> {
25 public:
26 CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
27 const std::string& uma_name);
28 virtual ~CdmResultPromise();
29
30 // CdmPromiseTemplate<T> implementation.
31 virtual void resolve(const T&... result) override;
32 virtual void reject(media::MediaKeys::Exception exception_code,
33 uint32 system_code,
34 const std::string& error_message) override;
35
36 private:
37 using media::CdmPromiseTemplate<T...>::MarkPromiseSettled;
38
39 blink::WebContentDecryptionModuleResult web_cdm_result_;
40
41 // UMA name to report result to.
42 std::string uma_name_;
43
44 DISALLOW_COPY_AND_ASSIGN(CdmResultPromise);
45 };
46
47 typedef base::Callback<blink::WebContentDecryptionModuleResult::SessionStatus(
48 const std::string& web_session_id)> SessionInitializedCB;
49
50 // Special class for resolving a new session promise. Resolving a new session
51 // promise returns the session ID (as a string), but the blink promise needs
52 // to get passed a SessionStatus. This class converts the session id to a
53 // SessionStatus by calling |new_session_created_cb|.
54 class NewSessionCdmResultPromise
55 : public media::CdmPromiseTemplate<std::string> {
56 public:
57 NewSessionCdmResultPromise(
58 const blink::WebContentDecryptionModuleResult& result,
59 const std::string& uma_name,
60 const SessionInitializedCB& new_session_created_cb);
61 virtual ~NewSessionCdmResultPromise();
62
63 // CdmPromiseTemplate<T> implementation.
64 virtual void resolve(const std::string& web_session_id) override;
65 virtual void reject(media::MediaKeys::Exception exception_code,
66 uint32 system_code,
67 const std::string& error_message) override;
68
69 private:
70 blink::WebContentDecryptionModuleResult web_cdm_result_;
71
72 // UMA name to report result to.
73 std::string uma_name_;
74
75 // Called on resolve() to convert the session ID into a SessionStatus to
76 // be reported to blink.
77 SessionInitializedCB new_session_created_cb_;
78
79 DISALLOW_COPY_AND_ASSIGN(NewSessionCdmResultPromise);
80 };
81
82 } // namespace content
83
84 #endif // CONTENT_RENDERER_MEDIA_CDM_RESULT_PROMISE_H_
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/cdm_result_promise.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698