| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ | 5 #ifndef MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ |
| 6 #define MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ | 6 #define MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/time/time.h" |
| 14 #include "media/base/cdm_promise.h" | 15 #include "media/base/cdm_promise.h" |
| 15 #include "media/blink/media_blink_export.h" | 16 #include "media/blink/media_blink_export.h" |
| 16 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 17 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| 17 | 18 |
| 18 namespace media { | 19 namespace media { |
| 19 | 20 |
| 20 enum class SessionInitStatus { | 21 enum class SessionInitStatus { |
| 21 // Error creating the session. | 22 // Error creating the session. |
| 22 UNKNOWN_STATUS, | 23 UNKNOWN_STATUS, |
| 23 | 24 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 // Special class for resolving a new session promise. Resolving a new session | 39 // Special class for resolving a new session promise. Resolving a new session |
| 39 // promise returns the session ID (as a string), but the blink promise needs | 40 // promise returns the session ID (as a string), but the blink promise needs |
| 40 // to get passed a SessionStatus. This class converts the session id to a | 41 // to get passed a SessionStatus. This class converts the session id to a |
| 41 // SessionStatus by calling |new_session_created_cb|. | 42 // SessionStatus by calling |new_session_created_cb|. |
| 42 class MEDIA_BLINK_EXPORT NewSessionCdmResultPromise | 43 class MEDIA_BLINK_EXPORT NewSessionCdmResultPromise |
| 43 : public CdmPromiseTemplate<std::string> { | 44 : public CdmPromiseTemplate<std::string> { |
| 44 public: | 45 public: |
| 45 NewSessionCdmResultPromise( | 46 NewSessionCdmResultPromise( |
| 46 const blink::WebContentDecryptionModuleResult& result, | 47 const blink::WebContentDecryptionModuleResult& result, |
| 48 const std::string& key_system_uma_prefix, |
| 47 const std::string& uma_name, | 49 const std::string& uma_name, |
| 48 const SessionInitializedCB& new_session_created_cb); | 50 const SessionInitializedCB& new_session_created_cb); |
| 49 ~NewSessionCdmResultPromise() override; | 51 ~NewSessionCdmResultPromise() override; |
| 50 | 52 |
| 51 // CdmPromiseTemplate<T> implementation. | 53 // CdmPromiseTemplate<T> implementation. |
| 52 void resolve(const std::string& session_id) override; | 54 void resolve(const std::string& session_id) override; |
| 53 void reject(CdmPromise::Exception exception_code, | 55 void reject(CdmPromise::Exception exception_code, |
| 54 uint32_t system_code, | 56 uint32_t system_code, |
| 55 const std::string& error_message) override; | 57 const std::string& error_message) override; |
| 56 | 58 |
| 57 private: | 59 private: |
| 58 blink::WebContentDecryptionModuleResult web_cdm_result_; | 60 blink::WebContentDecryptionModuleResult web_cdm_result_; |
| 59 | 61 |
| 60 // UMA name to report result to. | 62 // UMA prefix and name to report result and time to. |
| 63 std::string key_system_uma_prefix_; |
| 61 std::string uma_name_; | 64 std::string uma_name_; |
| 62 | 65 |
| 63 // Called on resolve() to convert the session ID into a SessionInitStatus to | 66 // Called on resolve() to convert the session ID into a SessionInitStatus to |
| 64 // be reported to blink. | 67 // be reported to blink. |
| 65 SessionInitializedCB new_session_created_cb_; | 68 SessionInitializedCB new_session_created_cb_; |
| 66 | 69 |
| 70 // Time when |this| is created. |
| 71 base::TimeTicks creation_time_; |
| 72 |
| 67 DISALLOW_COPY_AND_ASSIGN(NewSessionCdmResultPromise); | 73 DISALLOW_COPY_AND_ASSIGN(NewSessionCdmResultPromise); |
| 68 }; | 74 }; |
| 69 | 75 |
| 70 } // namespace media | 76 } // namespace media |
| 71 | 77 |
| 72 #endif // MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ | 78 #endif // MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_ |
| OLD | NEW |