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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions.h

Issue 11756002: Move cros_network_functions.cc to src/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fixes Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_network_functions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_
7
8 // This header is introduced to make it easy to switch from chromeos_network.cc
9 // to Chrome's own DBus code. crosbug.com/16557
10 // All calls to functions in chromeos_network.h should be made through
11 // functions provided by this header.
12
13 #include <vector>
14
15 #include "base/callback.h"
16 #include "base/time.h"
17 #include "chrome/browser/chromeos/cros/network_ip_config.h"
18
19 namespace base {
20
21 class DictionaryValue;
22 class Value;
23
24 } // namespace base
25
26 namespace chromeos {
27
28 // Describes whether there is an error and whether the error came from
29 // the local system or from the server implementing the connect
30 // method.
31 enum NetworkMethodErrorType {
32 NETWORK_METHOD_ERROR_NONE = 0,
33 NETWORK_METHOD_ERROR_LOCAL = 1,
34 NETWORK_METHOD_ERROR_REMOTE = 2,
35 };
36
37 // Struct to represent a SMS.
38 struct SMS {
39 SMS();
40 ~SMS();
41 base::Time timestamp;
42 std::string number;
43 std::string text;
44 std::string smsc; // optional; empty if not present in message.
45 int32 validity; // optional; -1 if not present in message.
46 int32 msgclass; // optional; -1 if not present in message.
47 };
48
49 // Callback to be called when receiving a SMS.
50 typedef base::Callback<void(const std::string& modem_device_path,
51 const SMS& message)> MonitorSMSCallback;
52
53 // Callback for asynchronous getters.
54 typedef base::Callback<void(
55 const std::string& path,
56 const base::DictionaryValue* properties)> NetworkPropertiesCallback;
57
58 // Callback for network properties watchers.
59 typedef base::Callback<void(
60 const std::string& path,
61 const std::string& key,
62 const base::Value& value)> NetworkPropertiesWatcherCallback;
63
64 // Callback for methods that initiate an operation and return no data.
65 typedef base::Callback<void(
66 const std::string& path,
67 NetworkMethodErrorType error,
68 const std::string& error_message)> NetworkOperationCallback;
69
70 // Base class of signal watchers.
71 class CrosNetworkWatcher {
72 public:
73 virtual ~CrosNetworkWatcher() {}
74
75 protected:
76 CrosNetworkWatcher() {}
77 };
78
79 struct WifiAccessPoint {
80 WifiAccessPoint();
81
82 std::string mac_address; // The mac address of the WiFi node.
83 std::string name; // The SSID of the WiFi node.
84 base::Time timestamp; // Timestamp when this AP was detected.
85 int signal_strength; // Radio signal strength measured in dBm.
86 int signal_to_noise; // Current signal to noise ratio measured in dB.
87 int channel; // Wifi channel number.
88 };
89
90 typedef std::vector<WifiAccessPoint> WifiAccessPointVector;
91
92 // Activates the cellular modem specified by |service_path| with carrier
93 // specified by |carrier|.
94 // |carrier| is NULL or an empty string, this will activate with the currently
95 // active carrier.
96 // Returns false on failure and true on success.
97 bool CrosActivateCellularModem(const std::string& service_path,
98 const std::string& carrier);
99
100
101 // Sets a property of a service to the provided value.
102 // Success is indicated by the receipt of a matching PropertyChanged signal.
103 void CrosSetNetworkServiceProperty(const std::string& service_path,
104 const std::string& property,
105 const base::Value& value);
106
107 // Clears a property of a service.
108 void CrosClearNetworkServiceProperty(const std::string& service_path,
109 const std::string& property);
110
111 // Sets a property of a device to the provided value.
112 // Success is indicated by the receipt of a matching PropertyChanged signal.
113 void CrosSetNetworkDeviceProperty(const std::string& device_path,
114 const std::string& property,
115 const base::Value& value);
116
117 // Sets a property of an ip config to the provided value.
118 // Success is indicated by the receipt of a matching PropertyChanged signal.
119 void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path,
120 const std::string& property,
121 const base::Value& value);
122
123 // Sets a property of a manager to the provided value.
124 // Success is indicated by the receipt of a matching PropertyChanged signal.
125 void CrosSetNetworkManagerProperty(const std::string& property,
126 const base::Value& value);
127
128 // Deletes a remembered service from a profile.
129 void CrosDeleteServiceFromProfile(const std::string& profile_path,
130 const std::string& service_path);
131
132 // Sets up monitoring of the PropertyChanged signal on the shill manager.
133 // The provided |callback| will be called whenever a manager property changes.
134 CrosNetworkWatcher* CrosMonitorNetworkManagerProperties(
135 const NetworkPropertiesWatcherCallback& callback);
136
137 // Similar to MonitorNetworkManagerProperties for a specified network service.
138 CrosNetworkWatcher* CrosMonitorNetworkServiceProperties(
139 const NetworkPropertiesWatcherCallback& callback,
140 const std::string& service_path);
141
142 // Similar to MonitorNetworkManagerProperties for a specified network device.
143 CrosNetworkWatcher* CrosMonitorNetworkDeviceProperties(
144 const NetworkPropertiesWatcherCallback& callback,
145 const std::string& device_path);
146
147 // Similar to MonitorNetworkManagerProperties for a specified network device.
148 CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path,
149 MonitorSMSCallback callback);
150
151 // Connects to the service with the |service_path|.
152 // Service parameters such as authentication must already be configured.
153 // Note, a successful invocation of the callback only indicates that
154 // the connection process has started. You will have to query the
155 // connection state to determine if the connection was established
156 // successfully.
157 void CrosRequestNetworkServiceConnect(const std::string& service_path,
158 const NetworkOperationCallback& callback);
159
160 // Retrieves the latest info for the manager.
161 void CrosRequestNetworkManagerProperties(
162 const NetworkPropertiesCallback& callback);
163
164 // Retrieves the latest info for a service.
165 void CrosRequestNetworkServiceProperties(
166 const std::string& service_path,
167 const NetworkPropertiesCallback& callback);
168
169 // Retrieves the latest info for a particular device.
170 void CrosRequestNetworkDeviceProperties(
171 const std::string& device_path,
172 const NetworkPropertiesCallback& callback);
173
174 // Retrieves the list of remembered services for a profile.
175 void CrosRequestNetworkProfileProperties(
176 const std::string& profile_path,
177 const NetworkPropertiesCallback& callback);
178
179 // Retrieves the latest info for a profile service entry.
180 void CrosRequestNetworkProfileEntryProperties(
181 const std::string& profile_path,
182 const std::string& profile_entry_path,
183 const NetworkPropertiesCallback& callback);
184
185 // Requests a wifi service not in the network list (i.e. hidden).
186 void CrosRequestHiddenWifiNetworkProperties(
187 const std::string& ssid,
188 const std::string& security,
189 const NetworkPropertiesCallback& callback);
190
191 // Requests a new VPN service.
192 void CrosRequestVirtualNetworkProperties(
193 const std::string& service_name,
194 const std::string& server_hostname,
195 const std::string& provider_type,
196 const NetworkPropertiesCallback& callback);
197
198 // Disconnects from network service asynchronously.
199 void CrosRequestNetworkServiceDisconnect(const std::string& service_path);
200
201 // Removes an exisiting network service (e.g. after forgetting a VPN).
202 void CrosRequestRemoveNetworkService(const std::string& service_path);
203
204 // Requests a scan of services of |type|.
205 // |type| should be is a string recognized by shill's Manager API.
206 void CrosRequestNetworkScan(const std::string& network_type);
207
208 // Requests enabling or disabling a device.
209 void CrosRequestNetworkDeviceEnable(const std::string& network_type,
210 bool enable);
211
212 // Enables or disables PIN protection for a SIM card.
213 void CrosRequestRequirePin(const std::string& device_path,
214 const std::string& pin,
215 bool enable,
216 const NetworkOperationCallback& callback);
217
218 // Enters a PIN to unlock a SIM card.
219 void CrosRequestEnterPin(const std::string& device_path,
220 const std::string& pin,
221 const NetworkOperationCallback& callback);
222
223 // Enters a PUK to unlock a SIM card whose PIN has been entered
224 // incorrectly too many times. A new |pin| must be supplied
225 // along with the |unblock_code| (PUK).
226 void CrosRequestUnblockPin(const std::string& device_path,
227 const std::string& unblock_code,
228 const std::string& pin,
229 const NetworkOperationCallback& callback);
230
231 // Changes the PIN used to unlock a SIM card.
232 void CrosRequestChangePin(const std::string& device_path,
233 const std::string& old_pin,
234 const std::string& new_pin,
235 const NetworkOperationCallback& callback);
236
237 // Proposes to trigger a scan transaction. For cellular networks scan result
238 // is set in the property Cellular.FoundNetworks.
239 void CrosProposeScan(const std::string& device_path);
240
241 // Initiates registration on the network specified by network_id, which is in
242 // the form MCCMNC. If the network ID is the empty string, then switch back to
243 // automatic registration mode before initiating registration.
244 void CrosRequestCellularRegister(const std::string& device_path,
245 const std::string& network_id,
246 const NetworkOperationCallback& callback);
247
248 // Enables or disables the specific network device for connection.
249 // Set offline mode. This will turn off all radios.
250 // Returns false on failure and true on success.
251 bool CrosSetOfflineMode(bool offline);
252
253 // Gets a list of all the NetworkIPConfigs using a given device path,
254 // and returns the information via callback.
255 void CrosListIPConfigs(const std::string& device_path,
256 const NetworkGetIPConfigsCallback& callback);
257
258 // DEPRECATED, DO NOT USE: Use the asynchronous CrosListIPConfigs, above,
259 // instead.
260 // Gets a list of all the NetworkIPConfigs using a given device path.
261 // Optionally, you can get ipconfig-paths and the hardware address. Pass NULL as
262 // |ipconfig_paths| and |hardware_address| if you are not interested in these
263 // values.
264 bool CrosListIPConfigsAndBlock(const std::string& device_path,
265 NetworkIPConfigVector* ipconfig_vector,
266 std::vector<std::string>* ipconfig_paths,
267 std::string* hardware_address);
268
269 // Refreshes the IP config |ipconfig_path| to pick up changes in
270 // configuration, and renew the DHCP lease, if any.
271 void CrosRequestIPConfigRefresh(const std::string& ipconfig_path);
272
273 // Reads out the results of the last wifi scan. These results are not
274 // pre-cached in the library, so the call may block whilst the results are
275 // read over IPC.
276 // Returns false if an error occurred in reading the results. Note that
277 // a true return code only indicates the result set was successfully read,
278 // it does not imply a scan has successfully completed yet.
279 bool CrosGetWifiAccessPoints(WifiAccessPointVector* result);
280
281 // Configures the network service specified by |properties|.
282 void CrosConfigureService(const base::DictionaryValue& properties);
283
284 // Converts a |prefix_length| to a netmask. (for IPv4 only)
285 // e.g. a |prefix_length| of 24 is converted to a netmask of "255.255.255.0".
286 // Invalid prefix lengths will return the empty string.
287 std::string CrosPrefixLengthToNetmask(int32 prefix_length);
288
289 // Converts a |netmask| to a prefixlen. (for IPv4 only)
290 // e.g. a |netmask| of 255.255.255.0 is converted to a prefixlen of 24
291 int32 CrosNetmaskToPrefixLength(const std::string& netmask);
292
293 // Changes the active cellular carrier.
294 void CrosSetCarrier(const std::string& device_path,
295 const std::string& carrier,
296 const NetworkOperationCallback& callback);
297
298 } // namespace chromeos
299
300 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_NETWORK_FUNCTIONS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_network_functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698