Chromium Code Reviews| Index: content/renderer/pepper/pepper_plugin_instance_impl.cc |
| diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| index a951355d10bca87b7fa04549c13209392ffb5886..edfc2e69fbac5e8b91f651e030f929dc8d135184 100644 |
| --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| @@ -16,11 +16,15 @@ |
| #include "base/strings/utf_offset_string_conversions.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/time/time.h" |
| +#include "cc/base/latency_info_swap_promise.h" |
| #include "cc/layers/texture_layer.h" |
| +#include "cc/trees/layer_tree_host.h" |
| #include "content/common/content_constants_internal.h" |
| +#include "content/common/input/web_input_event_traits.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/page_zoom.h" |
| #include "content/public/renderer/content_renderer_client.h" |
| +#include "content/renderer/gpu/render_widget_compositor.h" |
| #include "content/renderer/pepper/common.h" |
| #include "content/renderer/pepper/content_decryptor_delegate.h" |
| #include "content/renderer/pepper/event_conversion.h" |
| @@ -402,6 +406,23 @@ class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { |
| PepperPluginInstanceImpl* plugin_; |
| }; |
| +void InitLatencyInfo(ui::LatencyInfo* new_latency, |
| + const ui::LatencyInfo* old_latency, |
| + blink::WebInputEvent::Type type, |
| + int64 input_sequence) { |
| + new_latency->AddLatencyNumber( |
| + ui::INPUT_EVENT_LATENCY_BEGIN_PLUGIN_COMPONENT, |
| + 0, |
| + input_sequence); |
| + new_latency->TraceEventType(WebInputEventTraits::GetName(type)); |
| + if (old_latency) { |
| + new_latency->CopyLatencyFrom(*old_latency, |
| + ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); |
| + new_latency->CopyLatencyFrom(*old_latency, |
| + ui::INPUT_EVENT_LATENCY_UI_COMPONENT); |
| + } |
| +} |
| + |
| } // namespace |
| // static |
| @@ -538,6 +559,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
| npp_(new NPP_t), |
| isolate_(v8::Isolate::GetCurrent()), |
| is_deleted_(false), |
| + last_input_number_(0), |
| view_change_weak_ptr_factory_(this), |
| weak_factory_(this) { |
| pp_instance_ = HostGlobals::Get()->AddInstance(this); |
| @@ -1094,8 +1116,18 @@ bool PepperPluginInstanceImpl::HandleInputEvent( |
| pending_user_gesture_token_.setOutOfProcess(); |
| } |
| + const ui::LatencyInfo* current_event_latency_info = NULL; |
| + if (render_frame_->GetRenderWidget()) { |
| + current_event_latency_info = |
| + render_frame_->GetRenderWidget()->current_event_latency_info(); |
| + } |
| + |
| // Each input event may generate more than one PP_InputEvent. |
| for (size_t i = 0; i < events.size(); i++) { |
| + InitLatencyInfo(&events[i].latency_info, |
|
dmichael (off chromium)
2014/05/05 22:20:32
You're doing some work here even if the plugin isn
Yufeng Shen (Slow to review)
2014/05/07 17:12:14
done.
|
| + current_event_latency_info, |
| + event.type, |
| + last_input_number_++); |
| if (filtered_input_event_mask_ & event_class) |
| events[i].is_filtered = true; |
| else |
| @@ -1988,6 +2020,21 @@ bool PepperPluginInstanceImpl::PrepareTextureMailbox( |
| void PepperPluginInstanceImpl::OnDestruct() { render_frame_ = NULL; } |
| +void PepperPluginInstanceImpl::AddLatencyInfo( |
| + const std::vector<ui::LatencyInfo>& latency_info) { |
| + if (render_frame_ && render_frame_->GetRenderWidget()) { |
| + RenderWidgetCompositor* compositor = |
| + render_frame_->GetRenderWidget()->compositor(); |
| + if (compositor) { |
| + for (size_t i = 0; i < latency_info.size(); i++) { |
| + scoped_ptr<cc::SwapPromise> swap_promise( |
| + new cc::LatencyInfoSwapPromise(latency_info[i])); |
| + compositor->QueueSwapPromise(swap_promise.Pass()); |
| + } |
| + } |
| + } |
| +} |
| + |
| void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { |
| DCHECK(live_plugin_objects_.find(plugin_object) == |
| live_plugin_objects_.end()); |