| 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: |
| 46 virtual bool Prepare() OVERRIDE; |
| 37 virtual bool Prepare() OVERRIDE; | 47 virtual bool Prepare() OVERRIDE; |
| 38 virtual void Work() OVERRIDE; | 48 virtual void Work() OVERRIDE; |
| 39 virtual bool Respond() OVERRIDE; | 49 virtual bool Respond() OVERRIDE; |
| 40 | 50 |
| 41 private: | 51 private: |
| 42 int connection_id_; | 52 int connection_id_; |
| 43 | |
| 44 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.close") | |
| 45 }; | 53 }; |
| 46 | 54 |
| 47 class SerialReadFunction : public AsyncIOAPIFunction { | 55 class SerialReadFunction : public AsyncIOAPIFunction { |
| 56 public: |
| 57 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.read") |
| 58 |
| 48 protected: | 59 protected: |
| 60 virtual ~SerialReadFunction() {} |
| 61 |
| 62 // AsyncIOAPIFunction: |
| 49 virtual bool Prepare() OVERRIDE; | 63 virtual bool Prepare() OVERRIDE; |
| 50 virtual void Work() OVERRIDE; | 64 virtual void Work() OVERRIDE; |
| 51 virtual bool Respond() OVERRIDE; | 65 virtual bool Respond() OVERRIDE; |
| 52 | 66 |
| 53 private: | 67 private: |
| 54 int connection_id_; | 68 int connection_id_; |
| 55 | |
| 56 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.read") | |
| 57 }; | 69 }; |
| 58 | 70 |
| 59 class SerialWriteFunction : public AsyncIOAPIFunction { | 71 class SerialWriteFunction : public AsyncIOAPIFunction { |
| 60 public: | 72 public: |
| 73 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.write") |
| 74 |
| 61 SerialWriteFunction(); | 75 SerialWriteFunction(); |
| 76 |
| 77 protected: |
| 62 virtual ~SerialWriteFunction(); | 78 virtual ~SerialWriteFunction(); |
| 63 | 79 |
| 64 protected: | 80 // AsyncIOAPIFunction: |
| 65 virtual bool Prepare() OVERRIDE; | 81 virtual bool Prepare() OVERRIDE; |
| 66 virtual void Work() OVERRIDE; | 82 virtual void Work() OVERRIDE; |
| 67 virtual bool Respond() OVERRIDE; | 83 virtual bool Respond() OVERRIDE; |
| 68 | 84 |
| 69 private: | 85 private: |
| 70 int connection_id_; | 86 int connection_id_; |
| 71 scoped_refptr<net::IOBufferWithSize> io_buffer_; | 87 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
| 72 | |
| 73 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.write") | |
| 74 }; | 88 }; |
| 75 | 89 |
| 76 } // namespace extensions | 90 } // namespace extensions |
| 77 | 91 |
| 78 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 92 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
| OLD | NEW |