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

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

Issue 1226353004: Generate all extension schema namespaces as "api" and instead vary the generated bundle names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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_CONNECTION_H_ 5 #ifndef EXTENSIONS_BROWSER_API_SERIAL_SERIAL_CONNECTION_H_
6 #define EXTENSIONS_BROWSER_API_SERIAL_SERIAL_CONNECTION_H_ 6 #define EXTENSIONS_BROWSER_API_SERIAL_SERIAL_CONNECTION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 17 matching lines...) Expand all
28 // noted. 28 // noted.
29 class SerialConnection : public ApiResource, 29 class SerialConnection : public ApiResource,
30 public base::SupportsWeakPtr<SerialConnection> { 30 public base::SupportsWeakPtr<SerialConnection> {
31 public: 31 public:
32 typedef device::SerialIoHandler::OpenCompleteCallback OpenCompleteCallback; 32 typedef device::SerialIoHandler::OpenCompleteCallback OpenCompleteCallback;
33 33
34 // This is the callback type expected by Receive. Note that an error result 34 // This is the callback type expected by Receive. Note that an error result
35 // does not necessarily imply an empty |data| string, since a receive may 35 // does not necessarily imply an empty |data| string, since a receive may
36 // complete partially before being interrupted by an error condition. 36 // complete partially before being interrupted by an error condition.
37 typedef base::Callback<void(const std::vector<char>& data, 37 typedef base::Callback<void(const std::vector<char>& data,
38 core_api::serial::ReceiveError error)> 38 api::serial::ReceiveError error)>
39 ReceiveCompleteCallback; 39 ReceiveCompleteCallback;
40 40
41 // This is the callback type expected by Send. Note that an error result 41 // This is the callback type expected by Send. Note that an error result
42 // does not necessarily imply 0 bytes sent, since a send may complete 42 // does not necessarily imply 0 bytes sent, since a send may complete
43 // partially before being interrupted by an error condition. 43 // partially before being interrupted by an error condition.
44 typedef base::Callback< 44 typedef base::Callback<void(int bytes_sent, api::serial::SendError error)>
45 void(int bytes_sent, core_api::serial::SendError error)>
46 SendCompleteCallback; 45 SendCompleteCallback;
47 46
48 SerialConnection(const std::string& port, 47 SerialConnection(const std::string& port,
49 const std::string& owner_extension_id); 48 const std::string& owner_extension_id);
50 ~SerialConnection() override; 49 ~SerialConnection() override;
51 50
52 // ApiResource override. 51 // ApiResource override.
53 bool IsPersistent() const override; 52 bool IsPersistent() const override;
54 53
55 void set_persistent(bool persistent) { persistent_ = persistent; } 54 void set_persistent(bool persistent) { persistent_ = persistent; }
(...skipping 10 matching lines...) Expand all
66 65
67 void set_send_timeout(int send_timeout); 66 void set_send_timeout(int send_timeout);
68 int send_timeout() const { return send_timeout_; } 67 int send_timeout() const { return send_timeout_; }
69 68
70 void set_paused(bool paused); 69 void set_paused(bool paused);
71 bool paused() const { return paused_; } 70 bool paused() const { return paused_; }
72 71
73 // Initiates an asynchronous Open of the device. It is the caller's 72 // Initiates an asynchronous Open of the device. It is the caller's
74 // responsibility to ensure that this SerialConnection stays alive 73 // responsibility to ensure that this SerialConnection stays alive
75 // until |callback| is run. 74 // until |callback| is run.
76 void Open(const core_api::serial::ConnectionOptions& options, 75 void Open(const api::serial::ConnectionOptions& options,
77 const OpenCompleteCallback& callback); 76 const OpenCompleteCallback& callback);
78 77
79 // Begins an asynchronous receive operation. Calling this while a Receive 78 // Begins an asynchronous receive operation. Calling this while a Receive
80 // is already pending is a no-op and returns |false| without calling 79 // is already pending is a no-op and returns |false| without calling
81 // |callback|. 80 // |callback|.
82 bool Receive(const ReceiveCompleteCallback& callback); 81 bool Receive(const ReceiveCompleteCallback& callback);
83 82
84 // Begins an asynchronous send operation. Calling this while a Send 83 // Begins an asynchronous send operation. Calling this while a Send
85 // is already pending is a no-op and returns |false| without calling 84 // is already pending is a no-op and returns |false| without calling
86 // |callback|. 85 // |callback|.
87 bool Send(const std::vector<char>& data, 86 bool Send(const std::vector<char>& data,
88 const SendCompleteCallback& callback); 87 const SendCompleteCallback& callback);
89 88
90 // Flushes input and output buffers. 89 // Flushes input and output buffers.
91 bool Flush() const; 90 bool Flush() const;
92 91
93 // Configures some subset of port options for this connection. 92 // Configures some subset of port options for this connection.
94 // Omitted options are unchanged. Returns |true| iff the configuration 93 // Omitted options are unchanged. Returns |true| iff the configuration
95 // changes were successful. 94 // changes were successful.
96 bool Configure(const core_api::serial::ConnectionOptions& options); 95 bool Configure(const api::serial::ConnectionOptions& options);
97 96
98 // Connection configuration query. Fills values in an existing 97 // Connection configuration query. Fills values in an existing
99 // ConnectionInfo. Returns |true| iff the connection's information 98 // ConnectionInfo. Returns |true| iff the connection's information
100 // was successfully retrieved. 99 // was successfully retrieved.
101 bool GetInfo(core_api::serial::ConnectionInfo* info) const; 100 bool GetInfo(api::serial::ConnectionInfo* info) const;
102 101
103 // Reads current control signals (DCD, CTS, etc.) into an existing 102 // Reads current control signals (DCD, CTS, etc.) into an existing
104 // DeviceControlSignals structure. Returns |true| iff the signals were 103 // DeviceControlSignals structure. Returns |true| iff the signals were
105 // successfully read. 104 // successfully read.
106 bool GetControlSignals( 105 bool GetControlSignals(
107 core_api::serial::DeviceControlSignals* control_signals) const; 106 api::serial::DeviceControlSignals* control_signals) const;
108 107
109 // Sets one or more control signals (DTR and/or RTS). Returns |true| iff 108 // Sets one or more control signals (DTR and/or RTS). Returns |true| iff
110 // the signals were successfully set. Unininitialized flags in the 109 // the signals were successfully set. Unininitialized flags in the
111 // HostControlSignals structure are left unchanged. 110 // HostControlSignals structure are left unchanged.
112 bool SetControlSignals( 111 bool SetControlSignals(
113 const core_api::serial::HostControlSignals& control_signals); 112 const api::serial::HostControlSignals& control_signals);
114 113
115 // Suspend character transmission. Known as setting/sending 'Break' signal. 114 // Suspend character transmission. Known as setting/sending 'Break' signal.
116 bool SetBreak(); 115 bool SetBreak();
117 116
118 // Restore character transmission. Known as clear/stop sending 'Break' signal. 117 // Restore character transmission. Known as clear/stop sending 'Break' signal.
119 bool ClearBreak(); 118 bool ClearBreak();
120 119
121 // Overrides |io_handler_| for testing. 120 // Overrides |io_handler_| for testing.
122 void SetIoHandlerForTest(scoped_refptr<device::SerialIoHandler> handler); 121 void SetIoHandlerForTest(scoped_refptr<device::SerialIoHandler> handler);
123 122
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Asynchronous I/O handler. 198 // Asynchronous I/O handler.
200 scoped_refptr<device::SerialIoHandler> io_handler_; 199 scoped_refptr<device::SerialIoHandler> io_handler_;
201 }; 200 };
202 201
203 } // namespace extensions 202 } // namespace extensions
204 203
205 namespace mojo { 204 namespace mojo {
206 205
207 template <> 206 template <>
208 struct TypeConverter<device::serial::HostControlSignalsPtr, 207 struct TypeConverter<device::serial::HostControlSignalsPtr,
209 extensions::core_api::serial::HostControlSignals> { 208 extensions::api::serial::HostControlSignals> {
210 static device::serial::HostControlSignalsPtr Convert( 209 static device::serial::HostControlSignalsPtr Convert(
211 const extensions::core_api::serial::HostControlSignals& input); 210 const extensions::api::serial::HostControlSignals& input);
212 }; 211 };
213 212
214 template <> 213 template <>
215 struct TypeConverter<device::serial::ConnectionOptionsPtr, 214 struct TypeConverter<device::serial::ConnectionOptionsPtr,
216 extensions::core_api::serial::ConnectionOptions> { 215 extensions::api::serial::ConnectionOptions> {
217 static device::serial::ConnectionOptionsPtr Convert( 216 static device::serial::ConnectionOptionsPtr Convert(
218 const extensions::core_api::serial::ConnectionOptions& input); 217 const extensions::api::serial::ConnectionOptions& input);
219 }; 218 };
220 219
221 } // namespace mojo 220 } // namespace mojo
222 221
223 #endif // EXTENSIONS_BROWSER_API_SERIAL_SERIAL_CONNECTION_H_ 222 #endif // EXTENSIONS_BROWSER_API_SERIAL_SERIAL_CONNECTION_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/serial/serial_apitest.cc ('k') | extensions/browser/api/serial/serial_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698