| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Encapsulates an open serial port. Platform-specific implementations are in | 23 // Encapsulates an open serial port. Platform-specific implementations are in |
| 24 // _win and _posix versions of the the .cc file. | 24 // _win and _posix versions of the the .cc file. |
| 25 class SerialConnection : public APIResource { | 25 class SerialConnection : public APIResource { |
| 26 public: | 26 public: |
| 27 SerialConnection(const std::string& port, | 27 SerialConnection(const std::string& port, |
| 28 int bitrate, | 28 int bitrate, |
| 29 APIResourceEventNotifier* event_notifier); | 29 APIResourceEventNotifier* event_notifier); |
| 30 virtual ~SerialConnection(); | 30 virtual ~SerialConnection(); |
| 31 | 31 |
| 32 bool Open(); | 32 virtual bool Open(); |
| 33 void Close(); | 33 virtual void Close(); |
| 34 void Flush(); | 34 virtual void Flush(); |
| 35 | 35 |
| 36 int Read(uint8* byte); | 36 virtual int Read(uint8* byte); |
| 37 int Write(scoped_refptr<net::IOBuffer> io_buffer, int byte_count); | 37 virtual int Write(scoped_refptr<net::IOBuffer> io_buffer, int byte_count); |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 // Do platform-specific work after a successful Open(). | 40 // Do platform-specific work after a successful Open(). |
| 41 bool PostOpen(); | 41 bool PostOpen(); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 std::string port_; | 44 std::string port_; |
| 45 int bitrate_; | 45 int bitrate_; |
| 46 base::PlatformFile file_; | 46 base::PlatformFile file_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace extensions | 49 } // namespace extensions |
| 50 | 50 |
| 51 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_ | 51 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_ |
| OLD | NEW |