chrome.serial: [POSIX] Queue *Completed() callback in Cancel*Impl()

On Mac, Linux and Chrome OS, when a call is made to SerialIoHandler::CancelRead() or SerialIoHandler::CancelWrite(), no callback to SerialIoHandler:ReadCompleted() or SerialIoHandler::WriteCompleted() is triggered in the underlying implementation, as it is on Windows. This causes the cleanup code in SerialConnection::OnAsync*Complete() to never be executed. To fix the behaviour, call SerialIoHandler::Queue*Completed() directly from SerialIoHandlerPosix::Cancel*Impl().

The only code changes are in serial_io_handler_posix.cc, so there should be no effect on Windows.

BUG=383221

R=rockot@chromium.org

TEST=Toggle chrome.serial.setPaused() true then false; more detail and a link to a test app is provided in crbug.com/383221

Review URL: https://codereview.chromium.org/340713002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278130 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a3f2d26
...@@ -181,6 +181,7 @@ Joe Thomas <mhx348@motorola.com> ...@@ -181,6 +181,7 @@ Joe Thomas <mhx348@motorola.com>
Joel Stanley <joel@jms.id.au> Joel Stanley <joel@jms.id.au>
Johannes Rudolph <johannes.rudolph@googlemail.com> Johannes Rudolph <johannes.rudolph@googlemail.com>
John Yani <vanuan@gmail.com> John Yani <vanuan@gmail.com>
Jonathan Hacker <jhacker@arcanefour.com>
Jongsoo Lee <leejongsoo@gmail.com> Jongsoo Lee <leejongsoo@gmail.com>
Joone Hur <joone.hur@intel.com> Joone Hur <joone.hur@intel.com>
Jorge Villatoro <jorge@tomatocannon.com> Jorge Villatoro <jorge@tomatocannon.com>
......
...@@ -37,12 +37,14 @@ void SerialIoHandlerPosix::CancelReadImpl() { ...@@ -37,12 +37,14 @@ void SerialIoHandlerPosix::CancelReadImpl() {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
is_watching_reads_ = false; is_watching_reads_ = false;
file_read_watcher_.StopWatchingFileDescriptor(); file_read_watcher_.StopWatchingFileDescriptor();
QueueReadCompleted(0, read_cancel_reason());
} }
void SerialIoHandlerPosix::CancelWriteImpl() { void SerialIoHandlerPosix::CancelWriteImpl() {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
is_watching_writes_ = false; is_watching_writes_ = false;
file_write_watcher_.StopWatchingFileDescriptor(); file_write_watcher_.StopWatchingFileDescriptor();
QueueWriteCompleted(0, write_cancel_reason());
} }
SerialIoHandlerPosix::SerialIoHandlerPosix() SerialIoHandlerPosix::SerialIoHandlerPosix()
......
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