Chromium Code Reviews| Index: components/pairing/bluetooth_host_pairing_controller.cc |
| diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc |
| index 2968c879956b23c820e1cfc0371a6df287b0b186..d778a7ed7e5e188abc5bb71303c46c230fd6ada3 100644 |
| --- a/components/pairing/bluetooth_host_pairing_controller.cc |
| +++ b/components/pairing/bluetooth_host_pairing_controller.cc |
| @@ -8,8 +8,8 @@ |
| #include "base/hash.h" |
| #include "base/location.h" |
| #include "base/logging.h" |
| -#include "base/single_thread_task_runner.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/task_runner.h" |
| #include "base/task_runner_util.h" |
| #include "chromeos/system/devicetype.h" |
| #include "components/pairing/bluetooth_pairing_constants.h" |
| @@ -86,14 +86,9 @@ std::vector<BluetoothHostPairingController::InputDeviceInfo> GetDevices() { |
| } // namespace |
| BluetoothHostPairingController::BluetoothHostPairingController( |
| - const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) |
| - : current_stage_(STAGE_NONE), |
| - connectivity_status_(CONNECTIVITY_UNTESTED), |
| - update_status_(UPDATE_STATUS_UNKNOWN), |
| - enrollment_status_(ENROLLMENT_STATUS_UNKNOWN), |
| - proto_decoder_(new ProtoDecoder(this)), |
| - file_task_runner_(file_task_runner), |
| - ptr_factory_(this) {} |
| + const scoped_refptr<base::TaskRunner>& input_service_task_runner) |
| + : proto_decoder_(new ProtoDecoder(this)), |
|
achuithb
2017/06/20 08:36:48
Does base::MakeUnique not work here?
xiyuan
2017/06/20 15:26:55
Done.
|
| + input_service_task_runner_(input_service_task_runner) {} |
| BluetoothHostPairingController::~BluetoothHostPairingController() { |
| Reset(); |
| @@ -167,7 +162,7 @@ void BluetoothHostPairingController::Reset() { |
| void BluetoothHostPairingController::OnGetAdapter( |
| scoped_refptr<device::BluetoothAdapter> adapter) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| DCHECK(!adapter_.get()); |
| adapter_ = adapter; |
| @@ -180,7 +175,7 @@ void BluetoothHostPairingController::OnGetAdapter( |
| } |
| void BluetoothHostPairingController::SetPowered() { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| if (adapter_->IsPowered()) { |
| was_powered_ = true; |
| OnSetPowered(); |
| @@ -195,7 +190,7 @@ void BluetoothHostPairingController::SetPowered() { |
| } |
| void BluetoothHostPairingController::OnSetPowered() { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| adapter_->AddPairingDelegate( |
| this, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); |
| @@ -212,7 +207,7 @@ void BluetoothHostPairingController::OnSetPowered() { |
| void BluetoothHostPairingController::OnCreateService( |
| scoped_refptr<device::BluetoothSocket> socket) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| service_socket_ = socket; |
| service_socket_->Accept( |
| @@ -234,7 +229,7 @@ void BluetoothHostPairingController::OnAccept( |
| scoped_refptr<device::BluetoothSocket> socket) { |
| controller_device_address_ = device->GetAddress(); |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| adapter_->SetDiscoverable( |
| false, |
| base::Bind(&BluetoothHostPairingController::OnSetDiscoverable, |
| @@ -254,7 +249,7 @@ void BluetoothHostPairingController::OnAccept( |
| } |
| void BluetoothHostPairingController::OnSetDiscoverable(bool change_stage) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| if (change_stage) { |
| DCHECK_EQ(current_stage_, STAGE_NONE); |
| ChangeStage(STAGE_WAITING_FOR_CONTROLLER); |
| @@ -265,7 +260,7 @@ void BluetoothHostPairingController::OnSendComplete(int bytes_sent) {} |
| void BluetoothHostPairingController::OnReceiveComplete( |
| int bytes, scoped_refptr<net::IOBuffer> io_buffer) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| proto_decoder_->DecodeIOBuffer(bytes, io_buffer); |
| if (controller_socket_.get()) { |
| @@ -349,7 +344,7 @@ void BluetoothHostPairingController::OnForget() { |
| } |
| base::PostTaskAndReplyWithResult( |
| - file_task_runner_.get(), FROM_HERE, base::Bind(&GetDevices), |
| + input_service_task_runner_.get(), FROM_HERE, base::Bind(&GetDevices), |
| base::Bind(&BluetoothHostPairingController::PowerOffAdapterIfApplicable, |
| ptr_factory_.GetWeakPtr())); |
| } |
| @@ -386,7 +381,7 @@ void BluetoothHostPairingController::OnConfigureHostMessage( |
| void BluetoothHostPairingController::OnPairDevicesMessage( |
| const pairing_api::PairDevices& message) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| enrollment_domain_ = message.parameters().enrolling_domain(); |
| ChangeStage(STAGE_ENROLLING); |
| for (Observer& observer : observers_) |
| @@ -395,7 +390,7 @@ void BluetoothHostPairingController::OnPairDevicesMessage( |
| void BluetoothHostPairingController::OnCompleteSetupMessage( |
| const pairing_api::CompleteSetup& message) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| if (current_stage_ != STAGE_ENROLLMENT_SUCCESS) { |
| ChangeStage(STAGE_ENROLLMENT_ERROR); |
| } else { |
| @@ -412,14 +407,14 @@ void BluetoothHostPairingController::OnErrorMessage( |
| void BluetoothHostPairingController::OnRebootMessage( |
| const pairing_api::Reboot& message) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| for (Observer& observer : observers_) |
| observer.RebootHostRequested(); |
| } |
| void BluetoothHostPairingController::OnAddNetworkMessage( |
| const pairing_api::AddNetwork& message) { |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| for (Observer& observer : observers_) |
| observer.AddNetworkRequested(message.parameters().onc_spec()); |
| } |
| @@ -492,7 +487,7 @@ void BluetoothHostPairingController::OnUpdateStatusChanged( |
| void BluetoothHostPairingController::OnEnrollmentStatusChanged( |
| EnrollmentStatus enrollment_status) { |
| DCHECK_EQ(current_stage_, STAGE_ENROLLING); |
| - DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| enrollment_status_ = enrollment_status; |
| if (enrollment_status == ENROLLMENT_STATUS_SUCCESS) { |