OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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_BASE_ANDROID_MEDIA_DRM_STORAGE_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <string> |
| 12 #include <vector> |
| 13 |
| 14 #include "base/callback.h" |
| 15 #include "base/macros.h" |
| 16 #include "media/base/media_export.h" |
| 17 #include "url/origin.h" |
| 18 |
| 19 namespace media { |
| 20 |
| 21 // Allows MediaDrmBridge to store and retrieve persistent data. This is needed |
| 22 // for features like per-origin provisioning and persistent license support. |
| 23 class MEDIA_EXPORT MediaDrmStorage { |
| 24 public: |
| 25 struct SessionData { |
| 26 SessionData(std::vector<uint8_t> key_set_id, std::string mime_type); |
| 27 ~SessionData(); |
| 28 |
| 29 std::vector<uint8_t> key_set_id; |
| 30 std::string mime_type; |
| 31 }; |
| 32 |
| 33 MediaDrmStorage(); |
| 34 virtual ~MediaDrmStorage(); |
| 35 |
| 36 // Callback to return whether the operation succeeded. |
| 37 using ResultCB = base::OnceCallback<void(bool)>; |
| 38 |
| 39 // Callback to return the result of LoadPersistentSession. |key_set_id| and |
| 40 // |mime_type| must be non-empty if |success| is true, and vice versa. |
| 41 using LoadPersistentSessionCB = |
| 42 base::OnceCallback<void(std::unique_ptr<SessionData> session_data)>; |
| 43 |
| 44 // Binds |this| to |origin|. |
| 45 // TODO(xhwang): The host of the service should know about the last committed |
| 46 // origin. We should solely use that origin, or check the |origin| against it. |
| 47 // TODO(xhwang): We should NOT use the real origin for provisioning. Use a |
| 48 // random origin ID instead. |
| 49 virtual void Initialize(const url::Origin& origin) = 0; |
| 50 |
| 51 // Called when MediaDrm is provisioned for the origin bound to |this|. |
| 52 // The implementation should keep track of the storing time so that the |
| 53 // information can be cleared based on selected time range (e.g. for clearing |
| 54 // browsing data). |
| 55 virtual void OnProvisioned(ResultCB result_cb) = 0; |
| 56 |
| 57 // Saves the persistent session info for |session_id| in the storage. |
| 58 // The implementation should keep track of the storing time so that the |
| 59 // information can be cleared based on selected time range (e.g. for clearing |
| 60 // browsing data). |
| 61 virtual void SavePersistentSession(const std::string& session_id, |
| 62 const SessionData& session_data, |
| 63 ResultCB result_cb) = 0; |
| 64 |
| 65 // Loads the persistent session info for |session_id| from the storage. |
| 66 virtual void LoadPersistentSession( |
| 67 const std::string& session_id, |
| 68 LoadPersistentSessionCB load_persistent_session_cb) = 0; |
| 69 |
| 70 // Removes the persistent session info for |session_id| from the storage. |
| 71 virtual void RemovePersistentSession(const std::string& session_id, |
| 72 ResultCB result_cb) = 0; |
| 73 |
| 74 private: |
| 75 DISALLOW_COPY_AND_ASSIGN(MediaDrmStorage); |
| 76 }; |
| 77 |
| 78 using CreateStorageCB = base::Callback<std::unique_ptr<MediaDrmStorage>()>; |
| 79 |
| 80 } // namespace media |
| 81 |
| 82 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_H_ |
OLD | NEW |