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

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: Adding UMA stats to track usage of DragAndDrop, on Chromeos, X11 and Windows. 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.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 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) {
164 UMA_HISTOGRAM_COUNTS("DragDrop.Touch.Start", 1);
mfomitchev 2015/01/08 23:30:59 I think a single shared UMA_HISTOGRAM_ENUMERATION
caelyn 2015/01/12 22:43:10 I made the changes in histograms.xml and elsewhere
165 } else if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) {
166 UMA_HISTOGRAM_COUNTS("DragDrop.Mouse.Start", 1);
167 }
168
162 current_drag_event_source_ = source; 169 current_drag_event_source_ = source;
163 DragDropTracker* tracker = 170 DragDropTracker* tracker =
164 new DragDropTracker(root_window, drag_drop_window_delegate_.get()); 171 new DragDropTracker(root_window, drag_drop_window_delegate_.get());
165 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) { 172 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) {
166 // We need to transfer the current gesture sequence and the GR's touch event 173 // 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 174 // queue to the |drag_drop_tracker_|'s capture window so that when it takes
168 // capture, it still gets a valid gesture state. 175 // capture, it still gets a valid gesture state.
169 ui::GestureRecognizer::Get()->TransferEventsTo(source_window, 176 ui::GestureRecognizer::Get()->TransferEventsTo(source_window,
170 tracker->capture_window()); 177 tracker->capture_window());
171 // We also send a gesture end to the source window so it can clear state. 178 // 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); 310 DragUpdate(target, event);
304 DCHECK(target == drag_window_); 311 DCHECK(target == drag_window_);
305 312
306 aura::client::DragDropDelegate* delegate = 313 aura::client::DragDropDelegate* delegate =
307 aura::client::GetDragDropDelegate(target); 314 aura::client::GetDragDropDelegate(target);
308 if (delegate) { 315 if (delegate) {
309 ui::DropTargetEvent e( 316 ui::DropTargetEvent e(
310 *drag_data_, event.location(), event.root_location(), drag_operation_); 317 *drag_data_, event.location(), event.root_location(), drag_operation_);
311 e.set_flags(event.flags()); 318 e.set_flags(event.flags());
312 drag_operation_ = delegate->OnPerformDrop(e); 319 drag_operation_ = delegate->OnPerformDrop(e);
313 if (drag_operation_ == 0) 320 if (drag_operation_ == 0) {
314 StartCanceledAnimation(kCancelAnimationDuration); 321 StartCanceledAnimation(kCancelAnimationDuration);
mfomitchev 2015/01/08 23:30:59 don't we need to log a Cancel here?
caelyn 2015/01/12 22:43:10 Done. This changes the semantics of cancel to be l
315 else 322 } else {
323 if (current_drag_event_source_ ==
324 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) {
325 UMA_HISTOGRAM_COUNTS("DragDrop.Touch.Drop", 1);
326 } else if (current_drag_event_source_ ==
327 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) {
328 UMA_HISTOGRAM_COUNTS("DragDrop.Mouse.Drop", 1);
329 }
316 drag_image_.reset(); 330 drag_image_.reset();
331 }
317 } else { 332 } else {
318 drag_image_.reset(); 333 drag_image_.reset();
319 } 334 }
320 335
321 Cleanup(); 336 Cleanup();
322 if (should_block_during_drag_drop_) 337 if (should_block_during_drag_drop_)
323 quit_closure_.Run(); 338 quit_closure_.Run();
324 } 339 }
325 340
326 void DragDropController::DragCancel() { 341 void DragDropController::DragCancel() {
342 if (current_drag_event_source_ ==
343 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) {
344 UMA_HISTOGRAM_COUNTS("DragDrop.Touch.Cancel", 1);
345 } else if (current_drag_event_source_ ==
346 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) {
347 UMA_HISTOGRAM_COUNTS("DragDrop.Mouse.Cancel", 1);
348 }
327 DoDragCancel(kCancelAnimationDuration); 349 DoDragCancel(kCancelAnimationDuration);
328 } 350 }
329 351
330 bool DragDropController::IsDragDropInProgress() { 352 bool DragDropController::IsDragDropInProgress() {
331 return !!drag_drop_tracker_.get(); 353 return !!drag_drop_tracker_.get();
332 } 354 }
333 355
334 void DragDropController::OnKeyEvent(ui::KeyEvent* event) { 356 void DragDropController::OnKeyEvent(ui::KeyEvent* event) {
335 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) { 357 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) {
336 DragCancel(); 358 DragCancel();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (drag_window_) 571 if (drag_window_)
550 drag_window_->RemoveObserver(this); 572 drag_window_->RemoveObserver(this);
551 drag_window_ = NULL; 573 drag_window_ = NULL;
552 drag_data_ = NULL; 574 drag_data_ = NULL;
553 // Cleanup can be called again while deleting DragDropTracker, so delete 575 // Cleanup can be called again while deleting DragDropTracker, so delete
554 // the pointer with a local variable to avoid double free. 576 // the pointer with a local variable to avoid double free.
555 scoped_ptr<ash::DragDropTracker> holder = drag_drop_tracker_.Pass(); 577 scoped_ptr<ash::DragDropTracker> holder = drag_drop_tracker_.Pass();
556 } 578 }
557 579
558 } // namespace ash 580 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698