| Index: components/exo/gaming_seat_joydev.cc
|
| diff --git a/components/exo/gaming_seat.cc b/components/exo/gaming_seat_joydev.cc
|
| similarity index 85%
|
| copy from components/exo/gaming_seat.cc
|
| copy to components/exo/gaming_seat_joydev.cc
|
| index 016be145bb90f467d7c47fe6376c15ef15f3cce4..23cec92dbdb9b1f6ac76e12013dce62b7648b9a4 100644
|
| --- a/components/exo/gaming_seat.cc
|
| +++ b/components/exo/gaming_seat_joydev.cc
|
| @@ -2,15 +2,11 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "components/exo/gaming_seat.h"
|
| +#include "components/exo/gaming_seat_joydev.h"
|
|
|
| #include <cmath>
|
|
|
| #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"
|
| @@ -39,15 +35,15 @@ constexpr unsigned kPollingTimeIntervalMs = 16;
|
| } // namespace
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// GamingSeat::ThreadSafeGamepadChangeFetcher
|
| +// GamingSeatJoydev::ThreadSafeGamepadChangeFetcher
|
|
|
| // Implements all methods and resources running on the polling thread.
|
| // This class is reference counted to allow it to shut down safely on the
|
| // polling thread even if the Gamepad has been destroyed on the origin thread.
|
| -class GamingSeat::ThreadSafeGamepadChangeFetcher
|
| +class GamingSeatJoydev::ThreadSafeGamepadChangeFetcher
|
| : public device::GamepadPadStateProvider,
|
| public base::RefCountedThreadSafe<
|
| - GamingSeat::ThreadSafeGamepadChangeFetcher> {
|
| + GamingSeatJoydev::ThreadSafeGamepadChangeFetcher> {
|
| public:
|
| using ProcessGamepadChangesCallback =
|
| base::Callback<void(int index, const device::Gamepad)>;
|
| @@ -60,7 +56,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 +75,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 +92,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 +108,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,28 +176,30 @@ 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);
|
| };
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// GamingSeat, public:
|
| -
|
| -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)
|
| +// GamingSeatJoydev, public:
|
| +
|
| +GamingSeatJoydev::GamingSeatJoydev(
|
| + GamingSeatDelegate* gaming_seat_delegate,
|
| + base::SingleThreadTaskRunner* polling_task_runner)
|
| + : GamingSeatJoydev(gaming_seat_delegate,
|
| + polling_task_runner,
|
| + base::Bind(CreateGamepadPlatformDataFetcher)) {}
|
| +
|
| +GamingSeatJoydev::GamingSeatJoydev(
|
| + 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,
|
| + base::Bind(&GamingSeatJoydev::ProcessGamepadChanges,
|
| weak_ptr_factory_.GetWeakPtr()),
|
| create_fetcher_callback, polling_task_runner);
|
|
|
| @@ -210,7 +208,7 @@ GamingSeat::GamingSeat(GamingSeatDelegate* gaming_seat_delegate,
|
| OnWindowFocused(helper->GetFocusedWindow(), nullptr);
|
| }
|
|
|
| -GamingSeat::~GamingSeat() {
|
| +GamingSeatJoydev::~GamingSeatJoydev() {
|
| // Disable polling. Since ThreadSafeGamepadChangeFetcher are reference
|
| // counted, we can safely have it shut down after Gamepad has been destroyed.
|
| gamepad_change_fetcher_->EnablePolling(false);
|
| @@ -227,9 +225,9 @@ GamingSeat::~GamingSeat() {
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // aura::client::FocusChangeObserver overrides:
|
|
|
| -void GamingSeat::OnWindowFocused(aura::Window* gained_focus,
|
| - aura::Window* lost_focus) {
|
| - DCHECK(thread_checker_.CalledOnValidThread());
|
| +void GamingSeatJoydev::OnWindowFocused(aura::Window* gained_focus,
|
| + aura::Window* lost_focus) {
|
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
| Surface* target = nullptr;
|
| if (gained_focus) {
|
| target = Surface::AsSurface(gained_focus);
|
| @@ -246,11 +244,11 @@ void GamingSeat::OnWindowFocused(aura::Window* gained_focus,
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// GamingSeat, private:
|
| +// GamingSeatJoydev, private:
|
|
|
| -void GamingSeat::ProcessGamepadChanges(int index,
|
| - const device::Gamepad new_pad) {
|
| - DCHECK(thread_checker_.CalledOnValidThread());
|
| +void GamingSeatJoydev::ProcessGamepadChanges(int index,
|
| + const device::Gamepad new_pad) {
|
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
| bool send_frame = false;
|
|
|
| device::Gamepad& pad_state = pad_state_.items[index];
|
|
|