Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 PluginModule; | 108 class PluginModule; |
| 109 class PluginObject; | 109 class PluginObject; |
| 110 class PPB_Graphics3D_Impl; | 110 class PPB_Graphics3D_Impl; |
| 111 class PPB_ImageData_Impl; | 111 class PPB_ImageData_Impl; |
| 112 class PPB_URLLoader_Impl; | 112 class PPB_URLLoader_Impl; |
| 113 class RenderFrameImpl; | 113 class RenderFrameImpl; |
| 114 class RenderViewImpl; | 114 class RenderViewImpl; |
| 115 | 115 |
| 116 // Represents one time a plugin appears on one web page. | 116 // Represents one time a plugin appears on one web page. |
| 117 // | 117 // |
| 118 // Note: to get from a PP_Instance to a PepperPluginInstance*, use the | 118 // Note: to get from a PP_Instance to a PepperPluginInstance*, use the |
| 119 // ResourceTracker. | 119 // ResourceTracker. |
| 120 class CONTENT_EXPORT PepperPluginInstanceImpl | 120 class CONTENT_EXPORT PepperPluginInstanceImpl |
| 121 : public base::RefCounted<PepperPluginInstanceImpl>, | 121 : public base::RefCounted<PepperPluginInstanceImpl>, |
| 122 public NON_EXPORTED_BASE(PepperPluginInstance), | 122 public NON_EXPORTED_BASE(PepperPluginInstance), |
| 123 public ppapi::PPB_Instance_Shared, | 123 public ppapi::PPB_Instance_Shared, |
| 124 public NON_EXPORTED_BASE(cc::TextureLayerClient), | 124 public NON_EXPORTED_BASE(cc::TextureLayerClient), |
| 125 public RenderFrameObserver { | 125 public RenderFrameObserver, |
| 126 public NON_EXPORTED_BASE(PluginInstanceThrottler::Observer) { | |
| 126 public: | 127 public: |
| 127 // Create and return a PepperPluginInstanceImpl object which supports the most | 128 // Create and return a PepperPluginInstanceImpl object which supports the most |
| 128 // recent version of PPP_Instance possible by querying the given | 129 // recent version of PPP_Instance possible by querying the given |
| 129 // get_plugin_interface function. If the plugin does not support any valid | 130 // get_plugin_interface function. If the plugin does not support any valid |
| 130 // PPP_Instance interface, returns NULL. | 131 // PPP_Instance interface, returns NULL. |
| 131 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, | 132 static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, |
| 132 PluginModule* module, | 133 PluginModule* module, |
| 133 blink::WebPluginContainer* container, | 134 blink::WebPluginContainer* container, |
| 134 const GURL& plugin_url); | 135 const GURL& plugin_url); |
| 135 RenderFrameImpl* render_frame() const { return render_frame_; } | 136 RenderFrameImpl* render_frame() const { return render_frame_; } |
| 136 PluginModule* module() const { return module_.get(); } | 137 PluginModule* module() const { return module_.get(); } |
| 137 | 138 |
| 138 blink::WebPluginContainer* container() const { return container_; } | 139 blink::WebPluginContainer* container() const { return container_; } |
| 139 | 140 |
| 140 PepperPluginInstanceThrottler* throttler() const { return throttler_.get(); } | 141 PluginInstanceThrottler* throttler() const { return throttler_.get(); } |
| 141 | 142 |
| 142 // Returns the PP_Instance uniquely identifying this instance. Guaranteed | 143 // Returns the PP_Instance uniquely identifying this instance. Guaranteed |
| 143 // nonzero. | 144 // nonzero. |
| 144 PP_Instance pp_instance() const { return pp_instance_; } | 145 PP_Instance pp_instance() const { return pp_instance_; } |
| 145 | 146 |
| 146 ppapi::thunk::ResourceCreationAPI& resource_creation() { | 147 ppapi::thunk::ResourceCreationAPI& resource_creation() { |
| 147 return *resource_creation_.get(); | 148 return *resource_creation_.get(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 MessageChannel* message_channel() { return message_channel_; } | 151 MessageChannel* message_channel() { return message_channel_; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 void InstanceCrashed(); | 194 void InstanceCrashed(); |
| 194 | 195 |
| 195 // PPB_Instance and PPB_Instance_Private implementation. | 196 // PPB_Instance and PPB_Instance_Private implementation. |
| 196 bool full_frame() const { return full_frame_; } | 197 bool full_frame() const { return full_frame_; } |
| 197 const ppapi::ViewData& view_data() const { return view_data_; } | 198 const ppapi::ViewData& view_data() const { return view_data_; } |
| 198 | 199 |
| 199 // PPP_Instance and PPP_Instance_Private. | 200 // PPP_Instance and PPP_Instance_Private. |
| 200 bool Initialize(const std::vector<std::string>& arg_names, | 201 bool Initialize(const std::vector<std::string>& arg_names, |
| 201 const std::vector<std::string>& arg_values, | 202 const std::vector<std::string>& arg_values, |
| 202 bool full_frame, | 203 bool full_frame, |
| 203 RenderFrame::PluginPowerSaverMode power_saver_mode); | 204 PluginInstanceThrottler* throttler); |
| 204 bool HandleDocumentLoad(const blink::WebURLResponse& response); | 205 bool HandleDocumentLoad(const blink::WebURLResponse& response); |
| 205 bool HandleInputEvent(const blink::WebInputEvent& event, | 206 bool HandleInputEvent(const blink::WebInputEvent& event, |
| 206 blink::WebCursorInfo* cursor_info); | 207 blink::WebCursorInfo* cursor_info); |
| 207 PP_Var GetInstanceObject(v8::Isolate* isolate); | 208 PP_Var GetInstanceObject(v8::Isolate* isolate); |
| 208 void ViewChanged(const gfx::Rect& position, | 209 void ViewChanged(const gfx::Rect& position, |
| 209 const gfx::Rect& clip, | 210 const gfx::Rect& clip, |
| 210 const std::vector<gfx::Rect>& cut_outs_rects); | 211 const std::vector<gfx::Rect>& cut_outs_rects); |
| 211 | 212 |
| 212 // Handlers for composition events. | 213 // Handlers for composition events. |
| 213 bool HandleCompositionStart(const base::string16& text); | 214 bool HandleCompositionStart(const base::string16& text); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 | 532 |
| 532 // cc::TextureLayerClient implementation. | 533 // cc::TextureLayerClient implementation. |
| 533 bool PrepareTextureMailbox( | 534 bool PrepareTextureMailbox( |
| 534 cc::TextureMailbox* mailbox, | 535 cc::TextureMailbox* mailbox, |
| 535 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 536 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
| 536 bool use_shared_memory) override; | 537 bool use_shared_memory) override; |
| 537 | 538 |
| 538 // RenderFrameObserver | 539 // RenderFrameObserver |
| 539 void OnDestruct() override; | 540 void OnDestruct() override; |
| 540 | 541 |
| 542 // PluginInstanceThrottler::Observer | |
| 543 void OnThrottleStateChange() override; | |
| 544 | |
| 541 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 545 void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
| 542 | 546 |
| 543 private: | 547 private: |
| 544 friend class base::RefCounted<PepperPluginInstanceImpl>; | 548 friend class base::RefCounted<PepperPluginInstanceImpl>; |
| 545 friend class PpapiPluginInstanceTest; | 549 friend class PpapiPluginInstanceTest; |
| 546 friend class PpapiUnittest; | 550 friend class PpapiUnittest; |
| 547 | 551 |
| 548 // Delete should be called by the WebPlugin before this destructor. | 552 // Delete should be called by the WebPlugin before this destructor. |
| 549 ~PepperPluginInstanceImpl() override; | 553 ~PepperPluginInstanceImpl() override; |
| 550 | 554 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 scoped_ptr<blink::WebLayer> web_layer_; | 715 scoped_ptr<blink::WebLayer> web_layer_; |
| 712 bool layer_bound_to_fullscreen_; | 716 bool layer_bound_to_fullscreen_; |
| 713 bool layer_is_hardware_; | 717 bool layer_is_hardware_; |
| 714 | 718 |
| 715 // Plugin URL. | 719 // Plugin URL. |
| 716 GURL plugin_url_; | 720 GURL plugin_url_; |
| 717 | 721 |
| 718 // Used to track Flash-specific metrics. | 722 // Used to track Flash-specific metrics. |
| 719 bool is_flash_plugin_; | 723 bool is_flash_plugin_; |
| 720 | 724 |
| 725 // Set to true first time plugin is clicked. Used to collect metrics. | |
|
Bernhard Bauer
2015/01/13 23:29:36
Nit: "Set to true _the_ first time _the_ plugin is
tommycli
2015/01/14 01:45:00
Done.
| |
| 726 bool has_been_clicked_; | |
| 727 | |
| 721 // Used to track if JavaScript has ever been used for this plugin instance. | 728 // Used to track if JavaScript has ever been used for this plugin instance. |
| 722 bool javascript_used_; | 729 bool javascript_used_; |
| 723 | 730 |
| 724 // Responsible for turning on throttling if Power Saver is on. | 731 // Responsible for turning on throttling if Power Saver is on. |
| 725 scoped_ptr<PepperPluginInstanceThrottler> throttler_; | 732 scoped_ptr<PluginInstanceThrottler> throttler_; |
| 726 | 733 |
| 727 // Indicates whether this is a full frame instance, which means it represents | 734 // Indicates whether this is a full frame instance, which means it represents |
| 728 // an entire document rather than an embed tag. | 735 // an entire document rather than an embed tag. |
| 729 bool full_frame_; | 736 bool full_frame_; |
| 730 | 737 |
| 731 // Stores the current state of the plugin view. | 738 // Stores the current state of the plugin view. |
| 732 ppapi::ViewData view_data_; | 739 ppapi::ViewData view_data_; |
| 733 // The last state sent to the plugin. It is only valid after | 740 // The last state sent to the plugin. It is only valid after |
| 734 // |sent_initial_did_change_view_| is set to true. | 741 // |sent_initial_did_change_view_| is set to true. |
| 735 ppapi::ViewData last_sent_view_data_; | 742 ppapi::ViewData last_sent_view_data_; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 // view change events. | 929 // view change events. |
| 923 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; | 930 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; |
| 924 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; | 931 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; |
| 925 | 932 |
| 926 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); | 933 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); |
| 927 }; | 934 }; |
| 928 | 935 |
| 929 } // namespace content | 936 } // namespace content |
| 930 | 937 |
| 931 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 938 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| OLD | NEW |