diff options
author | scottmg@google.com <scottmg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-03 22:47:01 +0000 |
---|---|---|
committer | scottmg@google.com <scottmg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-03 22:47:01 +0000 |
commit | 1541752786ab8a77f5ef1847ecb81e5c5df890ee (patch) | |
tree | ad76d5a4a48a145a386119e3b1629ee756d3b10a /content/renderer/gamepad_shared_memory_reader.cc | |
parent | d353541f29a517a93d1b0fec023f5d12a05eade2 (diff) | |
download | chromium_src-1541752786ab8a77f5ef1847ecb81e5c5df890ee.zip chromium_src-1541752786ab8a77f5ef1847ecb81e5c5df890ee.tar.gz chromium_src-1541752786ab8a77f5ef1847ecb81e5c5df890ee.tar.bz2 |
Make sure we get a valid handle from browser, add UMA stats to track
The crash being tracked is in SharedMemory::Map. Adding the check will allow for distinguishing between an invalid handle passed to Map, and Map failing for other reasons.
R=jam@chromium.org
BUG=126066
Review URL: https://chromiumcodereview.appspot.com/10302017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135233 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/gamepad_shared_memory_reader.cc')
-rw-r--r-- | content/renderer/gamepad_shared_memory_reader.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/content/renderer/gamepad_shared_memory_reader.cc b/content/renderer/gamepad_shared_memory_reader.cc index f4241e2..3025f99 100644 --- a/content/renderer/gamepad_shared_memory_reader.cc +++ b/content/renderer/gamepad_shared_memory_reader.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,6 +17,13 @@ GamepadSharedMemoryReader::GamepadSharedMemoryReader() { memset(ever_interacted_with_, 0, sizeof(ever_interacted_with_)); CHECK(RenderThread::Get()->Send(new GamepadHostMsg_StartPolling( &renderer_shared_memory_handle_))); + // If we don't get a valid handle from the browser, don't try to Map (we're + // probably out of memory or file handles). + bool valid_handle = base::SharedMemory::IsHandleValid( + renderer_shared_memory_handle_); + UMA_HISTOGRAM_BOOLEAN("Gamepad.ValidSharedMemoryHandle", valid_handle); + if (!valid_handle) + return; renderer_shared_memory_.reset( new base::SharedMemory(renderer_shared_memory_handle_, true)); CHECK(renderer_shared_memory_->Map(sizeof(GamepadHardwareBuffer))); @@ -30,6 +37,9 @@ void GamepadSharedMemoryReader::SampleGamepads(WebKit::WebGamepads& gamepads) { WebKit::WebGamepads read_into; TRACE_EVENT0("GAMEPAD", "SampleGamepads"); + if (!base::SharedMemory::IsHandleValid(renderer_shared_memory_handle_)) + return; + // Only try to read this many times before failing to avoid waiting here // very long in case of contention with the writer. TODO(scottmg) Tune this // number (as low as 1?) if histogram shows distribution as mostly @@ -44,7 +54,7 @@ void GamepadSharedMemoryReader::SampleGamepads(WebKit::WebGamepads& gamepads) { if (contention_count == kMaximumContentionCount) break; } while (gamepad_hardware_buffer_->sequence.ReadRetry(version)); - HISTOGRAM_COUNTS("Gamepad.ReadContentionCount", contention_count); + UMA_HISTOGRAM_COUNTS("Gamepad.ReadContentionCount", contention_count); if (contention_count >= kMaximumContentionCount) { // We failed to successfully read, presumably because the hardware |