| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/extensions/api/api_function.h" | 12 #include "chrome/browser/extensions/api/api_function.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 extern const char kConnectionIdKey[]; | 17 extern const char kConnectionIdKey[]; |
| 18 | 18 |
| 19 class SerialOpenFunction : public AsyncIOAPIFunction { | 19 class SerialOpenFunction : public AsyncIOAPIFunction { |
| 20 public: | 20 public: |
| 21 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.open") |
| 22 |
| 21 SerialOpenFunction(); | 23 SerialOpenFunction(); |
| 22 | 24 |
| 23 protected: | 25 protected: |
| 26 virtual ~SerialOpenFunction() {} |
| 27 |
| 28 // AsyncIOAPIFunction: |
| 24 virtual bool Prepare() OVERRIDE; | 29 virtual bool Prepare() OVERRIDE; |
| 25 virtual void Work() OVERRIDE; | 30 virtual void Work() OVERRIDE; |
| 26 virtual bool Respond() OVERRIDE; | 31 virtual bool Respond() OVERRIDE; |
| 27 | 32 |
| 28 private: | 33 private: |
| 29 int src_id_; | 34 int src_id_; |
| 30 std::string port_; | 35 std::string port_; |
| 31 | |
| 32 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.open") | |
| 33 }; | 36 }; |
| 34 | 37 |
| 35 class SerialCloseFunction : public AsyncIOAPIFunction { | 38 class SerialCloseFunction : public AsyncIOAPIFunction { |
| 39 public: |
| 40 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.close") |
| 41 |
| 36 protected: | 42 protected: |
| 43 virtual ~SerialCloseFunction() {} |
| 44 |
| 45 // AsyncIOAPIFunction: |
| 37 virtual bool Prepare() OVERRIDE; | 46 virtual bool Prepare() OVERRIDE; |
| 38 virtual void Work() OVERRIDE; | 47 virtual void Work() OVERRIDE; |
| 39 virtual bool Respond() OVERRIDE; | 48 virtual bool Respond() OVERRIDE; |
| 40 | 49 |
| 41 private: | 50 private: |
| 42 int connection_id_; | 51 int connection_id_; |
| 43 | |
| 44 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.close") | |
| 45 }; | 52 }; |
| 46 | 53 |
| 47 class SerialReadFunction : public AsyncIOAPIFunction { | 54 class SerialReadFunction : public AsyncIOAPIFunction { |
| 55 public: |
| 56 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.read") |
| 57 |
| 48 protected: | 58 protected: |
| 59 virtual ~SerialReadFunction() {} |
| 60 |
| 61 // AsyncIOAPIFunction: |
| 49 virtual bool Prepare() OVERRIDE; | 62 virtual bool Prepare() OVERRIDE; |
| 50 virtual void Work() OVERRIDE; | 63 virtual void Work() OVERRIDE; |
| 51 virtual bool Respond() OVERRIDE; | 64 virtual bool Respond() OVERRIDE; |
| 52 | 65 |
| 53 private: | 66 private: |
| 54 int connection_id_; | 67 int connection_id_; |
| 55 | |
| 56 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.read") | |
| 57 }; | 68 }; |
| 58 | 69 |
| 59 class SerialWriteFunction : public AsyncIOAPIFunction { | 70 class SerialWriteFunction : public AsyncIOAPIFunction { |
| 60 public: | 71 public: |
| 72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.write") |
| 73 |
| 61 SerialWriteFunction(); | 74 SerialWriteFunction(); |
| 75 |
| 76 protected: |
| 62 virtual ~SerialWriteFunction(); | 77 virtual ~SerialWriteFunction(); |
| 63 | 78 |
| 64 protected: | 79 // AsyncIOAPIFunction: |
| 65 virtual bool Prepare() OVERRIDE; | 80 virtual bool Prepare() OVERRIDE; |
| 66 virtual void Work() OVERRIDE; | 81 virtual void Work() OVERRIDE; |
| 67 virtual bool Respond() OVERRIDE; | 82 virtual bool Respond() OVERRIDE; |
| 68 | 83 |
| 69 private: | 84 private: |
| 70 int connection_id_; | 85 int connection_id_; |
| 71 scoped_refptr<net::IOBufferWithSize> io_buffer_; | 86 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
| 72 | |
| 73 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.write") | |
| 74 }; | 87 }; |
| 75 | 88 |
| 76 } // namespace extensions | 89 } // namespace extensions |
| 77 | 90 |
| 78 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 91 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
| OLD | NEW |