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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "content/browser/renderer_host/input/input_ack_handler.h" | 7 #include "content/browser/renderer_host/input/input_ack_handler.h" |
8 #include "content/browser/renderer_host/input/input_router_client.h" | 8 #include "content/browser/renderer_host/input/input_router_client.h" |
9 #include "content/browser/renderer_host/input/input_router_impl.h" | 9 #include "content/browser/renderer_host/input/input_router_impl.h" |
10 #include "content/common/input/web_input_event_traits.h" | 10 #include "content/common/input/web_input_event_traits.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 class NullInputAckHandler : public InputAckHandler { | 28 class NullInputAckHandler : public InputAckHandler { |
29 public: | 29 public: |
30 NullInputAckHandler() : ack_count_(0) {} | 30 NullInputAckHandler() : ack_count_(0) {} |
31 virtual ~NullInputAckHandler() {} | 31 virtual ~NullInputAckHandler() {} |
32 | 32 |
33 // InputAckHandler | 33 // InputAckHandler |
34 virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event, | 34 virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event, |
35 InputEventAckState ack_result) OVERRIDE { | 35 InputEventAckState ack_result) override { |
36 ++ack_count_; | 36 ++ack_count_; |
37 } | 37 } |
38 virtual void OnWheelEventAck(const MouseWheelEventWithLatencyInfo& event, | 38 virtual void OnWheelEventAck(const MouseWheelEventWithLatencyInfo& event, |
39 InputEventAckState ack_result) OVERRIDE { | 39 InputEventAckState ack_result) override { |
40 ++ack_count_; | 40 ++ack_count_; |
41 } | 41 } |
42 virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 42 virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
43 InputEventAckState ack_result) OVERRIDE { | 43 InputEventAckState ack_result) override { |
44 ++ack_count_; | 44 ++ack_count_; |
45 } | 45 } |
46 virtual void OnGestureEventAck(const GestureEventWithLatencyInfo& event, | 46 virtual void OnGestureEventAck(const GestureEventWithLatencyInfo& event, |
47 InputEventAckState ack_result) OVERRIDE { | 47 InputEventAckState ack_result) override { |
48 ++ack_count_; | 48 ++ack_count_; |
49 } | 49 } |
50 virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) OVERRIDE { | 50 virtual void OnUnexpectedEventAck(UnexpectedEventAckType type) override { |
51 ++ack_count_; | 51 ++ack_count_; |
52 } | 52 } |
53 | 53 |
54 size_t GetAndResetAckCount() { | 54 size_t GetAndResetAckCount() { |
55 size_t ack_count = ack_count_; | 55 size_t ack_count = ack_count_; |
56 ack_count_ = 0; | 56 ack_count_ = 0; |
57 return ack_count; | 57 return ack_count; |
58 } | 58 } |
59 | 59 |
60 size_t ack_count() const { return ack_count_; } | 60 size_t ack_count() const { return ack_count_; } |
61 | 61 |
62 private: | 62 private: |
63 size_t ack_count_; | 63 size_t ack_count_; |
64 }; | 64 }; |
65 | 65 |
66 class NullInputRouterClient : public InputRouterClient { | 66 class NullInputRouterClient : public InputRouterClient { |
67 public: | 67 public: |
68 NullInputRouterClient() {} | 68 NullInputRouterClient() {} |
69 virtual ~NullInputRouterClient() {} | 69 virtual ~NullInputRouterClient() {} |
70 | 70 |
71 // InputRouterClient | 71 // InputRouterClient |
72 virtual InputEventAckState FilterInputEvent( | 72 virtual InputEventAckState FilterInputEvent( |
73 const blink::WebInputEvent& input_event, | 73 const blink::WebInputEvent& input_event, |
74 const ui::LatencyInfo& latency_info) OVERRIDE { | 74 const ui::LatencyInfo& latency_info) override { |
75 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 75 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
76 } | 76 } |
77 virtual void IncrementInFlightEventCount() OVERRIDE {} | 77 virtual void IncrementInFlightEventCount() override {} |
78 virtual void DecrementInFlightEventCount() OVERRIDE {} | 78 virtual void DecrementInFlightEventCount() override {} |
79 virtual void OnHasTouchEventHandlers(bool has_handlers) OVERRIDE {} | 79 virtual void OnHasTouchEventHandlers(bool has_handlers) override {} |
80 virtual void DidFlush() OVERRIDE {} | 80 virtual void DidFlush() override {} |
81 virtual void SetNeedsFlush() OVERRIDE {} | 81 virtual void SetNeedsFlush() override {} |
82 virtual void DidOverscroll(const DidOverscrollParams& params) OVERRIDE {} | 82 virtual void DidOverscroll(const DidOverscrollParams& params) override {} |
83 }; | 83 }; |
84 | 84 |
85 class NullIPCSender : public IPC::Sender { | 85 class NullIPCSender : public IPC::Sender { |
86 public: | 86 public: |
87 NullIPCSender() : sent_count_(0) {} | 87 NullIPCSender() : sent_count_(0) {} |
88 virtual ~NullIPCSender() {} | 88 virtual ~NullIPCSender() {} |
89 | 89 |
90 virtual bool Send(IPC::Message* message) OVERRIDE { | 90 virtual bool Send(IPC::Message* message) override { |
91 delete message; | 91 delete message; |
92 ++sent_count_; | 92 ++sent_count_; |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 size_t GetAndResetSentEventCount() { | 96 size_t GetAndResetSentEventCount() { |
97 size_t message_count = sent_count_; | 97 size_t message_count = sent_count_; |
98 sent_count_ = 0; | 98 sent_count_ = 0; |
99 return message_count; | 99 return message_count; |
100 } | 100 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 } // namespace | 195 } // namespace |
196 | 196 |
197 class InputRouterImplPerfTest : public testing::Test { | 197 class InputRouterImplPerfTest : public testing::Test { |
198 public: | 198 public: |
199 InputRouterImplPerfTest() : last_input_id_(0) {} | 199 InputRouterImplPerfTest() : last_input_id_(0) {} |
200 virtual ~InputRouterImplPerfTest() {} | 200 virtual ~InputRouterImplPerfTest() {} |
201 | 201 |
202 protected: | 202 protected: |
203 // testing::Test | 203 // testing::Test |
204 virtual void SetUp() OVERRIDE { | 204 virtual void SetUp() override { |
205 sender_.reset(new NullIPCSender()); | 205 sender_.reset(new NullIPCSender()); |
206 client_.reset(new NullInputRouterClient()); | 206 client_.reset(new NullInputRouterClient()); |
207 ack_handler_.reset(new NullInputAckHandler()); | 207 ack_handler_.reset(new NullInputAckHandler()); |
208 input_router_.reset(new InputRouterImpl(sender_.get(), | 208 input_router_.reset(new InputRouterImpl(sender_.get(), |
209 client_.get(), | 209 client_.get(), |
210 ack_handler_.get(), | 210 ack_handler_.get(), |
211 MSG_ROUTING_NONE, | 211 MSG_ROUTING_NONE, |
212 InputRouterImpl::Config())); | 212 InputRouterImpl::Config())); |
213 } | 213 } |
214 | 214 |
215 virtual void TearDown() OVERRIDE { | 215 virtual void TearDown() override { |
216 base::MessageLoop::current()->RunUntilIdle(); | 216 base::MessageLoop::current()->RunUntilIdle(); |
217 | 217 |
218 input_router_.reset(); | 218 input_router_.reset(); |
219 ack_handler_.reset(); | 219 ack_handler_.reset(); |
220 client_.reset(); | 220 client_.reset(); |
221 sender_.reset(); | 221 sender_.reset(); |
222 } | 222 } |
223 | 223 |
224 void SendEvent(const WebGestureEvent& gesture, | 224 void SendEvent(const WebGestureEvent& gesture, |
225 const ui::LatencyInfo& latency) { | 225 const ui::LatencyInfo& latency) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { | 379 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { |
380 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", | 380 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", |
381 kDefaultSteps, | 381 kDefaultSteps, |
382 kDefaultOrigin, | 382 kDefaultOrigin, |
383 kDefaultDistance, | 383 kDefaultDistance, |
384 kDefaultIterations); | 384 kDefaultIterations); |
385 } | 385 } |
386 | 386 |
387 } // namespace content | 387 } // namespace content |
OLD | NEW |