Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: content/browser/renderer_host/input/mouse_wheel_event_queue.cc

Issue 2435863004: Remove stl_util's deletion function use from content/. (Closed)
Patch Set: minus service worker Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/renderer_host/input/mouse_wheel_event_queue.h" 5 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
8 #include "base/stl_util.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "ui/events/blink/web_input_event_traits.h" 10 #include "ui/events/blink/web_input_event_traits.h"
11 11
12 using blink::WebGestureEvent; 12 using blink::WebGestureEvent;
13 using blink::WebInputEvent; 13 using blink::WebInputEvent;
14 using blink::WebMouseWheelEvent; 14 using blink::WebMouseWheelEvent;
15 using ui::LatencyInfo; 15 using ui::LatencyInfo;
16 16
17 namespace content { 17 namespace content {
18 18
(...skipping 20 matching lines...) Expand all
39 needs_scroll_begin_(true), 39 needs_scroll_begin_(true),
40 needs_scroll_end_(false), 40 needs_scroll_end_(false),
41 enable_scroll_latching_(enable_scroll_latching), 41 enable_scroll_latching_(enable_scroll_latching),
42 scrolling_device_(blink::WebGestureDeviceUninitialized) { 42 scrolling_device_(blink::WebGestureDeviceUninitialized) {
43 DCHECK(client); 43 DCHECK(client);
44 scroll_transaction_ms_ = 44 scroll_transaction_ms_ =
45 enable_scroll_latching_ ? kDefaultWheelScrollLatchingTransactionMs : 0; 45 enable_scroll_latching_ ? kDefaultWheelScrollLatchingTransactionMs : 0;
46 } 46 }
47 47
48 MouseWheelEventQueue::~MouseWheelEventQueue() { 48 MouseWheelEventQueue::~MouseWheelEventQueue() {
49 if (!wheel_queue_.empty())
50 base::STLDeleteElements(&wheel_queue_);
51 } 49 }
52 50
53 void MouseWheelEventQueue::QueueEvent( 51 void MouseWheelEventQueue::QueueEvent(
54 const MouseWheelEventWithLatencyInfo& event) { 52 const MouseWheelEventWithLatencyInfo& event) {
55 TRACE_EVENT0("input", "MouseWheelEventQueue::QueueEvent"); 53 TRACE_EVENT0("input", "MouseWheelEventQueue::QueueEvent");
56 54
57 if (event_sent_for_gesture_ack_ && !wheel_queue_.empty()) { 55 if (event_sent_for_gesture_ack_ && !wheel_queue_.empty()) {
58 QueuedWebMouseWheelEvent* last_event = wheel_queue_.back(); 56 QueuedWebMouseWheelEvent* last_event = wheel_queue_.back().get();
59 if (last_event->CanCoalesceWith(event)) { 57 if (last_event->CanCoalesceWith(event)) {
60 last_event->CoalesceWith(event); 58 last_event->CoalesceWith(event);
61 TRACE_EVENT_INSTANT2("input", "MouseWheelEventQueue::CoalescedWheelEvent", 59 TRACE_EVENT_INSTANT2("input", "MouseWheelEventQueue::CoalescedWheelEvent",
62 TRACE_EVENT_SCOPE_THREAD, "total_dx", 60 TRACE_EVENT_SCOPE_THREAD, "total_dx",
63 last_event->event.deltaX, "total_dy", 61 last_event->event.deltaX, "total_dy",
64 last_event->event.deltaY); 62 last_event->event.deltaY);
65 return; 63 return;
66 } 64 }
67 } 65 }
68 66
69 wheel_queue_.push_back(new QueuedWebMouseWheelEvent(event)); 67 wheel_queue_.push_back(base::MakeUnique<QueuedWebMouseWheelEvent>(event));
70 TryForwardNextEventToRenderer(); 68 TryForwardNextEventToRenderer();
71 LOCAL_HISTOGRAM_COUNTS_100("Renderer.WheelQueueSize", wheel_queue_.size()); 69 LOCAL_HISTOGRAM_COUNTS_100("Renderer.WheelQueueSize", wheel_queue_.size());
72 } 70 }
73 71
74 void MouseWheelEventQueue::ProcessMouseWheelAck( 72 void MouseWheelEventQueue::ProcessMouseWheelAck(
75 InputEventAckState ack_result, 73 InputEventAckState ack_result,
76 const LatencyInfo& latency_info) { 74 const LatencyInfo& latency_info) {
77 TRACE_EVENT0("input", "MouseWheelEventQueue::ProcessMouseWheelAck"); 75 TRACE_EVENT0("input", "MouseWheelEventQueue::ProcessMouseWheelAck");
78 if (!event_sent_for_gesture_ack_) 76 if (!event_sent_for_gesture_ack_)
79 return; 77 return;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 scroll_end_timer_.Reset(); 242 scroll_end_timer_.Reset();
245 } 243 }
246 } 244 }
247 245
248 void MouseWheelEventQueue::TryForwardNextEventToRenderer() { 246 void MouseWheelEventQueue::TryForwardNextEventToRenderer() {
249 TRACE_EVENT0("input", "MouseWheelEventQueue::TryForwardNextEventToRenderer"); 247 TRACE_EVENT0("input", "MouseWheelEventQueue::TryForwardNextEventToRenderer");
250 248
251 if (wheel_queue_.empty() || event_sent_for_gesture_ack_) 249 if (wheel_queue_.empty() || event_sent_for_gesture_ack_)
252 return; 250 return;
253 251
254 event_sent_for_gesture_ack_.reset(wheel_queue_.front()); 252 event_sent_for_gesture_ack_ = std::move(wheel_queue_.front());
255 wheel_queue_.pop_front(); 253 wheel_queue_.pop_front();
256 254
257 client_->SendMouseWheelEventImmediately(*event_sent_for_gesture_ack_); 255 client_->SendMouseWheelEventImmediately(*event_sent_for_gesture_ack_);
258 } 256 }
259 257
260 void MouseWheelEventQueue::SendScrollEnd(WebGestureEvent update_event, 258 void MouseWheelEventQueue::SendScrollEnd(WebGestureEvent update_event,
261 bool synthetic) { 259 bool synthetic) {
262 DCHECK((synthetic && !needs_scroll_end_) || needs_scroll_end_); 260 DCHECK((synthetic && !needs_scroll_end_) || needs_scroll_end_);
263 261
264 WebGestureEvent scroll_end(update_event); 262 WebGestureEvent scroll_end(update_event);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 scroll_begin.data.scrollBegin.deltaHintUnits = 299 scroll_begin.data.scrollBegin.deltaHintUnits =
302 gesture_update.data.scrollUpdate.deltaUnits; 300 gesture_update.data.scrollUpdate.deltaUnits;
303 301
304 needs_scroll_begin_ = false; 302 needs_scroll_begin_ = false;
305 needs_scroll_end_ = true; 303 needs_scroll_end_ = true;
306 client_->ForwardGestureEventWithLatencyInfo( 304 client_->ForwardGestureEventWithLatencyInfo(
307 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL)); 305 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL));
308 } 306 }
309 307
310 } // namespace content 308 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/mouse_wheel_event_queue.h ('k') | content/browser/renderer_host/input/touch_event_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698