OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SERVICE_THROTTLER_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_SERVICE_THROTTLER_H_ |
6 #define MEDIA_BASE_ANDROID_MEDIA_SERVICE_THROTTLER_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_SERVICE_THROTTLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
12 #include "base/lazy_instance.h" | |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
15 #include "base/time/tick_clock.h" | 14 #include "base/time/tick_clock.h" |
16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
17 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
18 | 17 |
19 namespace media { | 18 namespace media { |
20 class MediaServerCrashListener; | 19 class MediaServerCrashListener; |
21 | 20 |
22 // The MediaServiceThrottler's purpose is to prevent a compromised process from | 21 // The MediaServiceThrottler's purpose is to prevent a compromised process from |
(...skipping 28 matching lines...) Expand all Loading... |
51 | 50 |
52 // Test only methods. | 51 // Test only methods. |
53 void SetTickClockForTesting(base::TickClock* clock); | 52 void SetTickClockForTesting(base::TickClock* clock); |
54 void ResetInternalStateForTesting(); | 53 void ResetInternalStateForTesting(); |
55 base::TimeDelta GetBaseThrottlingRateForTesting(); | 54 base::TimeDelta GetBaseThrottlingRateForTesting(); |
56 bool IsCrashListenerAliveForTesting(); | 55 bool IsCrashListenerAliveForTesting(); |
57 void SetCrashListenerTaskRunnerForTesting( | 56 void SetCrashListenerTaskRunnerForTesting( |
58 scoped_refptr<base::SingleThreadTaskRunner> crash_listener_task_runner); | 57 scoped_refptr<base::SingleThreadTaskRunner> crash_listener_task_runner); |
59 | 58 |
60 private: | 59 private: |
61 friend struct base::DefaultLazyInstanceTraits<MediaServiceThrottler>; | |
62 friend class MediaServiceThrottlerTest; | 60 friend class MediaServiceThrottlerTest; |
63 | 61 |
64 MediaServiceThrottler(); | 62 MediaServiceThrottler(); |
65 virtual ~MediaServiceThrottler(); | 63 virtual ~MediaServiceThrottler(); |
66 | 64 |
67 // Called by the |crash_listener_| whenever a crash is detected. | 65 // Called by the |crash_listener_| whenever a crash is detected. |
68 void OnMediaServerCrash(bool watchdog_needs_release); | 66 void OnMediaServerCrash(bool watchdog_needs_release); |
69 | 67 |
70 // Updates |current_craches_| according to a linear decay function. | 68 // Updates |current_craches_| according to a linear decay function. |
71 void UpdateServerCrashes(); | 69 void UpdateServerCrashes(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 std::unique_ptr<MediaServerCrashListener> crash_listener_; | 107 std::unique_ptr<MediaServerCrashListener> crash_listener_; |
110 | 108 |
111 scoped_refptr<base::SingleThreadTaskRunner> crash_listener_task_runner_; | 109 scoped_refptr<base::SingleThreadTaskRunner> crash_listener_task_runner_; |
112 | 110 |
113 DISALLOW_COPY_AND_ASSIGN(MediaServiceThrottler); | 111 DISALLOW_COPY_AND_ASSIGN(MediaServiceThrottler); |
114 }; | 112 }; |
115 | 113 |
116 } // namespace media | 114 } // namespace media |
117 | 115 |
118 #endif // MEDIA_BASE_ANDROID_MEDIA_SERVICE_THROTTLER_H_ | 116 #endif // MEDIA_BASE_ANDROID_MEDIA_SERVICE_THROTTLER_H_ |
OLD | NEW |