Chromium Code Reviews| Index: content/renderer/gpu/gpu_benchmarking_extension.cc |
| diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc |
| index 8fe5bae7d4889f1e6ea25c7f664b61aeae027afc..209dcc80533156a2be4051808841590bbe70e263 100644 |
| --- a/content/renderer/gpu/gpu_benchmarking_extension.cc |
| +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc |
| @@ -21,6 +21,7 @@ |
| #include "content/common/child_process_messages.h" |
| #include "content/common/input/synthetic_gesture_params.h" |
| #include "content/common/input/synthetic_pinch_gesture_params.h" |
| +#include "content/common/input/synthetic_pointer_action_params.h" |
| #include "content/common/input/synthetic_smooth_drag_gesture_params.h" |
| #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| #include "content/common/input/synthetic_tap_gesture_params.h" |
| @@ -502,6 +503,7 @@ gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder( |
| .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) |
| .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) |
| .SetMethod("tap", &GpuBenchmarking::Tap) |
| + .SetMethod("touchActionSequence", &GpuBenchmarking::TouchActionSequence) |
| .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) |
| .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) |
| .SetMethod("sendMessageToMicroBenchmark", |
| @@ -883,6 +885,74 @@ bool GpuBenchmarking::Tap(gin::Arguments* args) { |
| return true; |
| } |
| +bool GpuBenchmarking::TouchActionSequence(gin::Arguments* args) { |
|
tdresser
2016/05/13 13:58:04
This patch is getting a little big - maybe we coul
lanwei
2016/05/19 16:04:13
Sure. I will remove this file from this patch.
|
| + GpuBenchmarkingContext context; |
| + if (!context.Init(false)) |
| + return false; |
| + |
| + v8::Local<v8::Function> callback; |
| + |
| + // pass a two-dimensional list of actions. |
| + |
| + int pointer_action_type_int; |
| + int index; |
| + float position_x; |
| + float position_y; |
| + int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; |
| + SyntheticPointerActionParams::PointerActionType pointer_action_type; |
| + if (!GetArg(args, &pointer_action_type_int)) { |
| + return false; |
| + } |
| + pointer_action_type = |
| + static_cast<SyntheticPointerActionParams::PointerActionType>( |
| + pointer_action_type_int); |
| + std::unique_ptr<SyntheticPointerActionParams> gesture_params( |
| + new SyntheticPointerActionParams(pointer_action_type)); |
| + |
| + if (pointer_action_type != |
| + SyntheticPointerActionParams::PointerActionType::PROCESS && |
| + pointer_action_type != |
| + SyntheticPointerActionParams::PointerActionType::FINISH) { |
| + if (!GetArg(args, &index)) { |
| + return false; |
| + } |
| + gesture_params->set_index(index); |
| + if (pointer_action_type == |
| + SyntheticPointerActionParams::PointerActionType::PRESS || |
| + pointer_action_type == |
| + SyntheticPointerActionParams::PointerActionType::MOVE) { |
| + if (!GetArg(args, &position_x) || !GetArg(args, &position_y)) { |
| + return false; |
| + } |
| + gesture_params->set_position(gfx::PointF(position_x, position_y)); |
| + } |
| + } |
| + |
| + if (!GetOptionalArg(args, &gesture_source_type)) { |
| + return false; |
| + } |
| + |
| + if (pointer_action_type != |
| + SyntheticPointerActionParams::PointerActionType::FINISH) { |
| + context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
| + std::move(gesture_params)); |
| + return true; |
| + } |
| + |
| + // At the end, we will send a 'FINISH' action and need a callback. |
| + scoped_refptr<CallbackAndContext> callback_and_context = |
| + new CallbackAndContext(args->isolate(), callback, |
| + context.web_frame()->mainWorldScriptContext()); |
| + // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
| + // progress, we will leak the callback and context. This needs to be fixed, |
| + // somehow. |
| + context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
| + std::move(gesture_params), |
| + base::Bind(&OnSyntheticGestureCompleted, |
| + base::RetainedRef(callback_and_context))); |
| + return true; |
| +} |
| + |
| void GpuBenchmarking::ClearImageCache() { |
| WebImageCache::clear(); |
| } |