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

Unified 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 side-by-side diff with in-line comments
Download patch
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..9b1961b1907d97c37a1711bb655f92e049240300
--- /dev/null
+++ b/content/renderer/media/webcontentdecryptionmoduleresult_helper.h
@@ -0,0 +1,97 @@
+// 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 "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.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 a
+ // SimpleCdmPromise that can be passed to the other methods to complete the
+ // WebContentDecryptionModuleResult. When SimpleCdmPromise is resolved,
+ // Complete() is called. If the SimpleCdmPromise is rejected,
+ // CompleteWithError() is called.
+ scoped_ptr<media::SimpleCdmPromise> CreateSimpleCdmPromise(
+ blink::WebContentDecryptionModuleResult result);
+
+ // Take a copy of |result| and keep it around until needed. Returns a
+ // KeyIdsPromise that can be passed to the other methods to complete the
+ // WebContentDecryptionModuleResult. When KeyIdsPromise is resolved,
+ // CompleteWithKeyIds() is called. If the KeyIdsPromise is rejected,
+ // CompleteWithError() is called.
+ scoped_ptr<media::KeyIdsPromise> CreateKeyIdsPromise(
+ blink::WebContentDecryptionModuleResult result);
+
+ // Take a copy of |result| and keep it around until needed. Returns an
+ // index that is passed to the Complete... methods to complete the
+ // WebContentDecryptionModuleResult.
+ uint32 AddResult(blink::WebContentDecryptionModuleResult result);
+
+ // 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 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;
+
+ // 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 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);
+
+ // Keep track of all the outstanding WebContentDecryptionModuleResult objects.
+ uint32 next_available_result_index_;
+ ResultMap outstanding_results_;
+
+ // Since promises will live until they are fired, use a weak reference when
+ // creating a promise in case this class disappears before the promise
+ // actually fires.
+ base::WeakPtrFactory<WebContentDecryptionModuleResultHelper>
+ weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleResultHelper);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULERESULT_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698