Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / device / serial / serial_io_handler_posix.h
blobc9c5fb5416472c0d7edae75c630705cf2f3e49df
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_
6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_
8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "device/serial/serial_io_handler.h"
13 namespace device {
15 class SerialIoHandlerPosix : public SerialIoHandler,
16 public base::MessageLoopForIO::Watcher {
17 protected:
18 // SerialIoHandler impl.
19 void ReadImpl() override;
20 void WriteImpl() override;
21 void CancelReadImpl() override;
22 void CancelWriteImpl() override;
23 bool ConfigurePortImpl() override;
24 bool Flush() const override;
25 serial::DeviceControlSignalsPtr GetControlSignals() const override;
26 bool SetControlSignals(
27 const serial::HostControlSignals& control_signals) override;
28 serial::ConnectionInfoPtr GetPortInfo() const override;
29 bool SetBreak() override;
30 bool ClearBreak() override;
32 private:
33 friend class SerialIoHandler;
35 SerialIoHandlerPosix(
36 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
37 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner);
38 ~SerialIoHandlerPosix() override;
40 // base::MessageLoopForIO::Watcher implementation.
41 void OnFileCanWriteWithoutBlocking(int fd) override;
42 void OnFileCanReadWithoutBlocking(int fd) override;
44 void EnsureWatchingReads();
45 void EnsureWatchingWrites();
47 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_;
48 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_;
50 // Flags indicating if the message loop is watching the device for IO events.
51 bool is_watching_reads_;
52 bool is_watching_writes_;
54 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix);
57 } // namespace device
59 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_