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

Side by Side Diff: ash/drag_drop/drag_drop_controller.cc

Issue 800183005: Adding UMA stats for dragdrop events for both touch and mouse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing issue that would have resulted in overcounting cancel events. Created 5 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/drag_drop/drag_drop_tracker.h" 7 #include "ash/drag_drop/drag_drop_tracker.h"
8 #include "ash/drag_drop/drag_image_view.h" 8 #include "ash/drag_drop/drag_image_view.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram_macros.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "ui/aura/client/capture_client.h" 14 #include "ui/aura/client/capture_client.h"
14 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/aura/window_delegate.h" 17 #include "ui/aura/window_delegate.h"
17 #include "ui/aura/window_event_dispatcher.h" 18 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/base/dragdrop/drag_drop_types.h" 19 #include "ui/base/dragdrop/drag_drop_types.h"
19 #include "ui/base/dragdrop/os_exchange_data.h" 20 #include "ui/base/dragdrop/os_exchange_data.h"
20 #include "ui/base/hit_test.h" 21 #include "ui/base/hit_test.h"
21 #include "ui/events/event.h" 22 #include "ui/events/event.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 ui::DragDropTypes::DragEventSource source) { 153 ui::DragDropTypes::DragEventSource source) {
153 if (IsDragDropInProgress()) 154 if (IsDragDropInProgress())
154 return 0; 155 return 0;
155 156
156 const ui::OSExchangeData::Provider* provider = &data.provider(); 157 const ui::OSExchangeData::Provider* provider = &data.provider();
157 // We do not support touch drag/drop without a drag image. 158 // We do not support touch drag/drop without a drag image.
158 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH && 159 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH &&
159 provider->GetDragImage().size().IsEmpty()) 160 provider->GetDragImage().size().IsEmpty())
160 return 0; 161 return 0;
161 162
163 UMA_HISTOGRAM_ENUMERATION("DragDrop.Start", source,
164 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT);
165
162 current_drag_event_source_ = source; 166 current_drag_event_source_ = source;
163 DragDropTracker* tracker = 167 DragDropTracker* tracker =
164 new DragDropTracker(root_window, drag_drop_window_delegate_.get()); 168 new DragDropTracker(root_window, drag_drop_window_delegate_.get());
165 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) { 169 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) {
166 // We need to transfer the current gesture sequence and the GR's touch event 170 // We need to transfer the current gesture sequence and the GR's touch event
167 // queue to the |drag_drop_tracker_|'s capture window so that when it takes 171 // queue to the |drag_drop_tracker_|'s capture window so that when it takes
168 // capture, it still gets a valid gesture state. 172 // capture, it still gets a valid gesture state.
169 ui::GestureRecognizer::Get()->TransferEventsTo(source_window, 173 ui::GestureRecognizer::Get()->TransferEventsTo(source_window,
170 tracker->capture_window()); 174 tracker->capture_window());
171 // We also send a gesture end to the source window so it can clear state. 175 // We also send a gesture end to the source window so it can clear state.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 DragUpdate(target, event); 307 DragUpdate(target, event);
304 DCHECK(target == drag_window_); 308 DCHECK(target == drag_window_);
305 309
306 aura::client::DragDropDelegate* delegate = 310 aura::client::DragDropDelegate* delegate =
307 aura::client::GetDragDropDelegate(target); 311 aura::client::GetDragDropDelegate(target);
308 if (delegate) { 312 if (delegate) {
309 ui::DropTargetEvent e( 313 ui::DropTargetEvent e(
310 *drag_data_, event.location(), event.root_location(), drag_operation_); 314 *drag_data_, event.location(), event.root_location(), drag_operation_);
311 e.set_flags(event.flags()); 315 e.set_flags(event.flags());
312 drag_operation_ = delegate->OnPerformDrop(e); 316 drag_operation_ = delegate->OnPerformDrop(e);
313 if (drag_operation_ == 0) 317 if (drag_operation_ == 0) {
318 UMA_HISTOGRAM_ENUMERATION("DragDrop.Cancel", current_drag_event_source_,
319 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT);
314 StartCanceledAnimation(kCancelAnimationDuration); 320 StartCanceledAnimation(kCancelAnimationDuration);
315 else 321 } else {
322 UMA_HISTOGRAM_ENUMERATION("DragDrop.Drop", current_drag_event_source_,
323 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT);
316 drag_image_.reset(); 324 drag_image_.reset();
325 }
317 } else { 326 } else {
318 drag_image_.reset(); 327 drag_image_.reset();
319 } 328 }
320 329
321 Cleanup(); 330 Cleanup();
322 if (should_block_during_drag_drop_) 331 if (should_block_during_drag_drop_)
323 quit_closure_.Run(); 332 quit_closure_.Run();
324 } 333 }
325 334
326 void DragDropController::DragCancel() { 335 void DragDropController::DragCancel() {
336 UMA_HISTOGRAM_ENUMERATION("DragDrop.Cancel", current_drag_event_source_,
mfomitchev 2015/01/14 17:03:41 There is at least one case where DoDragCancel is c
caelyn 2015/01/21 16:29:53 Done.
mfomitchev 2015/01/21 18:54:36 Doesn't look like you've moved it. However look at
caelyn 2015/01/21 21:06:41 Oops. I confused this with another thing and hit d
337 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT);
327 DoDragCancel(kCancelAnimationDuration); 338 DoDragCancel(kCancelAnimationDuration);
328 } 339 }
329 340
330 bool DragDropController::IsDragDropInProgress() { 341 bool DragDropController::IsDragDropInProgress() {
331 return !!drag_drop_tracker_.get(); 342 return !!drag_drop_tracker_.get();
332 } 343 }
333 344
334 void DragDropController::OnKeyEvent(ui::KeyEvent* event) { 345 void DragDropController::OnKeyEvent(ui::KeyEvent* event) {
335 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) { 346 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) {
336 DragCancel(); 347 DragCancel();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 486
476 void DragDropController::AnimationEnded(const gfx::Animation* animation) { 487 void DragDropController::AnimationEnded(const gfx::Animation* animation) {
477 cancel_animation_.reset(); 488 cancel_animation_.reset();
478 489
479 // By the time we finish animation, another drag/drop session may have 490 // By the time we finish animation, another drag/drop session may have
480 // started. We do not want to destroy the drag image in that case. 491 // started. We do not want to destroy the drag image in that case.
481 if (!IsDragDropInProgress()) 492 if (!IsDragDropInProgress())
482 drag_image_.reset(); 493 drag_image_.reset();
483 if (pending_long_tap_) { 494 if (pending_long_tap_) {
484 // If not in a nested message loop, we can forward the long tap right now. 495 // If not in a nested message loop, we can forward the long tap right now.
485 if (!should_block_during_drag_drop_) 496 if (!should_block_during_drag_drop_) {
486 ForwardPendingLongTap(); 497 ForwardPendingLongTap();
487 else { 498 } else {
488 // See comment about this in OnGestureEvent(). 499 // See comment about this in OnGestureEvent().
489 base::MessageLoopForUI::current()->PostTask( 500 base::MessageLoopForUI::current()->PostTask(
490 FROM_HERE, 501 FROM_HERE,
491 base::Bind(&DragDropController::ForwardPendingLongTap, 502 base::Bind(&DragDropController::ForwardPendingLongTap,
492 weak_factory_.GetWeakPtr())); 503 weak_factory_.GetWeakPtr()));
493 } 504 }
494 } 505 }
495 } 506 }
496 507
497 void DragDropController::DoDragCancel(int drag_cancel_animation_duration_ms) { 508 void DragDropController::DoDragCancel(int drag_cancel_animation_duration_ms) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (drag_window_) 560 if (drag_window_)
550 drag_window_->RemoveObserver(this); 561 drag_window_->RemoveObserver(this);
551 drag_window_ = NULL; 562 drag_window_ = NULL;
552 drag_data_ = NULL; 563 drag_data_ = NULL;
553 // Cleanup can be called again while deleting DragDropTracker, so delete 564 // Cleanup can be called again while deleting DragDropTracker, so delete
554 // the pointer with a local variable to avoid double free. 565 // the pointer with a local variable to avoid double free.
555 scoped_ptr<ash::DragDropTracker> holder = drag_drop_tracker_.Pass(); 566 scoped_ptr<ash::DragDropTracker> holder = drag_drop_tracker_.Pass();
556 } 567 }
557 568
558 } // namespace ash 569 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698