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

Unified Diff: components/exo/gaming_seat.cc

Issue 2900773003: Allow gaming_seat to use ozone gamepad as back-end (Closed)
Patch Set: Add gaming_seat_ozone to exo Created 3 years, 6 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: components/exo/gaming_seat.cc
diff --git a/components/exo/gaming_seat.cc b/components/exo/gaming_seat.cc
index 016be145bb90f467d7c47fe6376c15ef15f3cce4..1a03c9efa20583f2cc6463dd3c3fecdd4cacb848 100644
--- a/components/exo/gaming_seat.cc
+++ b/components/exo/gaming_seat.cc
@@ -5,12 +5,7 @@
#include "components/exo/gaming_seat.h"
#include <cmath>
-
reveman 2017/06/08 00:21:44 nit: keep this blank line
#include "base/bind.h"
-#include "base/location.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "components/exo/gamepad_delegate.h"
#include "components/exo/gaming_seat_delegate.h"
#include "components/exo/shell_surface.h"
@@ -60,7 +55,7 @@ class GamingSeat::ThreadSafeGamepadChangeFetcher
create_fetcher_callback_(create_fetcher_callback),
polling_task_runner_(task_runner),
origin_task_runner_(base::ThreadTaskRunnerHandle::Get()) {
- thread_checker_.DetachFromThread();
+ DETACH_FROM_THREAD(thread_checker_);
}
// Enable or disable gamepad polling. Can be called from any thread.
@@ -79,7 +74,7 @@ class GamingSeat::ThreadSafeGamepadChangeFetcher
// Enables or disables polling.
void EnablePollingOnPollingThread(bool enabled) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
is_enabled_ = enabled;
if (is_enabled_) {
@@ -96,7 +91,7 @@ class GamingSeat::ThreadSafeGamepadChangeFetcher
// Schedules the next poll on the polling thread.
void SchedulePollOnPollingThread() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(fetcher_);
if (!is_enabled_ || has_poll_scheduled_)
@@ -112,7 +107,7 @@ class GamingSeat::ThreadSafeGamepadChangeFetcher
// Polls devices for new data and posts gamepad changes back to origin thread.
void PollOnPollingThread() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
has_poll_scheduled_ = false;
if (!is_enabled_)
@@ -180,7 +175,7 @@ class GamingSeat::ThreadSafeGamepadChangeFetcher
bool is_enabled_ = false;
// ThreadChecker for the polling thread.
- base::ThreadChecker thread_checker_;
+ THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(ThreadSafeGamepadChangeFetcher);
};
@@ -190,20 +185,13 @@ class GamingSeat::ThreadSafeGamepadChangeFetcher
GamingSeat::GamingSeat(GamingSeatDelegate* gaming_seat_delegate,
base::SingleThreadTaskRunner* polling_task_runner)
- : GamingSeat(gaming_seat_delegate,
- polling_task_runner,
- base::Bind(CreateGamepadPlatformDataFetcher)) {}
-
-GamingSeat::GamingSeat(GamingSeatDelegate* gaming_seat_delegate,
- base::SingleThreadTaskRunner* polling_task_runner,
- CreateGamepadDataFetcherCallback create_fetcher_callback)
: delegate_(gaming_seat_delegate),
gamepad_delegates_{nullptr},
weak_ptr_factory_(this) {
gamepad_change_fetcher_ = new ThreadSafeGamepadChangeFetcher(
base::Bind(&GamingSeat::ProcessGamepadChanges,
weak_ptr_factory_.GetWeakPtr()),
- create_fetcher_callback, polling_task_runner);
+ base::Bind(CreateGamepadPlatformDataFetcher), polling_task_runner);
auto* helper = WMHelper::GetInstance();
helper->AddFocusObserver(this);
@@ -229,7 +217,7 @@ GamingSeat::~GamingSeat() {
void GamingSeat::OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
Surface* target = nullptr;
if (gained_focus) {
target = Surface::AsSurface(gained_focus);
@@ -250,7 +238,7 @@ void GamingSeat::OnWindowFocused(aura::Window* gained_focus,
void GamingSeat::ProcessGamepadChanges(int index,
const device::Gamepad new_pad) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
bool send_frame = false;
device::Gamepad& pad_state = pad_state_.items[index];

Powered by Google App Engine
This is Rietveld 408576698