| 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/device/input_service_proxy.h" | 5 #include "chrome/browser/chromeos/device/input_service_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/task_runner_util.h" | 8 #include "base/task_runner_util.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 InputDeviceInfo info; | 48 InputDeviceInfo info; |
| 49 info.id = id; | 49 info.id = id; |
| 50 if (InputServiceLinux::HasInstance()) | 50 if (InputServiceLinux::HasInstance()) |
| 51 success = InputServiceLinux::GetInstance()->GetDeviceInfo(id, &info); | 51 success = InputServiceLinux::GetInstance()->GetDeviceInfo(id, &info); |
| 52 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 53 BrowserThread::UI, FROM_HERE, base::Bind(callback, success, info)); | 53 BrowserThread::UI, FROM_HERE, base::Bind(callback, success, info)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // InputServiceLinux::Observer implementation: | 56 // InputServiceLinux::Observer implementation: |
| 57 virtual void OnInputDeviceAdded( | 57 virtual void OnInputDeviceAdded( |
| 58 const InputServiceLinux::InputDeviceInfo& info) OVERRIDE { | 58 const InputServiceLinux::InputDeviceInfo& info) override { |
| 59 DCHECK(CalledOnValidThread()); | 59 DCHECK(CalledOnValidThread()); |
| 60 BrowserThread::PostTask( | 60 BrowserThread::PostTask( |
| 61 BrowserThread::UI, | 61 BrowserThread::UI, |
| 62 FROM_HERE, | 62 FROM_HERE, |
| 63 base::Bind(&InputServiceProxy::OnDeviceAdded, proxy_, info)); | 63 base::Bind(&InputServiceProxy::OnDeviceAdded, proxy_, info)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void OnInputDeviceRemoved(const std::string& id) OVERRIDE { | 66 virtual void OnInputDeviceRemoved(const std::string& id) override { |
| 67 DCHECK(CalledOnValidThread()); | 67 DCHECK(CalledOnValidThread()); |
| 68 BrowserThread::PostTask( | 68 BrowserThread::PostTask( |
| 69 BrowserThread::UI, | 69 BrowserThread::UI, |
| 70 FROM_HERE, | 70 FROM_HERE, |
| 71 base::Bind(&InputServiceProxy::OnDeviceRemoved, proxy_, id)); | 71 base::Bind(&InputServiceProxy::OnDeviceRemoved, proxy_, id)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 bool CalledOnValidThread() const { | 75 bool CalledOnValidThread() const { |
| 76 return BrowserThread::CurrentlyOn(BrowserThread::FILE); | 76 return BrowserThread::CurrentlyOn(BrowserThread::FILE); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 DCHECK(thread_checker_.CalledOnValidThread()); | 148 DCHECK(thread_checker_.CalledOnValidThread()); |
| 149 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceAdded(info)); | 149 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceAdded(info)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void InputServiceProxy::OnDeviceRemoved(const std::string& id) { | 152 void InputServiceProxy::OnDeviceRemoved(const std::string& id) { |
| 153 DCHECK(thread_checker_.CalledOnValidThread()); | 153 DCHECK(thread_checker_.CalledOnValidThread()); |
| 154 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); | 154 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace chromeos | 157 } // namespace chromeos |
| OLD | NEW |