Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: chrome/browser/extensions/api/serial/serial_io_handler_posix.cc

Issue 340713002: chrome.serial: [POSIX] Queue *Completed() callback in Cancel*Impl() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/api/serial/serial_io_handler_posix.h" 5 #include "chrome/browser/extensions/api/serial/serial_io_handler_posix.h"
6 6
7 #include "base/posix/eintr_wrapper.h" 7 #include "base/posix/eintr_wrapper.h"
8 8
9 namespace { 9 namespace {
10 const base::PlatformFile kInvalidPlatformFileValue = -1; 10 const base::PlatformFile kInvalidPlatformFileValue = -1;
(...skipping 19 matching lines...) Expand all
30 DCHECK(pending_write_buffer()); 30 DCHECK(pending_write_buffer());
31 DCHECK_NE(file(), kInvalidPlatformFileValue); 31 DCHECK_NE(file(), kInvalidPlatformFileValue);
32 32
33 EnsureWatchingWrites(); 33 EnsureWatchingWrites();
34 } 34 }
35 35
36 void SerialIoHandlerPosix::CancelReadImpl() { 36 void SerialIoHandlerPosix::CancelReadImpl() {
37 DCHECK(CalledOnValidThread()); 37 DCHECK(CalledOnValidThread());
38 is_watching_reads_ = false; 38 is_watching_reads_ = false;
39 file_read_watcher_.StopWatchingFileDescriptor(); 39 file_read_watcher_.StopWatchingFileDescriptor();
40 QueueReadCompleted(0, read_cancel_reason());
40 } 41 }
41 42
42 void SerialIoHandlerPosix::CancelWriteImpl() { 43 void SerialIoHandlerPosix::CancelWriteImpl() {
43 DCHECK(CalledOnValidThread()); 44 DCHECK(CalledOnValidThread());
44 is_watching_writes_ = false; 45 is_watching_writes_ = false;
45 file_write_watcher_.StopWatchingFileDescriptor(); 46 file_write_watcher_.StopWatchingFileDescriptor();
47 QueueWriteCompleted(0, write_cancel_reason());
46 } 48 }
47 49
48 SerialIoHandlerPosix::SerialIoHandlerPosix() 50 SerialIoHandlerPosix::SerialIoHandlerPosix()
49 : is_watching_reads_(false), 51 : is_watching_reads_(false),
50 is_watching_writes_(false) { 52 is_watching_writes_(false) {
51 } 53 }
52 54
53 SerialIoHandlerPosix::~SerialIoHandlerPosix() {} 55 SerialIoHandlerPosix::~SerialIoHandlerPosix() {}
54 56
55 void SerialIoHandlerPosix::OnFileCanReadWithoutBlocking(int fd) { 57 void SerialIoHandlerPosix::OnFileCanReadWithoutBlocking(int fd) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 DCHECK_NE(file(), kInvalidPlatformFileValue); 117 DCHECK_NE(file(), kInvalidPlatformFileValue);
116 if (!is_watching_writes_) { 118 if (!is_watching_writes_) {
117 is_watching_writes_ = 119 is_watching_writes_ =
118 base::MessageLoopForIO::current()->WatchFileDescriptor( 120 base::MessageLoopForIO::current()->WatchFileDescriptor(
119 file(), true, base::MessageLoopForIO::WATCH_WRITE, 121 file(), true, base::MessageLoopForIO::WATCH_WRITE,
120 &file_write_watcher_, this); 122 &file_write_watcher_, this);
121 } 123 }
122 } 124 }
123 125
124 } // namespace extensions 126 } // namespace extensions
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698