| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 
| 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 
| 7 | 7 | 
| 8 #include "base/macros.h" | 8 #include "base/macros.h" | 
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" | 
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 48   // Called when the plugin flushes it's graphics context. Supplies the | 48   // Called when the plugin flushes it's graphics context. Supplies the | 
| 49   // throttler with a candidate to use as the representative keyframe. | 49   // throttler with a candidate to use as the representative keyframe. | 
| 50   void OnImageFlush(const SkBitmap* bitmap); | 50   void OnImageFlush(const SkBitmap* bitmap); | 
| 51 | 51 | 
| 52   // Returns true if |event| was handled and shouldn't be further processed. | 52   // Returns true if |event| was handled and shouldn't be further processed. | 
| 53   bool ConsumeInputEvent(const blink::WebInputEvent& event); | 53   bool ConsumeInputEvent(const blink::WebInputEvent& event); | 
| 54 | 54 | 
| 55  private: | 55  private: | 
| 56   friend class PluginInstanceThrottlerImplTest; | 56   friend class PluginInstanceThrottlerImplTest; | 
| 57 | 57 | 
| 58   enum State { |  | 
| 59     // Initial state if Power Saver is disabled. We are just collecting metrics. |  | 
| 60     POWER_SAVER_DISABLED, |  | 
| 61     // Initial state if Power Saver is enabled. Waiting for a keyframe. |  | 
| 62     POWER_SAVER_ENABLED_AWAITING_KEYFRAME, |  | 
| 63     // We've chosen a keyframe and the plug-in is throttled. |  | 
| 64     POWER_SAVER_ENABLED_PLUGIN_THROTTLED, |  | 
| 65     // Plugin instance is no longer considered peripheral. This can happen from |  | 
| 66     // a user click, whitelisting, or some other reason. We can end up in this |  | 
| 67     // state regardless of whether power saver is enabled. |  | 
| 68     PLUGIN_INSTANCE_MARKED_ESSENTIAL |  | 
| 69   }; |  | 
| 70 |  | 
| 71   void EngageThrottle(); | 58   void EngageThrottle(); | 
| 72 | 59 | 
| 73   State state_; | 60   PowerSaverState state_; | 
| 74 | 61 | 
| 75   // Number of consecutive interesting frames we've encountered. | 62   // Number of consecutive interesting frames we've encountered. | 
| 76   int consecutive_interesting_frames_; | 63   int consecutive_interesting_frames_; | 
| 77 | 64 | 
| 78   ObserverList<Observer> observer_list_; | 65   ObserverList<Observer> observer_list_; | 
| 79 | 66 | 
| 80   base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; | 67   base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; | 
| 81 | 68 | 
| 82   DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); | 69   DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); | 
| 83 }; | 70 }; | 
| 84 } | 71 } | 
| 85 | 72 | 
| 86 #endif  // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 73 #endif  // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 
| OLD | NEW | 
|---|