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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return BrowserThread::CurrentlyOn(InputServiceProxy::thread_identifier_); | 80 return BrowserThread::CurrentlyOn(InputServiceProxy::thread_identifier_); |
81 } | 81 } |
82 | 82 |
83 base::WeakPtr<InputServiceProxy> proxy_; | 83 base::WeakPtr<InputServiceProxy> proxy_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(ServiceObserver); | 85 DISALLOW_COPY_AND_ASSIGN(ServiceObserver); |
86 }; | 86 }; |
87 | 87 |
88 InputServiceProxy::InputServiceProxy() | 88 InputServiceProxy::InputServiceProxy() |
89 : service_observer_(new ServiceObserver()), | 89 : service_observer_(new ServiceObserver()), |
90 task_runner_(BrowserThread::GetMessageLoopProxyForThread( | 90 task_runner_(BrowserThread::GetTaskRunnerForThread(thread_identifier_)), |
91 thread_identifier_)), | |
92 weak_factory_(this) { | 91 weak_factory_(this) { |
93 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 92 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
94 task_runner_->PostTask( | 93 task_runner_->PostTask( |
95 FROM_HERE, | 94 FROM_HERE, |
96 base::Bind(&InputServiceProxy::ServiceObserver::Initialize, | 95 base::Bind(&InputServiceProxy::ServiceObserver::Initialize, |
97 base::Unretained(service_observer_.get()), | 96 base::Unretained(service_observer_.get()), |
98 weak_factory_.GetWeakPtr())); | 97 weak_factory_.GetWeakPtr())); |
99 } | 98 } |
100 | 99 |
101 InputServiceProxy::~InputServiceProxy() { | 100 InputServiceProxy::~InputServiceProxy() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 DCHECK(thread_checker_.CalledOnValidThread()); | 148 DCHECK(thread_checker_.CalledOnValidThread()); |
150 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceAdded(info)); | 149 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceAdded(info)); |
151 } | 150 } |
152 | 151 |
153 void InputServiceProxy::OnDeviceRemoved(const std::string& id) { | 152 void InputServiceProxy::OnDeviceRemoved(const std::string& id) { |
154 DCHECK(thread_checker_.CalledOnValidThread()); | 153 DCHECK(thread_checker_.CalledOnValidThread()); |
155 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); | 154 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); |
156 } | 155 } |
157 | 156 |
158 } // namespace chromeos | 157 } // namespace chromeos |
OLD | NEW |