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

Unified Diff: chrome/browser/chromeos/device/input_service_proxy.cc

Issue 913773002: Created fakes for HID-detection screen testing. Initial browsertest added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TaskRunner used for InputServiceProxy. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/device/input_service_proxy.cc
diff --git a/chrome/browser/chromeos/device/input_service_proxy.cc b/chrome/browser/chromeos/device/input_service_proxy.cc
index 861ef6c94a7fcb713db63cb735e336f166e36925..3d27ab1498f03ca82f21c01861aef041fdf5387f 100644
--- a/chrome/browser/chromeos/device/input_service_proxy.cc
+++ b/chrome/browser/chromeos/device/input_service_proxy.cc
@@ -15,6 +15,9 @@ typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
namespace chromeos {
+// static
+BrowserThread::ID InputServiceProxy::thread_identifier_ = BrowserThread::FILE;
+
class InputServiceProxy::ServiceObserver : public InputServiceLinux::Observer {
public:
ServiceObserver() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); }
@@ -73,7 +76,7 @@ class InputServiceProxy::ServiceObserver : public InputServiceLinux::Observer {
private:
bool CalledOnValidThread() const {
- return BrowserThread::CurrentlyOn(BrowserThread::FILE);
+ return BrowserThread::CurrentlyOn(InputServiceProxy::thread_identifier_);
}
base::WeakPtr<InputServiceProxy> proxy_;
@@ -82,10 +85,12 @@ class InputServiceProxy::ServiceObserver : public InputServiceLinux::Observer {
};
InputServiceProxy::InputServiceProxy()
- : service_observer_(new ServiceObserver()), weak_factory_(this) {
+ : service_observer_(new ServiceObserver()),
+ task_runner_(BrowserThread::GetMessageLoopProxyForThread(
+ thread_identifier_)),
+ weak_factory_(this) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserThread::PostTask(
- BrowserThread::FILE,
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&InputServiceProxy::ServiceObserver::Initialize,
base::Unretained(service_observer_.get()),
@@ -94,8 +99,7 @@ InputServiceProxy::InputServiceProxy()
InputServiceProxy::~InputServiceProxy() {
DCHECK(thread_checker_.CalledOnValidThread());
- BrowserThread::PostTask(
- BrowserThread::FILE,
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&InputServiceProxy::ServiceObserver::Shutdown,
base::Unretained(service_observer_.release())));
@@ -104,7 +108,7 @@ InputServiceProxy::~InputServiceProxy() {
// static
void InputServiceProxy::WarmUp() {
content::BrowserThread::PostTask(
- content::BrowserThread::FILE,
+ thread_identifier_,
FROM_HERE,
base::Bind(base::IgnoreResult(&InputServiceLinux::GetInstance)));
}
@@ -123,8 +127,8 @@ void InputServiceProxy::RemoveObserver(Observer* observer) {
void InputServiceProxy::GetDevices(const GetDevicesCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::FILE,
+ base::PostTaskAndReplyWithResult(
+ task_runner_.get(),
FROM_HERE,
base::Bind(&InputServiceProxy::ServiceObserver::GetDevices,
base::Unretained(service_observer_.get())),
@@ -134,8 +138,7 @@ void InputServiceProxy::GetDevices(const GetDevicesCallback& callback) {
void InputServiceProxy::GetDeviceInfo(const std::string& id,
const GetDeviceInfoCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- BrowserThread::PostTask(
- BrowserThread::FILE,
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&InputServiceProxy::ServiceObserver::GetDeviceInfo,
base::Unretained(service_observer_.release()),
@@ -143,6 +146,11 @@ void InputServiceProxy::GetDeviceInfo(const std::string& id,
callback));
}
+// static
+void InputServiceProxy::SetThreadIdForTesting(BrowserThread::ID thread_id) {
+ InputServiceProxy::thread_identifier_ = thread_id;
+}
+
void InputServiceProxy::OnDeviceAdded(
const InputServiceLinux::InputDeviceInfo& info) {
DCHECK(thread_checker_.CalledOnValidThread());
« no previous file with comments | « chrome/browser/chromeos/device/input_service_proxy.h ('k') | chrome/browser/chromeos/login/hid_detection_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698