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 "chrome/common/extensions/api/experimental_serial.h" | 13 #include "chrome/common/extensions/api/experimental_serial.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 class APIResourceEventNotifier; | 18 class APIResourceEventNotifier; |
19 class SerialConnection; | |
19 | 20 |
20 extern const char kConnectionIdKey[]; | 21 extern const char kConnectionIdKey[]; |
21 | 22 |
22 class SerialGetPortsFunction : public AsyncAPIFunction { | 23 class SerialGetPortsFunction : public AsyncAPIFunction { |
23 public: | 24 public: |
24 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.getPorts") | 25 DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.getPorts") |
25 | 26 |
26 SerialGetPortsFunction(); | 27 SerialGetPortsFunction(); |
27 | 28 |
28 protected: | 29 protected: |
(...skipping 13 matching lines...) Expand all Loading... | |
42 | 43 |
43 protected: | 44 protected: |
44 virtual ~SerialOpenFunction(); | 45 virtual ~SerialOpenFunction(); |
45 | 46 |
46 // AsyncAPIFunction: | 47 // AsyncAPIFunction: |
47 virtual bool Prepare() OVERRIDE; | 48 virtual bool Prepare() OVERRIDE; |
48 virtual void AsyncWorkStart() OVERRIDE; | 49 virtual void AsyncWorkStart() OVERRIDE; |
49 virtual void Work() OVERRIDE; | 50 virtual void Work() OVERRIDE; |
50 virtual bool Respond() OVERRIDE; | 51 virtual bool Respond() OVERRIDE; |
51 | 52 |
53 // Overrideable for testing. | |
Mihai Parparita -not on Chrome
2012/07/11 00:45:45
FWIW, the delegate pattern that Antony and I menti
| |
54 virtual SerialConnection* CreateSerialConnection( | |
55 const std::string& port, | |
56 int bitrate, | |
57 APIResourceEventNotifier* event_notifier); | |
58 virtual bool DoesPortExist(const std::string& port); | |
59 | |
52 private: | 60 private: |
53 scoped_ptr<api::experimental_serial::Open::Params> params_; | 61 scoped_ptr<api::experimental_serial::Open::Params> params_; |
54 int src_id_; | 62 int src_id_; |
55 int bitrate_; | 63 int bitrate_; |
56 | 64 |
57 // SerialConnection will take ownership. | 65 // SerialConnection will take ownership. |
58 APIResourceEventNotifier* event_notifier_; | 66 APIResourceEventNotifier* event_notifier_; |
59 }; | 67 }; |
60 | 68 |
61 class SerialCloseFunction : public AsyncAPIFunction { | 69 class SerialCloseFunction : public AsyncAPIFunction { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 virtual void Work() OVERRIDE; | 136 virtual void Work() OVERRIDE; |
129 virtual bool Respond() OVERRIDE; | 137 virtual bool Respond() OVERRIDE; |
130 | 138 |
131 private: | 139 private: |
132 scoped_ptr<api::experimental_serial::Flush::Params> params_; | 140 scoped_ptr<api::experimental_serial::Flush::Params> params_; |
133 }; | 141 }; |
134 | 142 |
135 } // namespace extensions | 143 } // namespace extensions |
136 | 144 |
137 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 145 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
OLD | NEW |