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

Side by Side Diff: device/serial/serial_io_handler_posix.h

Issue 2201893008: [serial] Only add a watcher if if the immeidate read attempt fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to EAGAIN Created 4 years, 4 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 | « no previous file | device/serial/serial_io_handler_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ 5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_
6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 private: 43 private:
44 friend class SerialIoHandler; 44 friend class SerialIoHandler;
45 friend class SerialIoHandlerPosixTest; 45 friend class SerialIoHandlerPosixTest;
46 46
47 SerialIoHandlerPosix( 47 SerialIoHandlerPosix(
48 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, 48 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
49 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); 49 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner);
50 ~SerialIoHandlerPosix() override; 50 ~SerialIoHandlerPosix() override;
51 51
52 void AttemptRead(bool within_read); 52 bool AttemptRead(bool within_read);
53 void RunReadCompleted(bool within_read, 53 void RunReadCompleted(bool within_read,
54 int bytes_read, 54 int bytes_read,
55 serial::ReceiveError error); 55 serial::ReceiveError error);
56 56
57 // base::MessageLoopForIO::Watcher implementation. 57 // base::MessageLoopForIO::Watcher implementation.
58 void OnFileCanWriteWithoutBlocking(int fd) override; 58 void OnFileCanWriteWithoutBlocking(int fd) override;
59 void OnFileCanReadWithoutBlocking(int fd) override; 59 void OnFileCanReadWithoutBlocking(int fd) override;
60 60
61 void EnsureWatchingReads(); 61 void EnsureWatchingReads();
62 void EnsureWatchingWrites(); 62 void EnsureWatchingWrites();
63 63
64 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; 64 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_;
65 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; 65 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_;
66 66
67 // Flags indicating if the message loop is watching the device for IO events. 67 // Flags indicating if the message loop is watching the device for IO events.
68 bool is_watching_reads_; 68 bool is_watching_reads_;
69 bool is_watching_writes_; 69 bool is_watching_writes_;
70 70
71 ErrorDetectState error_detect_state_; 71 ErrorDetectState error_detect_state_;
72 bool parity_check_enabled_; 72 bool parity_check_enabled_;
73 char chars_stashed_[2]; 73 char chars_stashed_[2];
74 int num_chars_stashed_; 74 int num_chars_stashed_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); 76 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix);
77 }; 77 };
78 78
79 } // namespace device 79 } // namespace device
80 80
81 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ 81 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_
OLDNEW
« no previous file with comments | « no previous file | device/serial/serial_io_handler_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698