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 MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ |
| 6 #define MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "media/base/cdm_promise.h" |
| 12 #include "media/base/media_export.h" |
| 13 #include "media/base/media_keys.h" |
| 14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| 15 |
| 16 namespace media { |
| 17 |
| 18 typedef base::Callback<blink::WebContentDecryptionModuleResult::SessionStatus( |
| 19 const std::string& web_session_id)> SessionInitializedCB; |
| 20 |
| 21 // Special class for resolving a new session promise. Resolving a new session |
| 22 // promise returns the session ID (as a string), but the blink promise needs |
| 23 // to get passed a SessionStatus. This class converts the session id to a |
| 24 // SessionStatus by calling |new_session_created_cb|. |
| 25 class MEDIA_EXPORT NewSessionCdmResultPromise |
| 26 : public CdmPromiseTemplate<std::string> { |
| 27 public: |
| 28 NewSessionCdmResultPromise( |
| 29 const blink::WebContentDecryptionModuleResult& result, |
| 30 const std::string& uma_name, |
| 31 const SessionInitializedCB& new_session_created_cb); |
| 32 virtual ~NewSessionCdmResultPromise(); |
| 33 |
| 34 // CdmPromiseTemplate<T> implementation. |
| 35 virtual void resolve(const std::string& web_session_id) override; |
| 36 virtual void reject(MediaKeys::Exception exception_code, |
| 37 uint32 system_code, |
| 38 const std::string& error_message) override; |
| 39 |
| 40 private: |
| 41 blink::WebContentDecryptionModuleResult web_cdm_result_; |
| 42 |
| 43 // UMA name to report result to. |
| 44 std::string uma_name_; |
| 45 |
| 46 // Called on resolve() to convert the session ID into a SessionStatus to |
| 47 // be reported to blink. |
| 48 SessionInitializedCB new_session_created_cb_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(NewSessionCdmResultPromise); |
| 51 }; |
| 52 |
| 53 } // namespace media |
| 54 |
| 55 #endif // MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ |
OLD | NEW |