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 MediaThrottler::~MediaThrottler() {} | 18 MediaThrottler::~MediaThrottler() {} |
19 | 19 |
20 bool MediaThrottler::RequestDecoderResources() { | 20 bool MediaThrottler::RequestDecoderResources() { |
21 JNIEnv* env = base::android::AttachCurrentThread(); | 21 JNIEnv* env = base::android::AttachCurrentThread(); |
22 return Java_MediaThrottler_requestDecoderResources( | 22 return Java_MediaThrottler_requestDecoderResources(env, j_media_throttler_); |
23 env, j_media_throttler_.obj()); | |
24 } | 23 } |
25 | 24 |
26 void MediaThrottler::OnDecodeRequestFinished() { | 25 void MediaThrottler::OnDecodeRequestFinished() { |
27 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
28 Java_MediaThrottler_onDecodeRequestFinished(env, j_media_throttler_.obj()); | 27 Java_MediaThrottler_onDecodeRequestFinished(env, j_media_throttler_); |
29 } | 28 } |
30 | 29 |
31 void MediaThrottler::Reset() { | 30 void MediaThrottler::Reset() { |
32 JNIEnv* env = base::android::AttachCurrentThread(); | 31 JNIEnv* env = base::android::AttachCurrentThread(); |
33 Java_MediaThrottler_reset(env, j_media_throttler_.obj()); | 32 Java_MediaThrottler_reset(env, j_media_throttler_); |
34 } | 33 } |
35 | 34 |
36 MediaThrottler::MediaThrottler() { | 35 MediaThrottler::MediaThrottler() { |
37 JNIEnv* env = base::android::AttachCurrentThread(); | 36 JNIEnv* env = base::android::AttachCurrentThread(); |
38 CHECK(env); | 37 CHECK(env); |
39 | 38 |
40 j_media_throttler_.Reset(Java_MediaThrottler_create( | 39 j_media_throttler_.Reset(Java_MediaThrottler_create( |
41 env, base::android::GetApplicationContext())); | 40 env, base::android::GetApplicationContext())); |
42 } | 41 } |
43 | 42 |
44 } // namespace content | 43 } // namespace content |
OLD | NEW |