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 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_THROTTLER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_THROTTLER_H_ |
6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_THROTTLER_H_ | 6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_THROTTLER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class MediaThrottler { | 16 class MediaThrottler { |
17 public: | 17 public: |
18 // Called to get the singleton MediaThrottler instance. | 18 // Called to get the singleton MediaThrottler instance. |
19 static MediaThrottler* GetInstance(); | 19 static MediaThrottler* GetInstance(); |
20 | 20 |
21 // Jni registration. | |
22 static bool RegisterMediaThrottler(JNIEnv* env); | |
23 | |
24 virtual ~MediaThrottler(); | 21 virtual ~MediaThrottler(); |
25 | 22 |
26 // Called to request the permission to decode media data. Returns true if | 23 // Called to request the permission to decode media data. Returns true if |
27 // permitted, or false otherwise. | 24 // permitted, or false otherwise. |
28 bool RequestDecoderResources(); | 25 bool RequestDecoderResources(); |
29 | 26 |
30 // Called when a decode request finishes. | 27 // Called when a decode request finishes. |
31 void OnDecodeRequestFinished(); | 28 void OnDecodeRequestFinished(); |
32 | 29 |
33 // Resets the throttler to a fresh state. | 30 // Resets the throttler to a fresh state. |
34 void Reset(); | 31 void Reset(); |
35 | 32 |
36 private: | 33 private: |
37 friend struct base::DefaultSingletonTraits<MediaThrottler>; | 34 friend struct base::DefaultSingletonTraits<MediaThrottler>; |
38 MediaThrottler(); | 35 MediaThrottler(); |
39 | 36 |
40 base::android::ScopedJavaGlobalRef<jobject> j_media_throttler_; | 37 base::android::ScopedJavaGlobalRef<jobject> j_media_throttler_; |
41 DISALLOW_COPY_AND_ASSIGN(MediaThrottler); | 38 DISALLOW_COPY_AND_ASSIGN(MediaThrottler); |
42 }; | 39 }; |
43 | 40 |
44 } // namespace content | 41 } // namespace content |
45 | 42 |
46 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_THROTTLER_H_ | 43 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_THROTTLER_H_ |
OLD | NEW |