OLD | NEW |
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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 const std::string& script(argv[0]); | 49 const std::string& script(argv[0]); |
50 | 50 |
51 // Script must exist on device and is of correct format. | 51 // Script must exist on device and is of correct format. |
52 DCHECK(script.compare(kInputControl) == 0); | 52 DCHECK(script.compare(kInputControl) == 0); |
53 DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script)); | 53 DCHECK(!base::SysInfo::IsRunningOnChromeOS() || ScriptExists(script)); |
54 | 54 |
55 if (!ScriptExists(script)) | 55 if (!ScriptExists(script)) |
56 return; | 56 return; |
57 | 57 |
58 base::ProcessHandle handle; | 58 base::ProcessHandle handle; |
59 base::LaunchProcess(CommandLine(argv), base::LaunchOptions(), &handle); | 59 base::LaunchProcess(base::CommandLine(argv), base::LaunchOptions(), &handle); |
60 base::EnsureProcessGetsReaped(handle); | 60 base::EnsureProcessGetsReaped(handle); |
61 } | 61 } |
62 | 62 |
63 void ExecuteScript(const std::vector<std::string>& argv) { | 63 void ExecuteScript(const std::vector<std::string>& argv) { |
64 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 64 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
65 | 65 |
66 if (argv.size() == 1) | 66 if (argv.size() == 1) |
67 return; | 67 return; |
68 | 68 |
69 VLOG(1) << "About to launch: \"" << CommandLine(argv).GetCommandLineString() | 69 VLOG(1) << "About to launch: \"" |
70 << "\""; | 70 << base::CommandLine(argv).GetCommandLineString() << "\""; |
71 | 71 |
72 // Control scripts can take long enough to cause SIGART during shutdown | 72 // Control scripts can take long enough to cause SIGART during shutdown |
73 // (http://crbug.com/261426). Run the blocking pool task with | 73 // (http://crbug.com/261426). Run the blocking pool task with |
74 // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down. | 74 // CONTINUE_ON_SHUTDOWN so it won't be joined when Chrome shuts down. |
75 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); | 75 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
76 scoped_refptr<base::TaskRunner> runner = | 76 scoped_refptr<base::TaskRunner> runner = |
77 pool->GetTaskRunnerWithShutdownBehavior( | 77 pool->GetTaskRunnerWithShutdownBehavior( |
78 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 78 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
79 runner->PostTask(FROM_HERE, base::Bind(&ExecuteScriptOnFileThread, argv)); | 79 runner->PostTask(FROM_HERE, base::Bind(&ExecuteScriptOnFileThread, argv)); |
80 } | 80 } |
(...skipping 19 matching lines...) Expand all Loading... |
100 if (!ScriptExists(kInputControl)) | 100 if (!ScriptExists(kInputControl)) |
101 return; | 101 return; |
102 | 102 |
103 std::vector<std::string> argv; | 103 std::vector<std::string> argv; |
104 argv.push_back(kInputControl); | 104 argv.push_back(kInputControl); |
105 argv.push_back(base::StringPrintf("--type=%s", device_type)); | 105 argv.push_back(base::StringPrintf("--type=%s", device_type)); |
106 argv.push_back("--list"); | 106 argv.push_back("--list"); |
107 std::string output; | 107 std::string output; |
108 // Output is empty if the device is not found. | 108 // Output is empty if the device is not found. |
109 exists->data = | 109 exists->data = |
110 base::GetAppOutput(CommandLine(argv), &output) && !output.empty(); | 110 base::GetAppOutput(base::CommandLine(argv), &output) && !output.empty(); |
111 DVLOG(1) << "DeviceExistsBlockingPool:" << device_type << "=" << exists->data; | 111 DVLOG(1) << "DeviceExistsBlockingPool:" << device_type << "=" << exists->data; |
112 } | 112 } |
113 | 113 |
114 void RunCallbackUIThread( | 114 void RunCallbackUIThread( |
115 scoped_refptr<RefCountedBool> exists, | 115 scoped_refptr<RefCountedBool> exists, |
116 const InputDeviceSettings::DeviceExistsCallback& callback) { | 116 const InputDeviceSettings::DeviceExistsCallback& callback) { |
117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
118 DVLOG(1) << "RunCallbackUIThread " << exists->data; | 118 DVLOG(1) << "RunCallbackUIThread " << exists->data; |
119 callback.Run(exists->data); | 119 callback.Run(exists->data); |
120 } | 120 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 void InputDeviceSettings::SetSettingsForTesting( | 314 void InputDeviceSettings::SetSettingsForTesting( |
315 InputDeviceSettings* test_settings) { | 315 InputDeviceSettings* test_settings) { |
316 if (g_test_instance == test_settings) | 316 if (g_test_instance == test_settings) |
317 return; | 317 return; |
318 delete g_test_instance; | 318 delete g_test_instance; |
319 g_test_instance = test_settings; | 319 g_test_instance = test_settings; |
320 } | 320 } |
321 | 321 |
322 } // namespace system | 322 } // namespace system |
323 } // namespace chromeos | 323 } // namespace chromeos |
OLD | NEW |