forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ozone: evdev: Add a device factory proxy that forwards to device thread
This is part of a series moving IO on evdev devices to a fast thread, since UI thread is too slow for the cursor. Make a new class InputDeviceFactoryProxyEvdev that wraps InputDeviceFactoryEvdev and can be safely passed to another thread. When the other thread calls to manipulate devices, we'll post to InputDeviceFactoryEvdev on the device thread with the command. BUG=449710 TEST=boot link_freon & move mouse Review URL: https://codereview.chromium.org/875513005 Cr-Commit-Position: refs/heads/master@{#313938}
- Loading branch information
Showing
10 changed files
with
214 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
ui/events/ozone/evdev/input_device_factory_evdev_proxy.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h" | ||
|
||
#include "base/bind.h" | ||
#include "base/thread_task_runner_handle.h" | ||
#include "ui/events/ozone/evdev/input_device_factory_evdev.h" | ||
|
||
namespace ui { | ||
|
||
namespace { | ||
|
||
void ForwardGetTouchDeviceStatusReply( | ||
scoped_refptr<base::SingleThreadTaskRunner> reply_runner, | ||
const GetTouchDeviceStatusReply& reply, | ||
scoped_ptr<std::string> status) { | ||
// Thread hop back to UI for reply. | ||
reply_runner->PostTask(FROM_HERE, base::Bind(reply, base::Passed(&status))); | ||
} | ||
|
||
} // namespace | ||
|
||
InputDeviceFactoryEvdevProxy::InputDeviceFactoryEvdevProxy( | ||
scoped_refptr<base::SingleThreadTaskRunner> task_runner, | ||
base::WeakPtr<InputDeviceFactoryEvdev> input_device_factory) | ||
: task_runner_(task_runner), input_device_factory_(input_device_factory) { | ||
} | ||
|
||
InputDeviceFactoryEvdevProxy::~InputDeviceFactoryEvdevProxy() { | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::AddInputDevice(int id, | ||
const base::FilePath& path) { | ||
task_runner_->PostTask(FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::AddInputDevice, | ||
input_device_factory_, id, path)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::RemoveInputDevice( | ||
const base::FilePath& path) { | ||
task_runner_->PostTask(FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::RemoveInputDevice, | ||
input_device_factory_, path)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::DisableInternalTouchpad() { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::DisableInternalTouchpad, | ||
input_device_factory_)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::EnableInternalTouchpad() { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::EnableInternalTouchpad, | ||
input_device_factory_)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::DisableInternalKeyboardExceptKeys( | ||
scoped_ptr<std::set<DomCode>> excepted_keys) { | ||
task_runner_->PostTask( | ||
FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::DisableInternalKeyboardExceptKeys, | ||
input_device_factory_, base::Passed(&excepted_keys))); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::EnableInternalKeyboard() { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::EnableInternalKeyboard, | ||
input_device_factory_)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetTouchpadSensitivity(int value) { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::SetTouchpadSensitivity, | ||
input_device_factory_, value)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetTapToClick(bool enabled) { | ||
task_runner_->PostTask(FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::SetTapToClick, | ||
input_device_factory_, enabled)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetThreeFingerClick(bool enabled) { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::SetThreeFingerClick, | ||
input_device_factory_, enabled)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetTapDragging(bool enabled) { | ||
task_runner_->PostTask(FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::SetTapDragging, | ||
input_device_factory_, enabled)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetNaturalScroll(bool enabled) { | ||
task_runner_->PostTask(FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::SetNaturalScroll, | ||
input_device_factory_, enabled)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetMouseSensitivity(int value) { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::SetMouseSensitivity, | ||
input_device_factory_, value)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::SetTapToClickPaused(bool state) { | ||
task_runner_->PostTask( | ||
FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::SetTapToClickPaused, | ||
input_device_factory_, state)); | ||
} | ||
|
||
void InputDeviceFactoryEvdevProxy::GetTouchDeviceStatus( | ||
const GetTouchDeviceStatusReply& reply) { | ||
task_runner_->PostTask( | ||
FROM_HERE, | ||
base::Bind(&InputDeviceFactoryEvdev::GetTouchDeviceStatus, | ||
input_device_factory_, | ||
base::Bind(&ForwardGetTouchDeviceStatusReply, | ||
base::ThreadTaskRunnerHandle::Get(), reply))); | ||
} | ||
|
||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_PROXY_EVDEV_H_ | ||
#define UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_PROXY_EVDEV_H_ | ||
|
||
#include <set> | ||
|
||
#include "base/compiler_specific.h" | ||
#include "base/files/file_path.h" | ||
#include "base/memory/ref_counted.h" | ||
#include "base/memory/weak_ptr.h" | ||
#include "base/single_thread_task_runner.h" | ||
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | ||
|
||
namespace ui { | ||
|
||
enum class DomCode; | ||
class InputDeviceFactoryEvdev; | ||
|
||
typedef base::Callback<void(scoped_ptr<std::string>)> GetTouchDeviceStatusReply; | ||
|
||
// Thread safe proxy for InputDeviceFactoryEvdev. | ||
class EVENTS_OZONE_EVDEV_EXPORT InputDeviceFactoryEvdevProxy { | ||
public: | ||
InputDeviceFactoryEvdevProxy( | ||
scoped_refptr<base::SingleThreadTaskRunner> task_runner, | ||
base::WeakPtr<InputDeviceFactoryEvdev> input_device_factory); | ||
~InputDeviceFactoryEvdevProxy(); | ||
|
||
// See InputDeviceFactoryEvdev for docs. These calls simply forward to | ||
// that object on another thread. | ||
void AddInputDevice(int id, const base::FilePath& path); | ||
void RemoveInputDevice(const base::FilePath& path); | ||
void DisableInternalTouchpad(); | ||
void EnableInternalTouchpad(); | ||
void DisableInternalKeyboardExceptKeys( | ||
scoped_ptr<std::set<DomCode>> excepted_keys); | ||
void EnableInternalKeyboard(); | ||
void SetTouchpadSensitivity(int value); | ||
void SetTapToClick(bool enabled); | ||
void SetThreeFingerClick(bool enabled); | ||
void SetTapDragging(bool enabled); | ||
void SetNaturalScroll(bool enabled); | ||
void SetMouseSensitivity(int value); | ||
void SetTapToClickPaused(bool state); | ||
void GetTouchDeviceStatus(const GetTouchDeviceStatusReply& reply); | ||
|
||
private: | ||
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | ||
base::WeakPtr<InputDeviceFactoryEvdev> input_device_factory_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(InputDeviceFactoryEvdevProxy); | ||
}; | ||
|
||
} // namespace ui | ||
|
||
#endif // UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_PROXY_EVDEV_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters