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

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

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: helpers Created 6 years, 3 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
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_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "media/base/media_keys.h"
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
15
16 namespace content {
17
18 // Keep track of a WebContentDecryptionModuleResults as they need to be kept
19 // around until the corresponding operation completes.
20 class WebContentDecryptionModuleResultHelper {
21 public:
22 WebContentDecryptionModuleResultHelper();
23 virtual ~WebContentDecryptionModuleResultHelper();
24
25 // Take a copy of |result| and keep it around until needed. Returns a
26 // SimpleCdmPromise that can be passed to the other methods to complete the
27 // WebContentDecryptionModuleResult. When SimpleCdmPromise is resolved,
28 // Complete() is called. If the SimpleCdmPromise is rejected,
29 // CompleteWithError() is called.
30 scoped_ptr<media::SimpleCdmPromise> CreateSimpleCdmPromise(
31 blink::WebContentDecryptionModuleResult result);
32
33 // Take a copy of |result| and keep it around until needed. Returns a
34 // KeyIdsPromise that can be passed to the other methods to complete the
35 // WebContentDecryptionModuleResult. When KeyIdsPromise is resolved,
36 // CompleteWithKeyIds() is called. If the KeyIdsPromise is rejected,
37 // CompleteWithError() is called.
38 scoped_ptr<media::KeyIdsPromise> CreateKeyIdsPromise(
39 blink::WebContentDecryptionModuleResult result);
40
41 // Take a copy of |result| and keep it around until needed. Returns an
42 // index that is passed to the Complete... methods to complete the
43 // WebContentDecryptionModuleResult.
44 uint32 AddResult(blink::WebContentDecryptionModuleResult result);
45
46 // Locate the corresponding WebContentDecryptionModuleResult for
47 // |result_index|, and call completeWithSession() on it.
48 // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if
49 // |result_index| does not map to a previously saved (and unused)
50 // WebContentDecryptionModuleResult object.
51 void CompleteWithSession(
52 uint32 result_index,
53 blink::WebContentDecryptionModuleResult::SessionStatus status);
54
55 // Locate the corresponding WebContentDecryptionModuleResult for
56 // |result_index|, and call completeWithError() on it.
57 // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if
58 // |result_index| does not map to a previously saved (and unused)
59 // WebContentDecryptionModuleResult object.
60 void CompleteWithError(uint32 result_index,
61 media::MediaKeys::Exception exception_code,
62 uint32 system_code,
63 const std::string& error_message);
64
65 private:
66 typedef std::map<uint32, blink::WebContentDecryptionModuleResult> ResultMap;
67
68 // Locate the corresponding WebContentDecryptionModuleResult for
69 // |result_index|, and call complete() on it. WebContentDecryptionModuleResult
70 // is destroyed afterwards. Does nothing if |result_index| does not map to
71 // a previously saved (and unused) WebContentDecryptionModuleResult object.
72 void Complete(uint32 result_index);
73
74 // Locate the corresponding WebContentDecryptionModuleResult for
75 // |result_index|, and call completeWithKeyIds() on it.
76 // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if
77 // |result_index| does not map to a previously saved (and unused)
78 // WebContentDecryptionModuleResult object.
79 void CompleteWithKeyIds(uint32 result_index,
80 const media::KeyIdsVector& key_ids);
81
82 // Keep track of all the outstanding WebContentDecryptionModuleResult objects.
83 uint32 next_available_result_index_;
84 ResultMap outstanding_results_;
85
86 // Since promises will live until they are fired, use a weak reference when
87 // creating a promise in case this class disappears before the promise
88 // actually fires.
89 base::WeakPtrFactory<WebContentDecryptionModuleResultHelper>
90 weak_ptr_factory_;
91
92 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleResultHelper);
93 };
94
95 } // namespace content
96
97 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698