Index: chrome/browser/extensions/api/serial/serial_io_handler.h |
diff --git a/chrome/browser/extensions/api/serial/serial_io_handler.h b/chrome/browser/extensions/api/serial/serial_io_handler.h |
index 8784afb8a990be26bd5f60cbc1c3cccf19ff1aa5..ba4a061ba0cc890e02ddad185734e5dbfad7332c 100644 |
--- a/chrome/browser/extensions/api/serial/serial_io_handler.h |
+++ b/chrome/browser/extensions/api/serial/serial_io_handler.h |
@@ -9,7 +9,7 @@ |
#include "base/files/file.h" |
#include "base/memory/ref_counted.h" |
#include "base/threading/non_thread_safe.h" |
-#include "chrome/common/extensions/api/serial.h" |
+#include "device/serial/serial.mojom.h" |
#include "net/base/io_buffer.h" |
namespace extensions { |
@@ -28,13 +28,14 @@ class SerialIoHandler : public base::NonThreadSafe, |
// Called with a string of bytes read, and a result code. Note that an error |
// result does not necessarily imply 0 bytes read. |
- typedef base::Callback<void(const std::string& data, |
- api::serial::ReceiveError error)> |
+ typedef base::Callback< |
+ void(const std::string& data, device::serial::ReceiveError error)> |
ReadCompleteCallback; |
// Called with the number of bytes written and a result code. Note that an |
// error result does not necessarily imply 0 bytes written. |
- typedef base::Callback<void(int bytes_written, api::serial::SendError error)> |
+ typedef base::Callback< |
+ void(int bytes_written, device::serial::SendError error)> |
WriteCompleteCallback; |
// Initializes the handler on the current message loop. Must be called exactly |
@@ -63,10 +64,10 @@ class SerialIoHandler : public base::NonThreadSafe, |
bool IsWritePending() const; |
// Attempts to cancel a pending read operation. |
- void CancelRead(api::serial::ReceiveError reason); |
+ void CancelRead(device::serial::ReceiveError reason); |
// Attempts to cancel a pending write operation. |
- void CancelWrite(api::serial::SendError reason); |
+ void CancelWrite(device::serial::SendError reason); |
// Flushes input and output buffers. |
virtual bool Flush() const = 0; |
@@ -74,23 +75,23 @@ class SerialIoHandler : public base::NonThreadSafe, |
// Reads current control signals (DCD, CTS, etc.) into an existing |
// DeviceControlSignals structure. Returns |true| iff the signals were |
// successfully read. |
- virtual bool GetControlSignals( |
- api::serial::DeviceControlSignals* control_signals) const = 0; |
+ virtual device::serial::DeviceControlSignalsPtr GetControlSignals() const = 0; |
// Sets one or more control signals (DTR and/or RTS). Returns |true| iff |
// the signals were successfully set. Unininitialized flags in the |
// HostControlSignals structure are left unchanged. |
virtual bool SetControlSignals( |
- const api::serial::HostControlSignals& control_signals) = 0; |
+ const device::serial::HostControlSignals& control_signals) = 0; |
// Performs platform-specific port configuration. Returns |true| iff |
// configuration was successful. |
- virtual bool ConfigurePort(const api::serial::ConnectionOptions& options) = 0; |
+ virtual bool ConfigurePort( |
+ const device::serial::ConnectionOptions& options) = 0; |
// Performs a platform-specific port configuration query. Fills values in an |
// existing ConnectionInfo. Returns |true| iff port configuration was |
// successfully retrieved. |
- virtual bool GetPortInfo(api::serial::ConnectionInfo* info) const = 0; |
+ virtual device::serial::ConnectionInfoPtr GetPortInfo() const = 0; |
protected: |
SerialIoHandler(); |
@@ -122,22 +123,22 @@ class SerialIoHandler : public base::NonThreadSafe, |
// Called by the implementation to signal that the active read has completed. |
// WARNING: Calling this method can destroy the SerialIoHandler instance |
// if the associated I/O operation was the only thing keeping it alive. |
- void ReadCompleted(int bytes_read, api::serial::ReceiveError error); |
+ void ReadCompleted(int bytes_read, device::serial::ReceiveError error); |
// Called by the implementation to signal that the active write has completed. |
// WARNING: Calling this method may destroy the SerialIoHandler instance |
// if the associated I/O operation was the only thing keeping it alive. |
- void WriteCompleted(int bytes_written, api::serial::SendError error); |
+ void WriteCompleted(int bytes_written, device::serial::SendError error); |
// Queues a ReadCompleted call on the current thread. This is used to allow |
// ReadImpl to immediately signal completion with 0 bytes and an error, |
// without being reentrant. |
- void QueueReadCompleted(int bytes_read, api::serial::ReceiveError error); |
+ void QueueReadCompleted(int bytes_read, device::serial::ReceiveError error); |
// Queues a WriteCompleted call on the current thread. This is used to allow |
// WriteImpl to immediately signal completion with 0 bytes and an error, |
// without being reentrant. |
- void QueueWriteCompleted(int bytes_written, api::serial::SendError error); |
+ void QueueWriteCompleted(int bytes_written, device::serial::SendError error); |
const base::File& file() const { return file_; } |
@@ -149,7 +150,7 @@ class SerialIoHandler : public base::NonThreadSafe, |
return pending_read_buffer_len_; |
} |
- api::serial::ReceiveError read_cancel_reason() const { |
+ device::serial::ReceiveError read_cancel_reason() const { |
return read_cancel_reason_; |
} |
@@ -165,7 +166,7 @@ class SerialIoHandler : public base::NonThreadSafe, |
return pending_write_buffer_len_; |
} |
- api::serial::SendError write_cancel_reason() const { |
+ device::serial::SendError write_cancel_reason() const { |
return write_cancel_reason_; |
} |
@@ -196,12 +197,12 @@ class SerialIoHandler : public base::NonThreadSafe, |
scoped_refptr<net::IOBuffer> pending_read_buffer_; |
int pending_read_buffer_len_; |
- api::serial::ReceiveError read_cancel_reason_; |
+ device::serial::ReceiveError read_cancel_reason_; |
bool read_canceled_; |
scoped_refptr<net::IOBuffer> pending_write_buffer_; |
int pending_write_buffer_len_; |
- api::serial::SendError write_cancel_reason_; |
+ device::serial::SendError write_cancel_reason_; |
bool write_canceled_; |
ReadCompleteCallback read_complete_; |