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_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "chrome/browser/extensions/api/api_function.h" | 11 #include "chrome/browser/extensions/api/api_function.h" |
12 #include "chrome/browser/extensions/api/api_resource_manager.h" | 12 #include "chrome/browser/extensions/api/api_resource_manager.h" |
13 #include "chrome/common/extensions/api/serial.h" | 13 #include "chrome/common/extensions/api/serial.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 | 15 |
| 16 namespace serial = extensions::api::serial; |
| 17 |
16 namespace extensions { | 18 namespace extensions { |
17 | 19 |
18 class SerialConnection; | 20 class SerialConnection; |
19 | 21 |
20 extern const char kConnectionIdKey[]; | 22 extern const char kConnectionIdKey[]; |
21 | 23 |
22 class SerialAsyncApiFunction : public AsyncApiFunction { | 24 class SerialAsyncApiFunction : public AsyncApiFunction { |
23 public: | 25 public: |
24 SerialAsyncApiFunction(); | 26 SerialAsyncApiFunction(); |
25 | 27 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // AsyncApiFunction: | 64 // AsyncApiFunction: |
63 virtual bool Prepare() OVERRIDE; | 65 virtual bool Prepare() OVERRIDE; |
64 virtual void AsyncWorkStart() OVERRIDE; | 66 virtual void AsyncWorkStart() OVERRIDE; |
65 virtual void Work() OVERRIDE; | 67 virtual void Work() OVERRIDE; |
66 virtual bool Respond() OVERRIDE; | 68 virtual bool Respond() OVERRIDE; |
67 | 69 |
68 // Overrideable for testing. | 70 // Overrideable for testing. |
69 virtual SerialConnection* CreateSerialConnection( | 71 virtual SerialConnection* CreateSerialConnection( |
70 const std::string& port, | 72 const std::string& port, |
71 int bitrate, | 73 int bitrate, |
| 74 serial::DataBit databit, |
| 75 serial::ParityBit parity, |
| 76 serial::StopBit stopbit, |
72 const std::string& owner_extension_id); | 77 const std::string& owner_extension_id); |
| 78 |
73 virtual bool DoesPortExist(const std::string& port); | 79 virtual bool DoesPortExist(const std::string& port); |
74 | 80 |
75 private: | 81 private: |
76 scoped_ptr<api::serial::Open::Params> params_; | 82 scoped_ptr<api::serial::Open::Params> params_; |
77 int bitrate_; | 83 int bitrate_; |
| 84 api::serial::DataBit databit_; |
| 85 api::serial::ParityBit parity_; |
| 86 api::serial::StopBit stopbit_; |
78 }; | 87 }; |
79 | 88 |
80 class SerialCloseFunction : public SerialAsyncApiFunction { | 89 class SerialCloseFunction : public SerialAsyncApiFunction { |
81 public: | 90 public: |
82 DECLARE_EXTENSION_FUNCTION("serial.close", SERIAL_CLOSE) | 91 DECLARE_EXTENSION_FUNCTION("serial.close", SERIAL_CLOSE) |
83 | 92 |
84 SerialCloseFunction(); | 93 SerialCloseFunction(); |
85 | 94 |
86 protected: | 95 protected: |
87 virtual ~SerialCloseFunction(); | 96 virtual ~SerialCloseFunction(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 virtual void Work() OVERRIDE; | 195 virtual void Work() OVERRIDE; |
187 virtual bool Respond() OVERRIDE; | 196 virtual bool Respond() OVERRIDE; |
188 | 197 |
189 private: | 198 private: |
190 scoped_ptr<api::serial::SetControlSignals::Params> params_; | 199 scoped_ptr<api::serial::SetControlSignals::Params> params_; |
191 }; | 200 }; |
192 | 201 |
193 } // namespace extensions | 202 } // namespace extensions |
194 | 203 |
195 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 204 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
OLD | NEW |