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

Side by Side Diff: chrome/browser/chromeos/system/input_device_settings_impl_x11.cc

Issue 2871303004: Rename TaskRunner::RunsTasksOnCurrentThread() in //chrome (Closed)
Patch Set: fixed build error Created 3 years, 7 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 #include "chrome/browser/chromeos/system/input_device_settings.h" 5 #include "chrome/browser/chromeos/system/input_device_settings.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/process/kill.h" 17 #include "base/process/kill.h"
18 #include "base/process/launch.h" 18 #include "base/process/launch.h"
19 #include "base/process/process_handle.h" 19 #include "base/process/process_handle.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/sys_info.h" 22 #include "base/sys_info.h"
23 #include "base/task_runner.h" 23 #include "base/task_runner.h"
24 #include "base/threading/sequenced_worker_pool.h" 24 #include "base/threading/sequenced_worker_pool.h"
25 #include "base/threading/thread_restrictions.h"
25 #include "chrome/browser/chromeos/system/fake_input_device_settings.h" 26 #include "chrome/browser/chromeos/system/fake_input_device_settings.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "ui/events/base_event_utils.h" 28 #include "ui/events/base_event_utils.h"
28 #include "ui/events/devices/x11/device_data_manager_x11.h" 29 #include "ui/events/devices/x11/device_data_manager_x11.h"
29 #include "ui/events/devices/x11/device_list_cache_x11.h" 30 #include "ui/events/devices/x11/device_list_cache_x11.h"
30 #include "ui/events/devices/x11/touch_factory_x11.h" 31 #include "ui/events/devices/x11/touch_factory_x11.h"
31 #include "ui/gfx/x/x11_types.h" 32 #include "ui/gfx/x/x11_types.h"
32 33
33 namespace chromeos { 34 namespace chromeos {
34 namespace system { 35 namespace system {
35 36
36 namespace { 37 namespace {
37 38
38 InputDeviceSettings* g_instance = nullptr; 39 InputDeviceSettings* g_instance = nullptr;
39 40
40 const char kDeviceTypeTouchpad[] = "touchpad"; 41 const char kDeviceTypeTouchpad[] = "touchpad";
41 const char kDeviceTypeMouse[] = "mouse"; 42 const char kDeviceTypeMouse[] = "mouse";
42 const char kInputControl[] = "/opt/google/input/inputcontrol"; 43 const char kInputControl[] = "/opt/google/input/inputcontrol";
43 44
44 // The name of the xinput device corresponding to the internal touchpad. 45 // The name of the xinput device corresponding to the internal touchpad.
45 const char kInternalTouchpadName[] = "Elan Touchpad"; 46 const char kInternalTouchpadName[] = "Elan Touchpad";
46 47
47 typedef base::RefCountedData<bool> RefCountedBool; 48 typedef base::RefCountedData<bool> RefCountedBool;
48 49
49 bool ScriptExists(const std::string& script) { 50 bool ScriptExists(const std::string& script) {
50 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 51 base::ThreadRestrictions::AssertIOAllowed();
51 return base::PathExists(base::FilePath(script)); 52 return base::PathExists(base::FilePath(script));
52 } 53 }
53 54
54 // Executes the input control script asynchronously, if it exists. 55 // Executes the input control script asynchronously, if it exists.
55 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { 56 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) {
56 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 57 base::ThreadRestrictions::AssertIOAllowed();
57 DCHECK(!argv.empty()); 58 DCHECK(!argv.empty());
58 const std::string& script(argv[0]); 59 const std::string& script(argv[0]);
59 60
60 // Script must exist on device and is of correct format. 61 // Script must exist on device and is of correct format.
61 DCHECK(script.compare(kInputControl) == 0); 62 DCHECK(script.compare(kInputControl) == 0);
62 DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script)); 63 DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script));
63 64
64 if (!ScriptExists(script)) 65 if (!ScriptExists(script))
65 return; 66 return;
66 67
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 99 }
99 100
100 void AddTPControlArguments(const char* control, 101 void AddTPControlArguments(const char* control,
101 bool enabled, 102 bool enabled,
102 std::vector<std::string>* argv) { 103 std::vector<std::string>* argv) {
103 argv->push_back(base::StringPrintf("--%s=%d", control, enabled ? 1 : 0)); 104 argv->push_back(base::StringPrintf("--%s=%d", control, enabled ? 1 : 0));
104 } 105 }
105 106
106 void DeviceExistsBlockingPool(const char* device_type, 107 void DeviceExistsBlockingPool(const char* device_type,
107 scoped_refptr<RefCountedBool> exists) { 108 scoped_refptr<RefCountedBool> exists) {
108 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 109 base::ThreadRestrictions::AssertIOAllowed();
109 exists->data = false; 110 exists->data = false;
110 if (!ScriptExists(kInputControl)) 111 if (!ScriptExists(kInputControl))
111 return; 112 return;
112 113
113 std::vector<std::string> argv; 114 std::vector<std::string> argv;
114 argv.push_back(kInputControl); 115 argv.push_back(kInputControl);
115 argv.push_back(base::StringPrintf("--type=%s", device_type)); 116 argv.push_back(base::StringPrintf("--type=%s", device_type));
116 argv.push_back("--list"); 117 argv.push_back("--list");
117 std::string output; 118 std::string output;
118 // Output is empty if the device is not found. 119 // Output is empty if the device is not found.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (base::SysInfo::IsRunningOnChromeOS()) 353 if (base::SysInfo::IsRunningOnChromeOS())
353 g_instance = new InputDeviceSettingsImplX11; 354 g_instance = new InputDeviceSettingsImplX11;
354 else 355 else
355 g_instance = new FakeInputDeviceSettings; 356 g_instance = new FakeInputDeviceSettings;
356 } 357 }
357 return g_instance; 358 return g_instance;
358 } 359 }
359 360
360 } // namespace system 361 } // namespace system
361 } // namespace chromeos 362 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/power/freezer_cgroup_process_manager.cc ('k') | chrome/browser/conflicts/module_database_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698