Commit d9fcb787 authored by fdoray's avatar fdoray Committed by Commit bot

Remove use of deprecated MessageLoop methods in device.

MessageLoop::PostTask/PostDelayedTask/DeleteSoon/ReleaseSoon
are deprecated. This CL makes the following replacements to
remove some uses of these methods:

"MessageLoop(ForUI|ForIO)::current()->PostTask" ->
  "ThreadTaskRunnerHandle::Get()->PostTask"
"MessageLoop(ForUI|ForIO)::current()->PostDelayedTask" ->
  "ThreadTaskRunnerHandle::Get()->PostDelayedTask"
"MessageLoop(ForUI|ForIO)::current()->DeleteSoon" ->
  "ThreadTaskRunnerHandle::Get()->DeleteSoon"
"MessageLoop(ForUI|ForIO)::current()->ReleaseSoon" ->
  "ThreadTaskRunnerHandle::Get()->ReleaseSoon"

In files where these replacements are made, it adds these includes:
  #include "base/location.h"
  #include "base/single_thread_task_runner.h"
  #include "base/threading/thread_task_runner_handle.h"

And removes this include if it is no longer required:
  #include "base/message_loop/message_loop.h"

Why ThreadTaskRunnerHandle::Get() instead of
MessageLoop::current()->task_runner()?
 - The two are equivalent on threads that run a MessageLoop.
 - MessageLoop::current() doesn't work in base/task_scheduler
   because the scheduler's thread don't run MessageLoops.
   This CL will therefore facilitate the migration of browser
   threads to base/task_scheduler.

Steps to generate this patch:
1. Run message_loop_cleanup.py (see code on the bug).
2. Run tools/sort-headers.py on modified files.
3. Run git cl format.

BUG=616447
R=reillyg@chromium.org

Review-Url: https://codereview.chromium.org/2031743005
Cr-Commit-Position: refs/heads/master@{#398123}
parent 69f2cc12
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#include "base/android/jni_array.h" #include "base/android/jni_array.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "device/bluetooth/bluetooth_adapter_android.h" #include "device/bluetooth/bluetooth_adapter_android.h"
#include "device/bluetooth/bluetooth_gatt_notify_session_android.h" #include "device/bluetooth/bluetooth_gatt_notify_session_android.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor_android.h" #include "device/bluetooth/bluetooth_remote_gatt_descriptor_android.h"
...@@ -140,7 +142,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession( ...@@ -140,7 +142,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
if (!hasNotify && !hasIndicate) { if (!hasNotify && !hasIndicate) {
LOG(ERROR) << "Characteristic needs NOTIFY or INDICATE"; LOG(ERROR) << "Characteristic needs NOTIFY or INDICATE";
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED)); BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED));
...@@ -154,7 +156,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession( ...@@ -154,7 +156,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
if (ccc_descriptor.size() != 1u) { if (ccc_descriptor.size() != 1u) {
LOG(ERROR) << "Found " << ccc_descriptor.size() LOG(ERROR) << "Found " << ccc_descriptor.size()
<< " client characteristic configuration descriptors."; << " client characteristic configuration descriptors.";
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
(ccc_descriptor.size() == 0) (ccc_descriptor.size() == 0)
...@@ -166,7 +168,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession( ...@@ -166,7 +168,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
if (!Java_ChromeBluetoothRemoteGattCharacteristic_setCharacteristicNotification( if (!Java_ChromeBluetoothRemoteGattCharacteristic_setCharacteristicNotification(
AttachCurrentThread(), j_characteristic_.obj(), true)) { AttachCurrentThread(), j_characteristic_.obj(), true)) {
LOG(ERROR) << "Error enabling characteristic notification"; LOG(ERROR) << "Error enabling characteristic notification";
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(error_callback, FROM_HERE, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_FAILED)); BluetoothRemoteGattService::GATT_ERROR_FAILED));
return; return;
...@@ -190,7 +192,7 @@ void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic( ...@@ -190,7 +192,7 @@ void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic(
const ValueCallback& callback, const ValueCallback& callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
if (read_pending_ || write_pending_) { if (read_pending_ || write_pending_) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
...@@ -199,7 +201,7 @@ void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic( ...@@ -199,7 +201,7 @@ void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic(
if (!Java_ChromeBluetoothRemoteGattCharacteristic_readRemoteCharacteristic( if (!Java_ChromeBluetoothRemoteGattCharacteristic_readRemoteCharacteristic(
AttachCurrentThread(), j_characteristic_.obj())) { AttachCurrentThread(), j_characteristic_.obj())) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(error_callback, FROM_HERE, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_FAILED)); BluetoothRemoteGattService::GATT_ERROR_FAILED));
return; return;
...@@ -215,7 +217,7 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( ...@@ -215,7 +217,7 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic(
const base::Closure& callback, const base::Closure& callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
if (read_pending_ || write_pending_) { if (read_pending_ || write_pending_) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
...@@ -226,7 +228,7 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic( ...@@ -226,7 +228,7 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic(
if (!Java_ChromeBluetoothRemoteGattCharacteristic_writeRemoteCharacteristic( if (!Java_ChromeBluetoothRemoteGattCharacteristic_writeRemoteCharacteristic(
env, j_characteristic_.obj(), env, j_characteristic_.obj(),
base::android::ToJavaByteArray(env, new_value).obj())) { base::android::ToJavaByteArray(env, new_value).obj())) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(error_callback, FROM_HERE, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_FAILED)); BluetoothRemoteGattService::GATT_ERROR_FAILED));
return; return;
......
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#include "base/android/jni_array.h" #include "base/android/jni_array.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_loop.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "device/bluetooth/bluetooth_gatt_notify_session_android.h" #include "device/bluetooth/bluetooth_gatt_notify_session_android.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_android.h" #include "device/bluetooth/bluetooth_remote_gatt_service_android.h"
#include "jni/ChromeBluetoothRemoteGattDescriptor_jni.h" #include "jni/ChromeBluetoothRemoteGattDescriptor_jni.h"
...@@ -86,7 +88,7 @@ void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor( ...@@ -86,7 +88,7 @@ void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor(
const ValueCallback& callback, const ValueCallback& callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
if (read_pending_ || write_pending_) { if (read_pending_ || write_pending_) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
...@@ -95,7 +97,7 @@ void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor( ...@@ -95,7 +97,7 @@ void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor(
if (!Java_ChromeBluetoothRemoteGattDescriptor_readRemoteDescriptor( if (!Java_ChromeBluetoothRemoteGattDescriptor_readRemoteDescriptor(
AttachCurrentThread(), j_descriptor_.obj())) { AttachCurrentThread(), j_descriptor_.obj())) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
...@@ -112,7 +114,7 @@ void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor( ...@@ -112,7 +114,7 @@ void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor(
const base::Closure& callback, const base::Closure& callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
if (read_pending_ || write_pending_) { if (read_pending_ || write_pending_) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS)); BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS));
...@@ -123,7 +125,7 @@ void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor( ...@@ -123,7 +125,7 @@ void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor(
if (!Java_ChromeBluetoothRemoteGattDescriptor_writeRemoteDescriptor( if (!Java_ChromeBluetoothRemoteGattDescriptor_writeRemoteDescriptor(
env, j_descriptor_.obj(), env, j_descriptor_.obj(),
base::android::ToJavaByteArray(env, new_value).obj())) { base::android::ToJavaByteArray(env, new_value).obj())) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(error_callback, base::Bind(error_callback,
BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED)); BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
......
...@@ -13,14 +13,16 @@ ...@@ -13,14 +13,16 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h" #include "base/threading/worker_pool.h"
#include "dbus/bus.h" #include "dbus/bus.h"
#include "dbus/file_descriptor.h" #include "dbus/file_descriptor.h"
...@@ -230,7 +232,7 @@ void BluetoothSocketBlueZ::RegisterProfile( ...@@ -230,7 +232,7 @@ void BluetoothSocketBlueZ::RegisterProfile(
if (!adapter->IsPresent()) { if (!adapter->IsPresent()) {
VLOG(1) << uuid_.canonical_value() << " on " << device_path_.value() VLOG(1) << uuid_.canonical_value() << " on " << device_path_.value()
<< ": Delaying profile registration."; << ": Delaying profile registration.";
base::MessageLoop::current()->PostTask(FROM_HERE, success_callback); base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, success_callback);
return; return;
} }
......
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/device_event_log/device_event_log.h" #include "components/device_event_log/device_event_log.h"
...@@ -55,8 +56,8 @@ void HidService::GetDevices(const GetDevicesCallback& callback) { ...@@ -55,8 +56,8 @@ void HidService::GetDevices(const GetDevicesCallback& callback) {
for (const auto& map_entry : devices_) { for (const auto& map_entry : devices_) {
devices.push_back(map_entry.second); devices.push_back(map_entry.second);
} }
base::MessageLoop::current()->PostTask(FROM_HERE, base::ThreadTaskRunnerHandle::Get()->PostTask(
base::Bind(callback, devices)); FROM_HERE, base::Bind(callback, devices));
} else { } else {
pending_enumerations_.push_back(callback); pending_enumerations_.push_back(callback);
} }
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
namespace device { namespace device {
...@@ -225,12 +227,12 @@ bool DataReceiver::PendingReceive::DispatchDataFrame( ...@@ -225,12 +227,12 @@ bool DataReceiver::PendingReceive::DispatchDataFrame(
if (data->is_error) { if (data->is_error) {
data->dispatched = true; data->dispatched = true;
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(receive_error_callback_, data->error)); FROM_HERE, base::Bind(receive_error_callback_, data->error));
return true; return true;
} }
buffer_in_use_ = true; buffer_in_use_ = true;
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind( base::Bind(
receive_callback_, receive_callback_,
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
namespace device { namespace device {
...@@ -80,7 +82,7 @@ bool DataSender::Cancel(int32_t error, const CancelCallback& callback) { ...@@ -80,7 +82,7 @@ bool DataSender::Cancel(int32_t error, const CancelCallback& callback) {
if (!pending_cancel_.is_null() || shut_down_) if (!pending_cancel_.is_null() || shut_down_)
return false; return false;
if (sends_awaiting_ack_.empty()) { if (sends_awaiting_ack_.empty()) {
base::MessageLoop::current()->PostTask(FROM_HERE, callback); base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
return true; return true;
} }
...@@ -120,8 +122,8 @@ void DataSender::RunCancelCallback() { ...@@ -120,8 +122,8 @@ void DataSender::RunCancelCallback() {
if (pending_cancel_.is_null()) if (pending_cancel_.is_null())
return; return;
base::MessageLoop::current()->PostTask(FROM_HERE, base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
base::Bind(pending_cancel_)); base::Bind(pending_cancel_));
pending_cancel_.Reset(); pending_cancel_.Reset();
} }
...@@ -146,19 +148,19 @@ DataSender::PendingSend::PendingSend(const base::StringPiece& data, ...@@ -146,19 +148,19 @@ DataSender::PendingSend::PendingSend(const base::StringPiece& data,
void DataSender::PendingSend::OnDataSent(uint32_t num_bytes, int32_t error) { void DataSender::PendingSend::OnDataSent(uint32_t num_bytes, int32_t error) {
if (error) { if (error) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(error_callback_, num_bytes, error)); FROM_HERE, base::Bind(error_callback_, num_bytes, error));
sender_->SendFailed(error); sender_->SendFailed(error);
} else { } else {
DCHECK(num_bytes == data_.size()); DCHECK(num_bytes == data_.size());
base::MessageLoop::current()->PostTask(FROM_HERE, base::ThreadTaskRunnerHandle::Get()->PostTask(
base::Bind(callback_, num_bytes)); FROM_HERE, base::Bind(callback_, num_bytes));
sender_->SendComplete(); sender_->SendComplete();
} }
} }
void DataSender::PendingSend::DispatchFatalError() { void DataSender::PendingSend::DispatchFatalError() {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(error_callback_, 0, sender_->fatal_error_value_)); FROM_HERE, base::Bind(error_callback_, 0, sender_->fatal_error_value_));
} }
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
namespace device { namespace device {
...@@ -154,10 +156,9 @@ void DataSinkReceiver::Done(uint32_t bytes_read) { ...@@ -154,10 +156,9 @@ void DataSinkReceiver::Done(uint32_t bytes_read) {
if (pending_data_buffers_.front()->GetRemainingBytes() == 0) if (pending_data_buffers_.front()->GetRemainingBytes() == 0)
pending_data_buffers_.pop(); pending_data_buffers_.pop();
if (!pending_data_buffers_.empty()) { if (!pending_data_buffers_.empty()) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE, base::Bind(&DataSinkReceiver::RunReadyCallback,
base::Bind(&DataSinkReceiver::RunReadyCallback, weak_factory_.GetWeakPtr()));
weak_factory_.GetWeakPtr()));
} }
} }
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
namespace device { namespace device {
...@@ -138,7 +140,7 @@ void DataSourceSender::GetMoreData() { ...@@ -138,7 +140,7 @@ void DataSourceSender::GetMoreData() {
void DataSourceSender::Done(const std::vector<char>& data) { void DataSourceSender::Done(const std::vector<char>& data) {
DoneInternal(data); DoneInternal(data);
if (!shut_down_ && available_buffer_capacity_) { if (!shut_down_ && available_buffer_capacity_) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&DataSourceSender::GetMoreData, weak_factory_.GetWeakPtr())); base::Bind(&DataSourceSender::GetMoreData, weak_factory_.GetWeakPtr()));
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/message_loop/message_loop.h" #include "base/location.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -281,14 +281,14 @@ bool SerialIoHandler::ConfigurePort(const serial::ConnectionOptions& options) { ...@@ -281,14 +281,14 @@ bool SerialIoHandler::ConfigurePort(const serial::ConnectionOptions& options) {
void SerialIoHandler::QueueReadCompleted(int bytes_read, void SerialIoHandler::QueueReadCompleted(int bytes_read,
serial::ReceiveError error) { serial::ReceiveError error) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&SerialIoHandler::ReadCompleted, this, bytes_read, error)); base::Bind(&SerialIoHandler::ReadCompleted, this, bytes_read, error));
} }
void SerialIoHandler::QueueWriteCompleted(int bytes_written, void SerialIoHandler::QueueWriteCompleted(int bytes_written,
serial::SendError error) { serial::SendError error) {
base::MessageLoop::current()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error));
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/files/file.h" #include "base/files/file.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
#include "base/process/process_handle.h" #include "base/process/process_handle.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
...@@ -237,7 +239,7 @@ class UsbGadgetFactory : public UsbService::Observer, ...@@ -237,7 +239,7 @@ class UsbGadgetFactory : public UsbService::Observer,
if (!device_) { if (!device_) {
// TODO(reillyg): This timer could be replaced by a way to use long- // TODO(reillyg): This timer could be replaced by a way to use long-
// polling to wait for claimed devices to become unclaimed. // polling to wait for claimed devices to become unclaimed.
base::MessageLoop::current()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&UsbGadgetFactory::EnumerateDevices, FROM_HERE, base::Bind(&UsbGadgetFactory::EnumerateDevices,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(kReenumeratePeriod)); base::TimeDelta::FromMilliseconds(kReenumeratePeriod));
...@@ -377,7 +379,7 @@ class UsbGadgetFactory : public UsbService::Observer, ...@@ -377,7 +379,7 @@ class UsbGadgetFactory : public UsbService::Observer,
version_.clear(); version_.clear();
// Wait a bit and then try again to find an available device. // Wait a bit and then try again to find an available device.
base::MessageLoop::current()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::Bind(&UsbGadgetFactory::EnumerateDevices, FROM_HERE, base::Bind(&UsbGadgetFactory::EnumerateDevices,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(kReenumeratePeriod)); base::TimeDelta::FromMilliseconds(kReenumeratePeriod));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment