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

Side by Side Diff: components/exo/gamepad.h

Issue 2076013002: exo: Implement wayland gamepad support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serv
Patch Set: moved polling thread resources into separate class. pass task_runner into Gamepad. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_EXO_GAMEPAD_H_
6 #define COMPONENTS_EXO_GAMEPAD_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/sequenced_task_runner.h"
13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread.h"
15 #include "base/threading/thread_task_runner_handle.h"
16 #include "device/gamepad/gamepad_data_fetcher.h"
17 #include "ui/aura/client/focus_change_observer.h"
18
19 namespace exo {
20 class GamepadDelegate;
21
22 typedef base::Callback<std::unique_ptr<device::GamepadDataFetcher>()>
reveman 2016/07/11 10:50:44 nit: using CreateGamepadDataFetcherCallback = base
denniskempin 2016/07/11 17:43:28 Done.
23 GamepadDataFetcherFactory;
24
25 // This class represents one or more gamepads, it implements a background thread
26 // for polling gamepad devices and notifies the GamepadDelegate of any
27 // changes.
28 class Gamepad : public aura::client::FocusChangeObserver {
29 public:
30 // This class will post tasks to invoke the delegate on the thread runner
31 // which is associated with the thread that is creating this instance.
32 Gamepad(GamepadDelegate* delegate,
33 scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner);
reveman 2016/07/11 10:50:44 nit: this will result in unnecessary ref-count chu
denniskempin 2016/07/11 17:43:28 Done.
34 // Allows test cases to specify a GamepadDataFetcherFactory that overrides
35 // the default PlatformGamepadDataFetcher.
36 Gamepad(GamepadDelegate* delegate,
37 scoped_refptr<base::SingleThreadTaskRunner> polling_task_runner,
reveman 2016/07/11 10:50:44 nit: "base::SingleThreadTaskRunner* polling_task_r
denniskempin 2016/07/11 17:43:28 Done.
38 GamepadDataFetcherFactory fetcher_factory);
39 ~Gamepad() override;
40
41 // Overridden aura::client::FocusChangeObserver:
42 void OnWindowFocused(aura::Window* gained_focus,
43 aura::Window* lost_focus) override;
44
45 private:
46 // Private implementation of methods and resources that are used on the
47 // polling thread.
48 class PollingThreadResources;
49 scoped_refptr<PollingThreadResources> polling_thread_resources_;
reveman 2016/07/11 10:50:44 nit: member variables below types and functions
denniskempin 2016/07/11 17:43:28 Done.
50
51 // Posts updates of gamepad data to delegate. Can only be called on the
52 // origin thread.
53 void PostGamepadChanges(const blink::WebGamepad new_pad);
reveman 2016/07/11 10:50:44 nit: "Handle" or "Process" instead of "Post" as po
denniskempin 2016/07/11 17:43:28 Done.
54
55 // Method implementing the default GamepadDataFetcherFactory, returning
56 // ownership of an instance of GamepadPlatformDataFetcher.
57 static std::unique_ptr<device::GamepadDataFetcher>
58 GamepadPlatformDataFetcherFactory();
reveman 2016/07/11 10:50:44 nit: either move this into anonymouse namespace in
denniskempin 2016/07/11 17:43:28 Done.
59
60 // The delegate instance that all events are dispatched to.
61 GamepadDelegate* const delegate_;
62
63 // The current state of the gamepad represented by this instance.
64 blink::WebGamepad pad_state_;
65
66 // ThreadChecker for the origin thread.
67 base::ThreadChecker thread_checker_;
68
69 base::WeakPtrFactory<Gamepad> weak_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(Gamepad);
72 };
73
74 } // namespace exo
75
76 #endif // COMPONENTS_EXO_GAMEPAD_H_
OLDNEW
« no previous file with comments | « components/exo/DEPS ('k') | components/exo/gamepad.cc » ('j') | components/exo/gamepad.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698