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

Side by Side Diff: media/base/android/media_drm_storage_bridge.h

Issue 2805803002: [Clank] Implement MediaDrmStorageBridge with MediaDrmStorage (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 10
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/callback.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "media/base/android/media_drm_storage.h"
16 #include "url/origin.h"
14 17
15 namespace base { 18 namespace base {
16 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
17 } // namespace base 20 } // namespace base
18 21
19 namespace media { 22 namespace media {
20 23
21 // This class is the native version of MediaDrmStorageBridge in Java. It's used 24 // This class is the native version of MediaDrmStorageBridge in Java. It's used
22 // to talk to the concrete implementation for persistent data management. 25 // to talk to the concrete implementation for persistent data management.
23 class MediaDrmStorageBridge { 26 class MediaDrmStorageBridge {
24 public: 27 public:
28 using OnceCreateStorageCB =
29 base::OnceCallback<std::unique_ptr<MediaDrmStorage>()>;
xhwang 2017/04/07 05:47:35 Can you reuse the CreateStorageCB? https://cs.chr
yucliu1 2017/04/07 18:53:10 Re-use CreateStorageCB. AndroidCdmFactory need to
30
25 static bool RegisterMediaDrmStorageBridge(JNIEnv* env); 31 static bool RegisterMediaDrmStorageBridge(JNIEnv* env);
26 32
27 MediaDrmStorageBridge(); 33 MediaDrmStorageBridge(const url::Origin& origin,
34 OnceCreateStorageCB create_storage_cb);
28 ~MediaDrmStorageBridge(); 35 ~MediaDrmStorageBridge();
29 36
30 // The following OnXXX functions are called by Java. The functions will post 37 // The following OnXXX functions are called by Java. The functions will post
31 // task on message loop immediately to avoid reentrancy issues. 38 // task on message loop immediately to avoid reentrancy issues.
32 39
33 // Called by the java object when device provision is finished. Implementation 40 // Called by the java object when device provision is finished. Implementation
34 // will record the time as provisioning time. 41 // will record the time as provisioning time.
35 void OnProvisioned(JNIEnv* env, 42 void OnProvisioned(JNIEnv* env,
36 const base::android::JavaParamRef<jobject>& j_storage, 43 const base::android::JavaParamRef<jobject>& j_storage,
37 // Callback<Boolean> 44 // Callback<Boolean>
(...skipping 16 matching lines...) Expand all
54 const base::android::JavaParamRef<jobject>& j_callback); 61 const base::android::JavaParamRef<jobject>& j_callback);
55 62
56 // Called by the java object to remove persistent session data. 63 // Called by the java object to remove persistent session data.
57 void OnClearInfo(JNIEnv* env, 64 void OnClearInfo(JNIEnv* env,
58 const base::android::JavaParamRef<jobject>& j_storage, 65 const base::android::JavaParamRef<jobject>& j_storage,
59 const base::android::JavaParamRef<jbyteArray>& j_session_id, 66 const base::android::JavaParamRef<jbyteArray>& j_session_id,
60 // Callback<Boolean> 67 // Callback<Boolean>
61 const base::android::JavaParamRef<jobject>& j_callback); 68 const base::android::JavaParamRef<jobject>& j_callback);
62 69
63 private: 70 private:
71 MediaDrmStorage* GetStorageImpl();
72
73 // Post |task| on |task_runner_|, |task| won't run if this object is deleted.
74 void PostCancellableTask(base::OnceClosure task);
75 void RunCancellableTask(base::OnceClosure task);
76
77 OnceCreateStorageCB create_storage_cb_;
78 std::unique_ptr<MediaDrmStorage> impl_;
79
80 const url::Origin origin_;
81
64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 82 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
65 83
66 // NOTE: Weak pointers must be invalidated before all other member variables. 84 // NOTE: Weak pointers must be invalidated before all other member variables.
67 base::WeakPtrFactory<MediaDrmStorageBridge> weak_factory_; 85 base::WeakPtrFactory<MediaDrmStorageBridge> weak_factory_;
68 86
69 DISALLOW_COPY_AND_ASSIGN(MediaDrmStorageBridge); 87 DISALLOW_COPY_AND_ASSIGN(MediaDrmStorageBridge);
70 }; 88 };
71 89
72 } // namespace media 90 } // namespace media
73 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_ 91 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_STORAGE_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698