| 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 "ui/base/ime/chromeos/ime_keyboard_x11.h" | 5 #include "ui/base/ime/chromeos/ime_keyboard_x11.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <X11/XKBlib.h> | 8 #include <X11/XKBlib.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 | 10 |
| 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
| 12 | 15 |
| 13 namespace chromeos { | 16 namespace chromeos { |
| 14 namespace input_method { | 17 namespace input_method { |
| 15 namespace { | 18 namespace { |
| 16 | 19 |
| 17 // The delay in milliseconds that we'll wait between checking if | 20 // The delay in milliseconds that we'll wait between checking if |
| 18 // setxkbmap command finished. | 21 // setxkbmap command finished. |
| 19 const int kSetLayoutCommandCheckDelayMs = 100; | 22 const int kSetLayoutCommandCheckDelayMs = 100; |
| 20 | 23 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 << ": pid=" << process.Pid(); | 179 << ": pid=" << process.Pid(); |
| 177 } | 180 } |
| 178 | 181 |
| 179 // Delay and loop until child process finishes and call the callback. | 182 // Delay and loop until child process finishes and call the callback. |
| 180 void ImeKeyboardX11::PollUntilChildFinish(const base::ProcessHandle handle) { | 183 void ImeKeyboardX11::PollUntilChildFinish(const base::ProcessHandle handle) { |
| 181 int exit_code; | 184 int exit_code; |
| 182 DVLOG(1) << "PollUntilChildFinish: poll for pid=" << base::GetProcId(handle); | 185 DVLOG(1) << "PollUntilChildFinish: poll for pid=" << base::GetProcId(handle); |
| 183 switch (base::GetTerminationStatus(handle, &exit_code)) { | 186 switch (base::GetTerminationStatus(handle, &exit_code)) { |
| 184 case base::TERMINATION_STATUS_STILL_RUNNING: | 187 case base::TERMINATION_STATUS_STILL_RUNNING: |
| 185 DVLOG(1) << "PollUntilChildFinish: Try waiting again"; | 188 DVLOG(1) << "PollUntilChildFinish: Try waiting again"; |
| 186 base::MessageLoop::current()->PostDelayedTask( | 189 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 187 FROM_HERE, | 190 FROM_HERE, base::Bind(&ImeKeyboardX11::PollUntilChildFinish, |
| 188 base::Bind(&ImeKeyboardX11::PollUntilChildFinish, | 191 weak_factory_.GetWeakPtr(), handle), |
| 189 weak_factory_.GetWeakPtr(), | |
| 190 handle), | |
| 191 base::TimeDelta::FromMilliseconds(kSetLayoutCommandCheckDelayMs)); | 192 base::TimeDelta::FromMilliseconds(kSetLayoutCommandCheckDelayMs)); |
| 192 return; | 193 return; |
| 193 | 194 |
| 194 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 195 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
| 195 DVLOG(1) << "PollUntilChildFinish: Child process finished"; | 196 DVLOG(1) << "PollUntilChildFinish: Child process finished"; |
| 196 OnSetLayoutFinish(); | 197 OnSetLayoutFinish(); |
| 197 return; | 198 return; |
| 198 | 199 |
| 199 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 200 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 200 DVLOG(1) << "PollUntilChildFinish: Abnormal exit code: " << exit_code; | 201 DVLOG(1) << "PollUntilChildFinish: Abnormal exit code: " << exit_code; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 return CheckLayoutName(layout_name); | 297 return CheckLayoutName(layout_name); |
| 297 } | 298 } |
| 298 | 299 |
| 299 // static | 300 // static |
| 300 ImeKeyboard* ImeKeyboard::Create() { | 301 ImeKeyboard* ImeKeyboard::Create() { |
| 301 return new ImeKeyboardX11(); | 302 return new ImeKeyboardX11(); |
| 302 } | 303 } |
| 303 | 304 |
| 304 } // namespace input_method | 305 } // namespace input_method |
| 305 } // namespace chromeos | 306 } // namespace chromeos |
| OLD | NEW |