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()); |