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

Unified Diff: content/browser/gamepad/gamepad_provider.cc

Issue 133943002: Gamepad API support for chrome on android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/gamepad/gamepad_provider.cc
diff --git a/content/browser/gamepad/gamepad_provider.cc b/content/browser/gamepad/gamepad_provider.cc
index 55a5f30ed78b6802c7fd6231a13bd0d596c958c8..9c78407b5f935ba8d14de5c801af42da07e78a0f 100644
--- a/content/browser/gamepad/gamepad_provider.cc
+++ b/content/browser/gamepad/gamepad_provider.cc
@@ -1,4 +1,5 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,14 +13,19 @@
#include "base/message_loop/message_loop_proxy.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
+#include "base/time/time.h"
#include "content/browser/gamepad/gamepad_data_fetcher.h"
#include "content/browser/gamepad/gamepad_platform_data_fetcher.h"
#include "content/browser/gamepad/gamepad_provider.h"
+#include "content/browser/gamepad/gamepad_service.h"
#include "content/common/gamepad_hardware_buffer.h"
#include "content/common/gamepad_messages.h"
#include "content/common/gamepad_user_gesture.h"
namespace content {
+#if defined(OS_ANDROID)
+const int64 GamepadProvider::max_timestamp_before_pause_ = 500;
+#endif
GamepadProvider::ClosureAndThread::ClosureAndThread(
const base::Closure& c,
@@ -63,6 +69,12 @@ base::SharedMemoryHandle GamepadProvider::GetSharedMemoryHandleForProcess(
return renderer_handle;
}
+#if defined(OS_ANDROID)
+bool GamepadProvider::GetPollState() {
+ return is_paused_;
+}
+#endif
+
void GamepadProvider::Pause() {
{
base::AutoLock lock(is_paused_lock_);
@@ -167,6 +179,17 @@ void GamepadProvider::DoPoll() {
devices_changed_ = false;
}
+#if defined(OS_ANDROID)
+ base::TimeDelta timestamp =
+ (base::Time::NowFromSystemTime()) - (
+ GamepadService::GetInstance()->GetGamepadAccessTimestamp());
+
+ if (timestamp.InMilliseconds() > max_timestamp_before_pause_) {
+ Pause();
+ return;
+ }
+#endif
+
// Acquire the SeqLock. There is only ever one writer to this data.
// See gamepad_hardware_buffer.h.
hwbuf->sequence.WriteBegin();

Powered by Google App Engine
This is Rietveld 408576698