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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 SerialGetDevicesFunction(); | 44 SerialGetDevicesFunction(); |
45 | 45 |
46 protected: | 46 protected: |
47 virtual ~SerialGetDevicesFunction() {} | 47 virtual ~SerialGetDevicesFunction() {} |
48 | 48 |
49 // AsyncApiFunction: | 49 // AsyncApiFunction: |
50 virtual bool Prepare() OVERRIDE; | 50 virtual bool Prepare() OVERRIDE; |
51 virtual void Work() OVERRIDE; | 51 virtual void Work() OVERRIDE; |
52 }; | 52 }; |
53 | 53 |
54 class SerialOpenFunction : public SerialAsyncApiFunction { | 54 class SerialConnectFunction : public SerialAsyncApiFunction { |
55 public: | 55 public: |
56 DECLARE_EXTENSION_FUNCTION("serial.open", SERIAL_OPEN) | 56 DECLARE_EXTENSION_FUNCTION("serial.connect", SERIAL_CONNECT) |
57 | 57 |
58 SerialOpenFunction(); | 58 SerialConnectFunction(); |
59 | 59 |
60 protected: | 60 protected: |
61 virtual ~SerialOpenFunction(); | 61 virtual ~SerialConnectFunction(); |
62 | 62 |
63 // AsyncApiFunction: | 63 // AsyncApiFunction: |
64 virtual bool Prepare() OVERRIDE; | 64 virtual bool Prepare() OVERRIDE; |
65 virtual void AsyncWorkStart() OVERRIDE; | 65 virtual void AsyncWorkStart() OVERRIDE; |
66 | 66 |
67 virtual SerialConnection* CreateSerialConnection( | 67 virtual SerialConnection* CreateSerialConnection( |
68 const std::string& port, | 68 const std::string& port, |
69 const std::string& extension_id) const; | 69 const std::string& extension_id) const; |
70 | 70 |
71 private: | 71 private: |
72 void OnOpen(bool success); | 72 void OnConnected(bool success); |
73 void FinishOpen(); | 73 void FinishConnect(); |
74 | 74 |
75 scoped_ptr<serial::Open::Params> params_; | 75 scoped_ptr<serial::Connect::Params> params_; |
76 | 76 |
77 // SerialEventDispatcher is owned by a Profile. | 77 // SerialEventDispatcher is owned by a Profile. |
78 SerialEventDispatcher* serial_event_dispatcher_; | 78 SerialEventDispatcher* serial_event_dispatcher_; |
79 | 79 |
80 // This connection is created within SerialOpenFunction. | 80 // This connection is created within SerialConnectFunction. |
81 // From there it is either destroyed in OnOpen (upon failure) | 81 // From there it is either destroyed in OnConnected (upon failure) |
82 // or its ownership is transferred to the profile's. | 82 // or its ownership is transferred to the profile's. |
83 // ApiResourceManager<SerialConnection>. | 83 // ApiResourceManager<SerialConnection>. |
84 SerialConnection* connection_; | 84 SerialConnection* connection_; |
85 }; | 85 }; |
86 | 86 |
87 class SerialUpdateFunction : public SerialAsyncApiFunction { | 87 class SerialUpdateFunction : public SerialAsyncApiFunction { |
88 public: | 88 public: |
89 DECLARE_EXTENSION_FUNCTION("serial.update", SERIAL_UPDATE); | 89 DECLARE_EXTENSION_FUNCTION("serial.update", SERIAL_UPDATE); |
90 | 90 |
91 SerialUpdateFunction(); | 91 SerialUpdateFunction(); |
92 | 92 |
93 protected: | 93 protected: |
94 virtual ~SerialUpdateFunction(); | 94 virtual ~SerialUpdateFunction(); |
95 | 95 |
96 // AsyncApiFunction: | 96 // AsyncApiFunction: |
97 virtual bool Prepare() OVERRIDE; | 97 virtual bool Prepare() OVERRIDE; |
98 virtual void Work() OVERRIDE; | 98 virtual void Work() OVERRIDE; |
99 | 99 |
100 private: | 100 private: |
101 scoped_ptr<serial::Update::Params> params_; | 101 scoped_ptr<serial::Update::Params> params_; |
102 }; | 102 }; |
103 | 103 |
104 class SerialCloseFunction : public SerialAsyncApiFunction { | 104 class SerialDisconnectFunction : public SerialAsyncApiFunction { |
105 public: | 105 public: |
106 DECLARE_EXTENSION_FUNCTION("serial.close", SERIAL_CLOSE) | 106 DECLARE_EXTENSION_FUNCTION("serial.disconnect", SERIAL_DISCONNECT) |
107 | 107 |
108 SerialCloseFunction(); | 108 SerialDisconnectFunction(); |
109 | 109 |
110 protected: | 110 protected: |
111 virtual ~SerialCloseFunction(); | 111 virtual ~SerialDisconnectFunction(); |
112 | 112 |
113 // AsyncApiFunction: | 113 // AsyncApiFunction: |
114 virtual bool Prepare() OVERRIDE; | 114 virtual bool Prepare() OVERRIDE; |
115 virtual void Work() OVERRIDE; | 115 virtual void Work() OVERRIDE; |
116 | 116 |
117 private: | 117 private: |
118 scoped_ptr<serial::Close::Params> params_; | 118 scoped_ptr<serial::Disconnect::Params> params_; |
119 }; | 119 }; |
120 | 120 |
121 class SerialSetPausedFunction : public SerialAsyncApiFunction { | 121 class SerialSetPausedFunction : public SerialAsyncApiFunction { |
122 public: | 122 public: |
123 DECLARE_EXTENSION_FUNCTION("serial.setPaused", SERIAL_SETPAUSED) | 123 DECLARE_EXTENSION_FUNCTION("serial.setPaused", SERIAL_SETPAUSED) |
124 | 124 |
125 SerialSetPausedFunction(); | 125 SerialSetPausedFunction(); |
126 | 126 |
127 protected: | 127 protected: |
128 virtual ~SerialSetPausedFunction(); | 128 virtual ~SerialSetPausedFunction(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 private: | 238 private: |
239 scoped_ptr<serial::SetControlSignals::Params> params_; | 239 scoped_ptr<serial::SetControlSignals::Params> params_; |
240 }; | 240 }; |
241 | 241 |
242 } // namespace api | 242 } // namespace api |
243 | 243 |
244 } // namespace extensions | 244 } // namespace extensions |
245 | 245 |
246 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ | 246 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_ |
OLD | NEW |