Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.h

Issue 849723002: Plugin Power Saver: Make PepperPluginInstanceThrottler interface public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PEPPER_PLUGIN_INSTANCE_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "cc/layers/content_layer_client.h" 19 #include "cc/layers/content_layer_client.h"
20 #include "cc/layers/layer.h" 20 #include "cc/layers/layer.h"
21 #include "cc/layers/texture_layer_client.h" 21 #include "cc/layers/texture_layer_client.h"
22 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
23 #include "content/public/renderer/pepper_plugin_instance.h" 23 #include "content/public/renderer/pepper_plugin_instance.h"
24 #include "content/public/renderer/plugin_instance_throttler.h"
24 #include "content/public/renderer/render_frame.h" 25 #include "content/public/renderer/render_frame.h"
25 #include "content/public/renderer/render_frame_observer.h" 26 #include "content/public/renderer/render_frame_observer.h"
26 #include "content/renderer/mouse_lock_dispatcher.h" 27 #include "content/renderer/mouse_lock_dispatcher.h"
27 #include "gin/handle.h" 28 #include "gin/handle.h"
28 #include "ppapi/c/dev/pp_cursor_type_dev.h" 29 #include "ppapi/c/dev/pp_cursor_type_dev.h"
29 #include "ppapi/c/dev/ppp_printing_dev.h" 30 #include "ppapi/c/dev/ppp_printing_dev.h"
30 #include "ppapi/c/dev/ppp_selection_dev.h" 31 #include "ppapi/c/dev/ppp_selection_dev.h"
31 #include "ppapi/c/dev/ppp_text_input_dev.h" 32 #include "ppapi/c/dev/ppp_text_input_dev.h"
32 #include "ppapi/c/dev/ppp_zoom_dev.h" 33 #include "ppapi/c/dev/ppp_zoom_dev.h"
33 #include "ppapi/c/pp_completion_callback.h" 34 #include "ppapi/c/pp_completion_callback.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 class ScopedPPVar; 98 class ScopedPPVar;
98 } 99 }
99 100
100 namespace content { 101 namespace content {
101 102
102 class ContentDecryptorDelegate; 103 class ContentDecryptorDelegate;
103 class FullscreenContainer; 104 class FullscreenContainer;
104 class MessageChannel; 105 class MessageChannel;
105 class PepperCompositorHost; 106 class PepperCompositorHost;
106 class PepperGraphics2DHost; 107 class PepperGraphics2DHost;
107 class PepperPluginInstanceThrottler; 108 class PluginInstanceThrottlerImpl;
108 class PluginModule; 109 class PluginModule;
109 class PluginObject; 110 class PluginObject;
110 class PPB_Graphics3D_Impl; 111 class PPB_Graphics3D_Impl;
111 class PPB_ImageData_Impl; 112 class PPB_ImageData_Impl;
112 class PPB_URLLoader_Impl; 113 class PPB_URLLoader_Impl;
113 class RenderFrameImpl; 114 class RenderFrameImpl;
114 class RenderViewImpl; 115 class RenderViewImpl;
115 116
116 // Represents one time a plugin appears on one web page. 117 // Represents one time a plugin appears on one web page.
117 // 118 //
118 // Note: to get from a PP_Instance to a PepperPluginInstance*, use the 119 // Note: to get from a PP_Instance to a PepperPluginInstance*, use the
119 // ResourceTracker. 120 // ResourceTracker.
120 class CONTENT_EXPORT PepperPluginInstanceImpl 121 class CONTENT_EXPORT PepperPluginInstanceImpl
121 : public base::RefCounted<PepperPluginInstanceImpl>, 122 : public base::RefCounted<PepperPluginInstanceImpl>,
122 public NON_EXPORTED_BASE(PepperPluginInstance), 123 public NON_EXPORTED_BASE(PepperPluginInstance),
123 public ppapi::PPB_Instance_Shared, 124 public ppapi::PPB_Instance_Shared,
124 public NON_EXPORTED_BASE(cc::TextureLayerClient), 125 public NON_EXPORTED_BASE(cc::TextureLayerClient),
125 public RenderFrameObserver { 126 public RenderFrameObserver,
127 public NON_EXPORTED_BASE(PluginInstanceThrottler::Observer) {
126 public: 128 public:
127 // Create and return a PepperPluginInstanceImpl object which supports the most 129 // Create and return a PepperPluginInstanceImpl object which supports the most
128 // recent version of PPP_Instance possible by querying the given 130 // recent version of PPP_Instance possible by querying the given
129 // get_plugin_interface function. If the plugin does not support any valid 131 // get_plugin_interface function. If the plugin does not support any valid
130 // PPP_Instance interface, returns NULL. 132 // PPP_Instance interface, returns NULL.
131 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, 133 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame,
132 PluginModule* module, 134 PluginModule* module,
133 blink::WebPluginContainer* container, 135 blink::WebPluginContainer* container,
134 const GURL& plugin_url); 136 const GURL& plugin_url);
135 RenderFrameImpl* render_frame() const { return render_frame_; } 137 RenderFrameImpl* render_frame() const { return render_frame_; }
136 PluginModule* module() const { return module_.get(); } 138 PluginModule* module() const { return module_.get(); }
137 139
138 blink::WebPluginContainer* container() const { return container_; } 140 blink::WebPluginContainer* container() const { return container_; }
139 141
140 PepperPluginInstanceThrottler* throttler() const { return throttler_.get(); } 142 PluginInstanceThrottlerImpl* throttler() const { return throttler_.get(); }
141 143
142 // Returns the PP_Instance uniquely identifying this instance. Guaranteed 144 // Returns the PP_Instance uniquely identifying this instance. Guaranteed
143 // nonzero. 145 // nonzero.
144 PP_Instance pp_instance() const { return pp_instance_; } 146 PP_Instance pp_instance() const { return pp_instance_; }
145 147
146 ppapi::thunk::ResourceCreationAPI& resource_creation() { 148 ppapi::thunk::ResourceCreationAPI& resource_creation() {
147 return *resource_creation_.get(); 149 return *resource_creation_.get();
148 } 150 }
149 151
150 MessageChannel* message_channel() { return message_channel_; } 152 MessageChannel* message_channel() { return message_channel_; }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void InstanceCrashed(); 195 void InstanceCrashed();
194 196
195 // PPB_Instance and PPB_Instance_Private implementation. 197 // PPB_Instance and PPB_Instance_Private implementation.
196 bool full_frame() const { return full_frame_; } 198 bool full_frame() const { return full_frame_; }
197 const ppapi::ViewData& view_data() const { return view_data_; } 199 const ppapi::ViewData& view_data() const { return view_data_; }
198 200
199 // PPP_Instance and PPP_Instance_Private. 201 // PPP_Instance and PPP_Instance_Private.
200 bool Initialize(const std::vector<std::string>& arg_names, 202 bool Initialize(const std::vector<std::string>& arg_names,
201 const std::vector<std::string>& arg_values, 203 const std::vector<std::string>& arg_values,
202 bool full_frame, 204 bool full_frame,
203 RenderFrame::PluginPowerSaverMode power_saver_mode); 205 scoped_ptr<PluginInstanceThrottlerImpl> throttler);
204 bool HandleDocumentLoad(const blink::WebURLResponse& response); 206 bool HandleDocumentLoad(const blink::WebURLResponse& response);
205 bool HandleInputEvent(const blink::WebInputEvent& event, 207 bool HandleInputEvent(const blink::WebInputEvent& event,
206 blink::WebCursorInfo* cursor_info); 208 blink::WebCursorInfo* cursor_info);
207 PP_Var GetInstanceObject(v8::Isolate* isolate); 209 PP_Var GetInstanceObject(v8::Isolate* isolate);
208 void ViewChanged(const gfx::Rect& position, 210 void ViewChanged(const gfx::Rect& position,
209 const gfx::Rect& clip, 211 const gfx::Rect& clip,
210 const std::vector<gfx::Rect>& cut_outs_rects); 212 const std::vector<gfx::Rect>& cut_outs_rects);
211 213
212 // Handlers for composition events. 214 // Handlers for composition events.
213 bool HandleCompositionStart(const base::string16& text); 215 bool HandleCompositionStart(const base::string16& text);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 533
532 // cc::TextureLayerClient implementation. 534 // cc::TextureLayerClient implementation.
533 bool PrepareTextureMailbox( 535 bool PrepareTextureMailbox(
534 cc::TextureMailbox* mailbox, 536 cc::TextureMailbox* mailbox,
535 scoped_ptr<cc::SingleReleaseCallback>* release_callback, 537 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
536 bool use_shared_memory) override; 538 bool use_shared_memory) override;
537 539
538 // RenderFrameObserver 540 // RenderFrameObserver
539 void OnDestruct() override; 541 void OnDestruct() override;
540 542
543 // PluginInstanceThrottler::Observer
544 void OnThrottleStateChange() override;
545
541 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); 546 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info);
542 547
543 private: 548 private:
544 friend class base::RefCounted<PepperPluginInstanceImpl>; 549 friend class base::RefCounted<PepperPluginInstanceImpl>;
545 friend class PpapiPluginInstanceTest; 550 friend class PpapiPluginInstanceTest;
546 friend class PpapiUnittest; 551 friend class PpapiUnittest;
547 552
548 // Delete should be called by the WebPlugin before this destructor. 553 // Delete should be called by the WebPlugin before this destructor.
549 ~PepperPluginInstanceImpl() override; 554 ~PepperPluginInstanceImpl() override;
550 555
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 scoped_ptr<blink::WebLayer> web_layer_; 716 scoped_ptr<blink::WebLayer> web_layer_;
712 bool layer_bound_to_fullscreen_; 717 bool layer_bound_to_fullscreen_;
713 bool layer_is_hardware_; 718 bool layer_is_hardware_;
714 719
715 // Plugin URL. 720 // Plugin URL.
716 GURL plugin_url_; 721 GURL plugin_url_;
717 722
718 // Used to track Flash-specific metrics. 723 // Used to track Flash-specific metrics.
719 bool is_flash_plugin_; 724 bool is_flash_plugin_;
720 725
726 // Set to true the first time the plugin is clicked. Used to collect metrics.
727 bool has_been_clicked_;
728
721 // Used to track if JavaScript has ever been used for this plugin instance. 729 // Used to track if JavaScript has ever been used for this plugin instance.
722 bool javascript_used_; 730 bool javascript_used_;
723 731
724 // Responsible for turning on throttling if Power Saver is on. 732 // Responsible for turning on throttling if Power Saver is on.
725 scoped_ptr<PepperPluginInstanceThrottler> throttler_; 733 scoped_ptr<PluginInstanceThrottlerImpl> throttler_;
726 734
727 // Indicates whether this is a full frame instance, which means it represents 735 // Indicates whether this is a full frame instance, which means it represents
728 // an entire document rather than an embed tag. 736 // an entire document rather than an embed tag.
729 bool full_frame_; 737 bool full_frame_;
730 738
731 // Stores the current state of the plugin view. 739 // Stores the current state of the plugin view.
732 ppapi::ViewData view_data_; 740 ppapi::ViewData view_data_;
733 // The last state sent to the plugin. It is only valid after 741 // The last state sent to the plugin. It is only valid after
734 // |sent_initial_did_change_view_| is set to true. 742 // |sent_initial_did_change_view_| is set to true.
735 ppapi::ViewData last_sent_view_data_; 743 ppapi::ViewData last_sent_view_data_;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 // view change events. 930 // view change events.
923 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; 931 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_;
924 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; 932 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_;
925 933
926 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); 934 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl);
927 }; 935 };
928 936
929 } // namespace content 937 } // namespace content
930 938
931 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ 939 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_graphics_2d_host.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698