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 e95a9f0de0530c423272ca97e73c633063768624..c06858644bb2952294407476b9ae9073dee926d1 100644 |
| --- a/content/renderer/gpu/gpu_benchmarking_extension.cc |
| +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc |
| @@ -18,6 +18,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" |
| @@ -499,6 +500,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", |
| @@ -806,6 +808,7 @@ float GpuBenchmarking::VisualViewportWidth() { |
| } |
| bool GpuBenchmarking::Tap(gin::Arguments* args) { |
| + LOG(ERROR) << "GpuBenchmarking::Tap"; |
| GpuBenchmarkingContext context; |
| if (!context.Init(false)) |
| return false; |
| @@ -858,6 +861,73 @@ bool GpuBenchmarking::Tap(gin::Arguments* args) { |
| return true; |
| } |
| +bool GpuBenchmarking::TouchActionSequence(gin::Arguments* args) { |
| + GpuBenchmarkingContext context; |
| + if (!context.Init(false)) |
| + return false; |
| + |
| + v8::Local<v8::Function> callback; |
| + |
| + // pass a two-dimensional list of actions. |
|
tdresser
2016/04/18 15:24:39
pass -> Pass
Is this supposed to be currently pas
lanwei
2016/04/19 19:05:32
Yes, it should be 2D array. I am not sure how to c
|
| + |
| + 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); |
| + LOG(ERROR) << "GpuBenchmarking::TouchActionSequence " |
| + << pointer_action_type_int; |
| + scoped_ptr<SyntheticPointerActionParams> gesture_params( |
| + new SyntheticPointerActionParams(pointer_action_type)); |
| + |
| + if (pointer_action_type != |
| + SyntheticPointerActionParams::PointerActionType::PROCESS) { |
| + 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; |
| + } |
| + |
| + // We do not need a callback everytime sending an action? |
| + 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)); |
| + |
| + // At the end, ask for call back? |
| + // 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(); |
| } |