OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ |
6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... | |
22 } // namespace base | 22 } // namespace base |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 | 25 |
26 // This class is the native version of MediaDrmStorageBridge in Java. It's used | 26 // This class is the native version of MediaDrmStorageBridge in Java. It's used |
27 // to talk to the concrete implementation for persistent data management. | 27 // to talk to the concrete implementation for persistent data management. |
28 class MediaDrmStorageBridge { | 28 class MediaDrmStorageBridge { |
29 public: | 29 public: |
30 static bool RegisterMediaDrmStorageBridge(JNIEnv* env); | 30 static bool RegisterMediaDrmStorageBridge(JNIEnv* env); |
31 | 31 |
32 MediaDrmStorageBridge(const url::Origin& origin, | 32 MediaDrmStorageBridge(); |
33 const CreateStorageCB& create_storage_cb); | |
34 ~MediaDrmStorageBridge(); | 33 ~MediaDrmStorageBridge(); |
35 | 34 |
35 // Bind origin to |this|. Once storage is initialized, |on_init| will be | |
36 // called and it will have a random generated origin id for later usage. If | |
37 // this function isn't called, all the other functions will fail. | |
xhwang
2017/07/21 18:18:26
"This function must be called before any other fun
yucliu1
2017/07/21 20:24:09
Already DCHECK(impl_) which is assigned in Initial
| |
38 void Initialize(const url::Origin& origin, | |
39 const CreateStorageCB& create_storage_cb, | |
40 base::OnceClosure on_init); | |
xhwang
2017/07/21 18:18:27
nit: s/on_init/init_cb
yucliu1
2017/07/21 20:24:09
Done.
| |
41 | |
42 std::string origin_id() const { return origin_id_; } | |
43 | |
36 // The following OnXXX functions are called by Java. The functions will post | 44 // The following OnXXX functions are called by Java. The functions will post |
37 // task on message loop immediately to avoid reentrancy issues. | 45 // task on message loop immediately to avoid reentrancy issues. |
38 | 46 |
39 // Called by the java object when device provision is finished. Implementation | 47 // Called by the java object when device provision is finished. Implementation |
40 // will record the time as provisioning time. | 48 // will record the time as provisioning time. |
41 void OnProvisioned(JNIEnv* env, | 49 void OnProvisioned(JNIEnv* env, |
42 const base::android::JavaParamRef<jobject>& j_storage, | 50 const base::android::JavaParamRef<jobject>& j_storage, |
43 // Callback<Boolean> | 51 // Callback<Boolean> |
44 const base::android::JavaParamRef<jobject>& j_callback); | 52 const base::android::JavaParamRef<jobject>& j_callback); |
45 | 53 |
(...skipping 20 matching lines...) Expand all Loading... | |
66 // Callback<Boolean> | 74 // Callback<Boolean> |
67 const base::android::JavaParamRef<jobject>& j_callback); | 75 const base::android::JavaParamRef<jobject>& j_callback); |
68 | 76 |
69 private: | 77 private: |
70 void RunAndroidBoolCallback(JavaObjectPtr j_callback, bool success); | 78 void RunAndroidBoolCallback(JavaObjectPtr j_callback, bool success); |
71 void OnSessionDataLoaded( | 79 void OnSessionDataLoaded( |
72 JavaObjectPtr j_callback, | 80 JavaObjectPtr j_callback, |
73 const std::string& session_id, | 81 const std::string& session_id, |
74 std::unique_ptr<MediaDrmStorage::SessionData> session_data); | 82 std::unique_ptr<MediaDrmStorage::SessionData> session_data); |
75 | 83 |
76 MediaDrmStorage* GetStorageImpl(); | |
77 | |
78 CreateStorageCB create_storage_cb_; | |
79 std::unique_ptr<MediaDrmStorage> impl_; | 84 std::unique_ptr<MediaDrmStorage> impl_; |
80 | 85 |
81 const url::Origin origin_; | 86 // Random generated ID for origin. |
xhwang
2017/07/21 18:18:26
nit: Randomly
yucliu1
2017/07/21 20:24:09
Done.
| |
87 std::string origin_id_; | |
82 | 88 |
83 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 89 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
84 | 90 |
85 base::WeakPtrFactory<MediaDrmStorageBridge> weak_factory_; | 91 base::WeakPtrFactory<MediaDrmStorageBridge> weak_factory_; |
86 | 92 |
87 DISALLOW_COPY_AND_ASSIGN(MediaDrmStorageBridge); | 93 DISALLOW_COPY_AND_ASSIGN(MediaDrmStorageBridge); |
88 }; | 94 }; |
89 | 95 |
90 } // namespace media | 96 } // namespace media |
91 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ | 97 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ |
OLD | NEW |