Index: content/renderer/media/webcontentdecryptionmoduleresult_helper.h |
diff --git a/content/renderer/media/webcontentdecryptionmoduleresult_helper.h b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..158a6bf38950cdd606de59d25aef5167f6149a8b |
--- /dev/null |
+++ b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h |
@@ -0,0 +1,73 @@ |
+// 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 CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |
+#define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |
+ |
+#include <map> |
+ |
+#include "base/basictypes.h" |
+#include "media/base/media_keys.h" |
+#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
+ |
+namespace content { |
+ |
+// Keep track of a WebContentDecryptionModuleResults as they need to be kept |
+// around until the corresponding operation completes. |
+class WebContentDecryptionModuleResultHelper { |
+ public: |
+ WebContentDecryptionModuleResultHelper(); |
+ virtual ~WebContentDecryptionModuleResultHelper(); |
+ |
+ // Take a copy of |result| and keep it around until needed. Returns an |
+ // index that is passed to the other methods to complete the |
+ // WebContentDecryptionModuleResult. |
+ uint32 AddResult(blink::WebContentDecryptionModuleResult result); |
+ |
+ // Locate the corresponding WebContentDecryptionModuleResult for |
+ // |result_index|, and call complete() on it. WebContentDecryptionModuleResult |
+ // is destroyed afterwards. Does nothing if |result_index| does not map to |
+ // a previously saved (and unused) WebContentDecryptionModuleResult object. |
+ void Complete(uint32 result_index); |
+ |
+ // Locate the corresponding WebContentDecryptionModuleResult for |
+ // |result_index|, and call completeWithSession() on it. |
+ // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if |
+ // |result_index| does not map to a previously saved (and unused) |
+ // WebContentDecryptionModuleResult object. |
+ void CompleteWithSession( |
+ uint32 result_index, |
+ blink::WebContentDecryptionModuleResult::SessionStatus status); |
+ |
+ // Locate the corresponding WebContentDecryptionModuleResult for |
+ // |result_index|, and call completeWithKeyIds() on it. |
+ // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if |
+ // |result_index| does not map to a previously saved (and unused) |
+ // WebContentDecryptionModuleResult object. |
+ void CompleteWithKeyIds(uint32 result_index, |
+ const media::KeyIdsVector& key_ids); |
+ |
+ // Locate the corresponding WebContentDecryptionModuleResult for |
+ // |result_index|, and call completeWithError() on it. |
+ // WebContentDecryptionModuleResult is destroyed afterwards. Does nothing if |
+ // |result_index| does not map to a previously saved (and unused) |
+ // WebContentDecryptionModuleResult object. |
+ void CompleteWithError(uint32 result_index, |
+ media::MediaKeys::Exception exception_code, |
+ uint32 system_code, |
+ const std::string& error_message); |
+ |
+ private: |
+ typedef std::map<uint32, blink::WebContentDecryptionModuleResult> ResultMap; |
+ |
+ // Keep track of all the outstanding WebContentDecryptionModuleResult objects. |
+ uint32 next_available_result_index_; |
+ ResultMap outstanding_results_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleResultHelper); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_ |