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 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 "media/base/media_keys.h" |
| 12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // Keep track of a WebContentDecryptionModuleResults as they need to be kept |
| 17 // around until the corresponding operation completes. |
| 18 class WebContentDecryptionModuleResultHelper { |
| 19 public: |
| 20 WebContentDecryptionModuleResultHelper(); |
| 21 virtual ~WebContentDecryptionModuleResultHelper(); |
| 22 |
| 23 // Take a copy of |result| and keep it around until needed. Returns an |
| 24 // index that is passed to the other methods to complete the |
| 25 // WebContentDecryptionModuleResult. |
| 26 uint32 AddResult(blink::WebContentDecryptionModuleResult result); |
| 27 |
| 28 // Locate the corresponding WebContentDecryptionModuleResult for |
| 29 // |result_index|, and call complete() on it. WebContentDecryptionModuleResult |
| 30 // is destroyed afterwards. Does nothing if |result_index| does not map to |
| 31 // a previously saved (and unused) WebContentDecryptionModuleResult object. |
| 32 void Complete(uint32 result_index); |
| 33 |
| 34 // Locate the corresponding WebContentDecryptionModuleResult for |
| 35 // |result_index|, and call completeWithSession() on it. |
| 36 // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if |
| 37 // |result_index| does not map to a previously saved (and unused) |
| 38 // WebContentDecryptionModuleResult object. |
| 39 void CompleteWithSession( |
| 40 uint32 result_index, |
| 41 blink::WebContentDecryptionModuleResult::SessionStatus status); |
| 42 |
| 43 // Locate the corresponding WebContentDecryptionModuleResult for |
| 44 // |result_index|, and call completeWithKeyIds() on it. |
| 45 // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if |
| 46 // |result_index| does not map to a previously saved (and unused) |
| 47 // WebContentDecryptionModuleResult object. |
| 48 void CompleteWithKeyIds(uint32 result_index, |
| 49 const media::KeyIdsVector& key_ids); |
| 50 |
| 51 // Locate the corresponding WebContentDecryptionModuleResult for |
| 52 // |result_index|, and call completeWithError() on it. |
| 53 // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if |
| 54 // |result_index| does not map to a previously saved (and unused) |
| 55 // WebContentDecryptionModuleResult object. |
| 56 void CompleteWithError(uint32 result_index, |
| 57 media::MediaKeys::Exception exception_code, |
| 58 uint32 system_code, |
| 59 const std::string& error_message); |
| 60 |
| 61 private: |
| 62 typedef std::map<uint32, blink::WebContentDecryptionModuleResult> ResultMap; |
| 63 |
| 64 // Keep track of all the outstanding WebContentDecryptionModuleResult objects. |
| 65 uint32 next_available_result_index_; |
| 66 ResultMap outstanding_results_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleResultHelper); |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |
OLD | NEW |