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

Side by Side Diff: chrome/browser/chromeos/device/input_service_proxy.h

Issue 2937253003: cros: Replace BrowserThread::FILE in InputServiceProxy (Closed)
Patch Set: for #2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
6 #define CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_ 6 #define CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
15 #include "base/task_runner.h" 16 #include "base/task_runner.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "device/hid/input_service_linux.h" 18 #include "device/hid/input_service_linux.h"
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 // Proxy to device::InputServiceLinux. Should be created and used on the UI 22 // Proxy to device::InputServiceLinux. Should be created and used on the UI
23 // thread. 23 // thread.
24 class InputServiceProxy { 24 class InputServiceProxy {
25 public: 25 public:
26 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; 26 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
27 27
(...skipping 12 matching lines...) Expand all
40 InputServiceProxy(); 40 InputServiceProxy();
41 ~InputServiceProxy(); 41 ~InputServiceProxy();
42 42
43 void AddObserver(Observer* observer); 43 void AddObserver(Observer* observer);
44 void RemoveObserver(Observer* observer); 44 void RemoveObserver(Observer* observer);
45 45
46 void GetDevices(const GetDevicesCallback& callback); 46 void GetDevices(const GetDevicesCallback& callback);
47 void GetDeviceInfo(const std::string& id, 47 void GetDeviceInfo(const std::string& id,
48 const GetDeviceInfoCallback& callback); 48 const GetDeviceInfoCallback& callback);
49 49
50 // Returns the TaskRunner for device::InputServiceLinux. Make it static so
51 // that all InputServiceProxy instances and code that needs access to
52 // device::InputServiceLinux uses the same TaskRunner.
53 static scoped_refptr<base::TaskRunner> GetInputServiceTaskRunner();
fdoray 2017/06/20 12:42:39 Since it's important for callers that tasks posted
xiyuan 2017/06/20 15:26:55 Done.
54
50 // Should be called once before any InputServiceProxy instance is created. 55 // Should be called once before any InputServiceProxy instance is created.
51 static void SetThreadIdForTesting(content::BrowserThread::ID thread_id); 56 static void SetUseUIThreadForTesting(bool use_ui_thread);
52 57
53 private: 58 private:
54 static content::BrowserThread::ID thread_identifier_;
55
56 class ServiceObserver; 59 class ServiceObserver;
57 60
58 void OnDeviceAdded(const device::InputServiceLinux::InputDeviceInfo& info); 61 void OnDeviceAdded(const device::InputServiceLinux::InputDeviceInfo& info);
59 void OnDeviceRemoved(const std::string& id); 62 void OnDeviceRemoved(const std::string& id);
60 63
61 base::ObserverList<Observer> observers_; 64 base::ObserverList<Observer> observers_;
62 std::unique_ptr<ServiceObserver> service_observer_; 65 std::unique_ptr<ServiceObserver> service_observer_;
63 66
64 base::ThreadChecker thread_checker_; 67 THREAD_CHECKER(thread_checker_);
65
66 scoped_refptr<base::TaskRunner> task_runner_;
67 68
68 base::WeakPtrFactory<InputServiceProxy> weak_factory_; 69 base::WeakPtrFactory<InputServiceProxy> weak_factory_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(InputServiceProxy); 71 DISALLOW_COPY_AND_ASSIGN(InputServiceProxy);
71 }; 72 };
72 73
73 } // namespace chromeos 74 } // namespace chromeos
74 75
75 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_ 76 #endif // CHROME_BROWSER_CHROMEOS_DEVICE_INPUT_SERVICE_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698