| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class SerialAsyncApiFunction : public AsyncApiFunction { | 23 class SerialAsyncApiFunction : public AsyncApiFunction { |
| 24 public: | 24 public: |
| 25 SerialAsyncApiFunction(); | 25 SerialAsyncApiFunction(); |
| 26 | 26 |
| 27 protected: | 27 protected: |
| 28 virtual ~SerialAsyncApiFunction(); | 28 virtual ~SerialAsyncApiFunction(); |
| 29 | 29 |
| 30 // AsyncApiFunction: | 30 // AsyncApiFunction: |
| 31 virtual bool PrePrepare() OVERRIDE; | 31 virtual bool PrePrepare() OVERRIDE; |
| 32 | 32 |
| 33 SerialConnection* GetSerialConnection(int api_resource_id); |
| 34 void RemoveSerialConnection(int api_resource_id); |
| 35 |
| 33 ApiResourceManager<SerialConnection>* manager_; | 36 ApiResourceManager<SerialConnection>* manager_; |
| 34 }; | 37 }; |
| 35 | 38 |
| 36 class SerialGetPortsFunction : public SerialAsyncApiFunction { | 39 class SerialGetPortsFunction : public SerialAsyncApiFunction { |
| 37 public: | 40 public: |
| 38 DECLARE_EXTENSION_FUNCTION_NAME("serial.getPorts") | 41 DECLARE_EXTENSION_FUNCTION_NAME("serial.getPorts") |
| 39 | 42 |
| 40 SerialGetPortsFunction(); | 43 SerialGetPortsFunction(); |
| 41 | 44 |
| 42 protected: | 45 protected: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 // AsyncApiFunction: | 63 // AsyncApiFunction: |
| 61 virtual bool Prepare() OVERRIDE; | 64 virtual bool Prepare() OVERRIDE; |
| 62 virtual void AsyncWorkStart() OVERRIDE; | 65 virtual void AsyncWorkStart() OVERRIDE; |
| 63 virtual void Work() OVERRIDE; | 66 virtual void Work() OVERRIDE; |
| 64 virtual bool Respond() OVERRIDE; | 67 virtual bool Respond() OVERRIDE; |
| 65 | 68 |
| 66 // Overrideable for testing. | 69 // Overrideable for testing. |
| 67 virtual SerialConnection* CreateSerialConnection( | 70 virtual SerialConnection* CreateSerialConnection( |
| 68 const std::string& port, | 71 const std::string& port, |
| 69 int bitrate, | 72 int bitrate, |
| 73 const std::string& owner_extension_id, |
| 70 ApiResourceEventNotifier* event_notifier); | 74 ApiResourceEventNotifier* event_notifier); |
| 71 virtual bool DoesPortExist(const std::string& port); | 75 virtual bool DoesPortExist(const std::string& port); |
| 72 | 76 |
| 73 private: | 77 private: |
| 74 scoped_ptr<api::serial::Open::Params> params_; | 78 scoped_ptr<api::serial::Open::Params> params_; |
| 75 int src_id_; | 79 int src_id_; |
| 76 int bitrate_; | 80 int bitrate_; |
| 77 | 81 |
| 78 // SerialConnection will take ownership. | 82 // SerialConnection will take ownership. |
| 79 ApiResourceEventNotifier* event_notifier_; | 83 ApiResourceEventNotifier* event_notifier_; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 virtual void Work() OVERRIDE; | 190 virtual void Work() OVERRIDE; |
| 187 virtual bool Respond() OVERRIDE; | 191 virtual bool Respond() OVERRIDE; |
| 188 | 192 |
| 189 private: | 193 private: |
| 190 scoped_ptr<api::serial::SetControlSignals::Params> params_; | 194 scoped_ptr<api::serial::SetControlSignals::Params> params_; |
| 191 }; | 195 }; |
| 192 | 196 |
| 193 } // namespace extensions | 197 } // namespace extensions |
| 194 | 198 |
| 195 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 199 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
| OLD | NEW |