OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/devtools/protocol/input_handler.h" | 5 #include "content/browser/devtools/protocol/input_handler.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 391 } |
392 | 392 |
393 void InputHandler::SynthesizeRepeatingScroll( | 393 void InputHandler::SynthesizeRepeatingScroll( |
394 SyntheticSmoothScrollGestureParams gesture_params, | 394 SyntheticSmoothScrollGestureParams gesture_params, |
395 int repeat_count, | 395 int repeat_count, |
396 base::TimeDelta repeat_delay, | 396 base::TimeDelta repeat_delay, |
397 std::string interaction_marker_name, | 397 std::string interaction_marker_name, |
398 DevToolsCommandId command_id) { | 398 DevToolsCommandId command_id) { |
399 if (!interaction_marker_name.empty()) { | 399 if (!interaction_marker_name.empty()) { |
400 // TODO(alexclarke): Can we move this elsewhere? It doesn't really fit here. | 400 // TODO(alexclarke): Can we move this elsewhere? It doesn't really fit here. |
401 TRACE_EVENT_COPY_ASYNC_BEGIN0("benchmark", | 401 TRACE_EVENT_COPY_ASYNC_BEGIN0("benchmark", interaction_marker_name.c_str(), |
402 interaction_marker_name.c_str(), command_id); | 402 command_id.call_id); |
403 } | 403 } |
404 | 404 |
405 host_->QueueSyntheticGesture( | 405 host_->QueueSyntheticGesture( |
406 SyntheticGesture::Create(gesture_params), | 406 SyntheticGesture::Create(gesture_params), |
407 base::Bind(&InputHandler::OnScrollFinished, weak_factory_.GetWeakPtr(), | 407 base::Bind(&InputHandler::OnScrollFinished, weak_factory_.GetWeakPtr(), |
408 gesture_params, repeat_count, repeat_delay, | 408 gesture_params, repeat_count, repeat_delay, |
409 interaction_marker_name, command_id)); | 409 interaction_marker_name, command_id)); |
410 } | 410 } |
411 | 411 |
412 void InputHandler::OnScrollFinished( | 412 void InputHandler::OnScrollFinished( |
413 SyntheticSmoothScrollGestureParams gesture_params, | 413 SyntheticSmoothScrollGestureParams gesture_params, |
414 int repeat_count, | 414 int repeat_count, |
415 base::TimeDelta repeat_delay, | 415 base::TimeDelta repeat_delay, |
416 std::string interaction_marker_name, | 416 std::string interaction_marker_name, |
417 DevToolsCommandId command_id, | 417 DevToolsCommandId command_id, |
418 SyntheticGesture::Result result) { | 418 SyntheticGesture::Result result) { |
419 if (!interaction_marker_name.empty()) { | 419 if (!interaction_marker_name.empty()) { |
420 TRACE_EVENT_COPY_ASYNC_END0("benchmark", | 420 TRACE_EVENT_COPY_ASYNC_END0("benchmark", interaction_marker_name.c_str(), |
421 interaction_marker_name.c_str(), command_id); | 421 command_id.call_id); |
422 } | 422 } |
423 | 423 |
424 if (repeat_count > 0) { | 424 if (repeat_count > 0) { |
425 base::MessageLoop::current()->task_runner()->PostDelayedTask( | 425 base::MessageLoop::current()->task_runner()->PostDelayedTask( |
426 FROM_HERE, | 426 FROM_HERE, |
427 base::Bind(&InputHandler::SynthesizeRepeatingScroll, | 427 base::Bind(&InputHandler::SynthesizeRepeatingScroll, |
428 weak_factory_.GetWeakPtr(), gesture_params, repeat_count - 1, | 428 weak_factory_.GetWeakPtr(), gesture_params, repeat_count - 1, |
429 repeat_delay, interaction_marker_name, command_id), | 429 repeat_delay, interaction_marker_name, command_id), |
430 repeat_delay); | 430 repeat_delay); |
431 } else { | 431 } else { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } else { | 510 } else { |
511 client_->SendError(command_id, | 511 client_->SendError(command_id, |
512 Response::InternalError(base::StringPrintf( | 512 Response::InternalError(base::StringPrintf( |
513 "Synthetic tap failed, result was %d", result))); | 513 "Synthetic tap failed, result was %d", result))); |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 } // namespace input | 517 } // namespace input |
518 } // namespace devtools | 518 } // namespace devtools |
519 } // namespace content | 519 } // namespace content |
OLD | NEW |