OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "content/browser/media/android/media_throttler.h" | 5 #include "content/browser/media/android/media_throttler.h" |
6 | 6 |
7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "jni/MediaThrottler_jni.h" | 9 #include "jni/MediaThrottler_jni.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 // static | 13 // static |
14 MediaThrottler* MediaThrottler::GetInstance() { | 14 MediaThrottler* MediaThrottler::GetInstance() { |
15 return base::Singleton<MediaThrottler>::get(); | 15 return base::Singleton<MediaThrottler>::get(); |
16 } | 16 } |
17 | 17 |
18 // static | |
19 bool MediaThrottler::RegisterMediaThrottler(JNIEnv* env) { | |
20 return RegisterNativesImpl(env); | |
21 } | |
22 | |
23 MediaThrottler::~MediaThrottler() {} | 18 MediaThrottler::~MediaThrottler() {} |
24 | 19 |
25 bool MediaThrottler::RequestDecoderResources() { | 20 bool MediaThrottler::RequestDecoderResources() { |
26 JNIEnv* env = base::android::AttachCurrentThread(); | 21 JNIEnv* env = base::android::AttachCurrentThread(); |
27 return Java_MediaThrottler_requestDecoderResources( | 22 return Java_MediaThrottler_requestDecoderResources( |
28 env, j_media_throttler_.obj()); | 23 env, j_media_throttler_.obj()); |
29 } | 24 } |
30 | 25 |
31 void MediaThrottler::OnDecodeRequestFinished() { | 26 void MediaThrottler::OnDecodeRequestFinished() { |
32 JNIEnv* env = base::android::AttachCurrentThread(); | 27 JNIEnv* env = base::android::AttachCurrentThread(); |
33 Java_MediaThrottler_onDecodeRequestFinished(env, j_media_throttler_.obj()); | 28 Java_MediaThrottler_onDecodeRequestFinished(env, j_media_throttler_.obj()); |
34 } | 29 } |
35 | 30 |
36 void MediaThrottler::Reset() { | 31 void MediaThrottler::Reset() { |
37 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
38 Java_MediaThrottler_reset(env, j_media_throttler_.obj()); | 33 Java_MediaThrottler_reset(env, j_media_throttler_.obj()); |
39 } | 34 } |
40 | 35 |
41 MediaThrottler::MediaThrottler() { | 36 MediaThrottler::MediaThrottler() { |
42 JNIEnv* env = base::android::AttachCurrentThread(); | 37 JNIEnv* env = base::android::AttachCurrentThread(); |
43 CHECK(env); | 38 CHECK(env); |
44 | 39 |
45 j_media_throttler_.Reset(Java_MediaThrottler_create( | 40 j_media_throttler_.Reset(Java_MediaThrottler_create( |
46 env, base::android::GetApplicationContext())); | 41 env, base::android::GetApplicationContext())); |
47 } | 42 } |
48 | 43 |
49 } // namespace content | 44 } // namespace content |
OLD | NEW |