summaryrefslogtreecommitdiffstats
path: root/ash/touch
diff options
context:
space:
mode:
authormiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-04 23:56:55 +0000
committermiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-04 23:56:55 +0000
commit9f42dec34a9b5c2360eda748dc9a975108098480 (patch)
tree68de3426261b8102d8fa09e11bf32d266b6b4885 /ash/touch
parent4de0eefcb0c03250ec287a9cfac2c503beee5ac1 (diff)
downloadchromium_src-9f42dec34a9b5c2360eda748dc9a975108098480.zip
chromium_src-9f42dec34a9b5c2360eda748dc9a975108098480.tar.gz
chromium_src-9f42dec34a9b5c2360eda748dc9a975108098480.tar.bz2
Make sure bucket_size_x/y is not 0
If the bounds.width()/height() is smaller than the kBucketCountForLocation = 100, then the bucket_size_x/y will be 0. And the following call to UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.TouchPositionX", position.x() / bucket_size_x, ...) could cause division by zero. BUG=None TEST=UMA for touch does not crash for window size smaller than 100x100 Review URL: https://chromiumcodereview.appspot.com/13455003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/touch')
-rw-r--r--ash/touch/touch_uma.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/ash/touch/touch_uma.cc b/ash/touch/touch_uma.cc
index 0853241..8279bf6 100644
--- a/ash/touch/touch_uma.cc
+++ b/ash/touch/touch_uma.cc
@@ -306,8 +306,10 @@ void TouchUMA::RecordTouchEvent(aura::Window* target,
// Record the location of the touch points.
const int kBucketCountForLocation = 100;
const gfx::Rect bounds = target->GetRootWindow()->bounds();
- const int bucket_size_x = bounds.width() / kBucketCountForLocation;
- const int bucket_size_y = bounds.height() / kBucketCountForLocation;
+ const int bucket_size_x = std::max(1,
+ bounds.width() / kBucketCountForLocation);
+ const int bucket_size_y = std::max(1,
+ bounds.height() / kBucketCountForLocation);
gfx::Point position = event.root_location();