Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: extensions/browser/api/serial/serial_api.h

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_SERIAL_SERIAL_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_SERIAL_SERIAL_API_H_
6 #define EXTENSIONS_BROWSER_API_SERIAL_SERIAL_API_H_ 6 #define EXTENSIONS_BROWSER_API_SERIAL_SERIAL_API_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "device/serial/serial.mojom.h" 10 #include "device/serial/serial.mojom.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void AsyncWorkStart() override; 65 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 OnConnected(bool success); 72 void OnConnected(bool success);
73 void FinishConnect(); 73 void FinishConnect();
74 74
75 scoped_ptr<serial::Connect::Params> params_; 75 std::unique_ptr<serial::Connect::Params> params_;
76 76
77 // SerialEventDispatcher is owned by a BrowserContext. 77 // SerialEventDispatcher is owned by a BrowserContext.
78 SerialEventDispatcher* serial_event_dispatcher_; 78 SerialEventDispatcher* serial_event_dispatcher_;
79 79
80 // This connection is created within SerialConnectFunction. 80 // This connection is created within SerialConnectFunction.
81 // From there it is either destroyed in OnConnected (upon failure) 81 // From there it is either destroyed in OnConnected (upon failure)
82 // or its ownership is transferred to the 82 // or its ownership is transferred to the
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 ~SerialUpdateFunction() override; 94 ~SerialUpdateFunction() override;
95 95
96 // AsyncApiFunction: 96 // AsyncApiFunction:
97 bool Prepare() override; 97 bool Prepare() override;
98 void Work() override; 98 void Work() override;
99 99
100 private: 100 private:
101 scoped_ptr<serial::Update::Params> params_; 101 std::unique_ptr<serial::Update::Params> params_;
102 }; 102 };
103 103
104 class SerialDisconnectFunction : public SerialAsyncApiFunction { 104 class SerialDisconnectFunction : public SerialAsyncApiFunction {
105 public: 105 public:
106 DECLARE_EXTENSION_FUNCTION("serial.disconnect", SERIAL_DISCONNECT) 106 DECLARE_EXTENSION_FUNCTION("serial.disconnect", SERIAL_DISCONNECT)
107 107
108 SerialDisconnectFunction(); 108 SerialDisconnectFunction();
109 109
110 protected: 110 protected:
111 ~SerialDisconnectFunction() override; 111 ~SerialDisconnectFunction() override;
112 112
113 // AsyncApiFunction: 113 // AsyncApiFunction:
114 bool Prepare() override; 114 bool Prepare() override;
115 void Work() override; 115 void Work() override;
116 116
117 private: 117 private:
118 scoped_ptr<serial::Disconnect::Params> params_; 118 std::unique_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 ~SerialSetPausedFunction() override; 128 ~SerialSetPausedFunction() override;
129 129
130 // AsyncApiFunction: 130 // AsyncApiFunction:
131 bool Prepare() override; 131 bool Prepare() override;
132 void Work() override; 132 void Work() override;
133 133
134 private: 134 private:
135 scoped_ptr<serial::SetPaused::Params> params_; 135 std::unique_ptr<serial::SetPaused::Params> params_;
136 SerialEventDispatcher* serial_event_dispatcher_; 136 SerialEventDispatcher* serial_event_dispatcher_;
137 }; 137 };
138 138
139 class SerialGetInfoFunction : public SerialAsyncApiFunction { 139 class SerialGetInfoFunction : public SerialAsyncApiFunction {
140 public: 140 public:
141 DECLARE_EXTENSION_FUNCTION("serial.getInfo", SERIAL_GETINFO) 141 DECLARE_EXTENSION_FUNCTION("serial.getInfo", SERIAL_GETINFO)
142 142
143 SerialGetInfoFunction(); 143 SerialGetInfoFunction();
144 144
145 protected: 145 protected:
146 ~SerialGetInfoFunction() override; 146 ~SerialGetInfoFunction() override;
147 147
148 // AsyncApiFunction: 148 // AsyncApiFunction:
149 bool Prepare() override; 149 bool Prepare() override;
150 void Work() override; 150 void Work() override;
151 151
152 private: 152 private:
153 scoped_ptr<serial::GetInfo::Params> params_; 153 std::unique_ptr<serial::GetInfo::Params> params_;
154 }; 154 };
155 155
156 class SerialGetConnectionsFunction : public SerialAsyncApiFunction { 156 class SerialGetConnectionsFunction : public SerialAsyncApiFunction {
157 public: 157 public:
158 DECLARE_EXTENSION_FUNCTION("serial.getConnections", SERIAL_GETCONNECTIONS); 158 DECLARE_EXTENSION_FUNCTION("serial.getConnections", SERIAL_GETCONNECTIONS);
159 159
160 SerialGetConnectionsFunction(); 160 SerialGetConnectionsFunction();
161 161
162 protected: 162 protected:
163 ~SerialGetConnectionsFunction() override; 163 ~SerialGetConnectionsFunction() override;
(...skipping 12 matching lines...) Expand all
176 protected: 176 protected:
177 ~SerialSendFunction() override; 177 ~SerialSendFunction() override;
178 178
179 // AsyncApiFunction: 179 // AsyncApiFunction:
180 bool Prepare() override; 180 bool Prepare() override;
181 void AsyncWorkStart() override; 181 void AsyncWorkStart() override;
182 182
183 private: 183 private:
184 void OnSendComplete(int bytes_sent, serial::SendError error); 184 void OnSendComplete(int bytes_sent, serial::SendError error);
185 185
186 scoped_ptr<serial::Send::Params> params_; 186 std::unique_ptr<serial::Send::Params> params_;
187 }; 187 };
188 188
189 class SerialFlushFunction : public SerialAsyncApiFunction { 189 class SerialFlushFunction : public SerialAsyncApiFunction {
190 public: 190 public:
191 DECLARE_EXTENSION_FUNCTION("serial.flush", SERIAL_FLUSH) 191 DECLARE_EXTENSION_FUNCTION("serial.flush", SERIAL_FLUSH)
192 192
193 SerialFlushFunction(); 193 SerialFlushFunction();
194 194
195 protected: 195 protected:
196 ~SerialFlushFunction() override; 196 ~SerialFlushFunction() override;
197 197
198 // AsyncApiFunction: 198 // AsyncApiFunction:
199 bool Prepare() override; 199 bool Prepare() override;
200 void Work() override; 200 void Work() override;
201 201
202 private: 202 private:
203 scoped_ptr<serial::Flush::Params> params_; 203 std::unique_ptr<serial::Flush::Params> params_;
204 }; 204 };
205 205
206 class SerialGetControlSignalsFunction : public SerialAsyncApiFunction { 206 class SerialGetControlSignalsFunction : public SerialAsyncApiFunction {
207 public: 207 public:
208 DECLARE_EXTENSION_FUNCTION("serial.getControlSignals", 208 DECLARE_EXTENSION_FUNCTION("serial.getControlSignals",
209 SERIAL_GETCONTROLSIGNALS) 209 SERIAL_GETCONTROLSIGNALS)
210 210
211 SerialGetControlSignalsFunction(); 211 SerialGetControlSignalsFunction();
212 212
213 protected: 213 protected:
214 ~SerialGetControlSignalsFunction() override; 214 ~SerialGetControlSignalsFunction() override;
215 215
216 // AsyncApiFunction: 216 // AsyncApiFunction:
217 bool Prepare() override; 217 bool Prepare() override;
218 void Work() override; 218 void Work() override;
219 219
220 private: 220 private:
221 scoped_ptr<serial::GetControlSignals::Params> params_; 221 std::unique_ptr<serial::GetControlSignals::Params> params_;
222 }; 222 };
223 223
224 class SerialSetControlSignalsFunction : public SerialAsyncApiFunction { 224 class SerialSetControlSignalsFunction : public SerialAsyncApiFunction {
225 public: 225 public:
226 DECLARE_EXTENSION_FUNCTION("serial.setControlSignals", 226 DECLARE_EXTENSION_FUNCTION("serial.setControlSignals",
227 SERIAL_SETCONTROLSIGNALS) 227 SERIAL_SETCONTROLSIGNALS)
228 228
229 SerialSetControlSignalsFunction(); 229 SerialSetControlSignalsFunction();
230 230
231 protected: 231 protected:
232 ~SerialSetControlSignalsFunction() override; 232 ~SerialSetControlSignalsFunction() override;
233 233
234 // AsyncApiFunction: 234 // AsyncApiFunction:
235 bool Prepare() override; 235 bool Prepare() override;
236 void Work() override; 236 void Work() override;
237 237
238 private: 238 private:
239 scoped_ptr<serial::SetControlSignals::Params> params_; 239 std::unique_ptr<serial::SetControlSignals::Params> params_;
240 }; 240 };
241 241
242 class SerialSetBreakFunction : public SerialAsyncApiFunction { 242 class SerialSetBreakFunction : public SerialAsyncApiFunction {
243 public: 243 public:
244 DECLARE_EXTENSION_FUNCTION("serial.setBreak", SERIAL_SETBREAK) 244 DECLARE_EXTENSION_FUNCTION("serial.setBreak", SERIAL_SETBREAK)
245 SerialSetBreakFunction(); 245 SerialSetBreakFunction();
246 246
247 protected: 247 protected:
248 ~SerialSetBreakFunction() override; 248 ~SerialSetBreakFunction() override;
249 249
250 // AsyncApiFunction: 250 // AsyncApiFunction:
251 bool Prepare() override; 251 bool Prepare() override;
252 void Work() override; 252 void Work() override;
253 253
254 private: 254 private:
255 scoped_ptr<serial::SetBreak::Params> params_; 255 std::unique_ptr<serial::SetBreak::Params> params_;
256 }; 256 };
257 257
258 class SerialClearBreakFunction : public SerialAsyncApiFunction { 258 class SerialClearBreakFunction : public SerialAsyncApiFunction {
259 public: 259 public:
260 DECLARE_EXTENSION_FUNCTION("serial.clearBreak", SERIAL_CLEARBREAK) 260 DECLARE_EXTENSION_FUNCTION("serial.clearBreak", SERIAL_CLEARBREAK)
261 SerialClearBreakFunction(); 261 SerialClearBreakFunction();
262 262
263 protected: 263 protected:
264 ~SerialClearBreakFunction() override; 264 ~SerialClearBreakFunction() override;
265 265
266 // AsyncApiFunction: 266 // AsyncApiFunction:
267 bool Prepare() override; 267 bool Prepare() override;
268 void Work() override; 268 void Work() override;
269 269
270 private: 270 private:
271 scoped_ptr<serial::ClearBreak::Params> params_; 271 std::unique_ptr<serial::ClearBreak::Params> params_;
272 }; 272 };
273 273
274 } // namespace api 274 } // namespace api
275 275
276 } // namespace extensions 276 } // namespace extensions
277 277
278 namespace mojo { 278 namespace mojo {
279 279
280 template <> 280 template <>
281 struct TypeConverter<extensions::api::serial::DeviceInfo, 281 struct TypeConverter<extensions::api::serial::DeviceInfo,
282 device::serial::DeviceInfoPtr> { 282 device::serial::DeviceInfoPtr> {
283 static extensions::api::serial::DeviceInfo Convert( 283 static extensions::api::serial::DeviceInfo Convert(
284 const device::serial::DeviceInfoPtr& input); 284 const device::serial::DeviceInfoPtr& input);
285 }; 285 };
286 286
287 } // namespace mojo 287 } // namespace mojo
288 288
289 #endif // EXTENSIONS_BROWSER_API_SERIAL_SERIAL_API_H_ 289 #endif // EXTENSIONS_BROWSER_API_SERIAL_SERIAL_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/runtime/runtime_apitest.cc ('k') | extensions/browser/api/serial/serial_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698