OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // Reads out the results of the last wifi scan. These results are not | 291 // Reads out the results of the last wifi scan. These results are not |
292 // pre-cached in the library, so the call may block whilst the results are | 292 // pre-cached in the library, so the call may block whilst the results are |
293 // read over IPC. | 293 // read over IPC. |
294 // Returns false if an error occurred in reading the results. Note that | 294 // Returns false if an error occurred in reading the results. Note that |
295 // a true return code only indicates the result set was successfully read, | 295 // a true return code only indicates the result set was successfully read, |
296 // it does not imply a scan has successfully completed yet. | 296 // it does not imply a scan has successfully completed yet. |
297 virtual bool GetWifiAccessPoints(WifiAccessPointVector* result) = 0; | 297 virtual bool GetWifiAccessPoints(WifiAccessPointVector* result) = 0; |
298 | 298 |
299 // TODO(joth): Add GetCellTowers to retrieve a CellTowerVector. | 299 // TODO(joth): Add GetCellTowers to retrieve a CellTowerVector. |
300 | 300 |
| 301 // Force an update of the system info. |
| 302 virtual void UpdateSystemInfo() = 0; |
| 303 |
301 // Attempt to connect to the preferred network if available and it is set up. | 304 // Attempt to connect to the preferred network if available and it is set up. |
302 // This call will return true if connection is started. | 305 // This call will return true if connection is started. |
303 // If the preferred network is not available or not setup, returns false. | 306 // If the preferred network is not available or not setup, returns false. |
304 // Note: For dogfood purposes, we hardcode the preferred network to Google-A. | 307 // Note: For dogfood purposes, we hardcode the preferred network to Google-A. |
305 virtual bool ConnectToPreferredNetworkIfAvailable() = 0; | 308 virtual bool ConnectToPreferredNetworkIfAvailable() = 0; |
306 | 309 |
307 // Returns true if we are currently connected to the preferred network. | 310 // Returns true if we are currently connected to the preferred network. |
308 virtual bool PreferredNetworkConnected() = 0; | 311 virtual bool PreferredNetworkConnected() = 0; |
309 | 312 |
310 // Returns true if we failed to connect to the preferred network. | 313 // Returns true if we failed to connect to the preferred network. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 473 |
471 virtual bool offline_mode() const { return offline_mode_; } | 474 virtual bool offline_mode() const { return offline_mode_; } |
472 | 475 |
473 virtual void EnableEthernetNetworkDevice(bool enable); | 476 virtual void EnableEthernetNetworkDevice(bool enable); |
474 virtual void EnableWifiNetworkDevice(bool enable); | 477 virtual void EnableWifiNetworkDevice(bool enable); |
475 virtual void EnableCellularNetworkDevice(bool enable); | 478 virtual void EnableCellularNetworkDevice(bool enable); |
476 virtual void EnableOfflineMode(bool enable); | 479 virtual void EnableOfflineMode(bool enable); |
477 virtual NetworkIPConfigVector GetIPConfigs(const std::string& device_path); | 480 virtual NetworkIPConfigVector GetIPConfigs(const std::string& device_path); |
478 virtual std::string GetHtmlInfo(int refresh); | 481 virtual std::string GetHtmlInfo(int refresh); |
479 | 482 |
| 483 virtual void UpdateSystemInfo(); |
| 484 |
480 private: | 485 private: |
481 | 486 |
482 // This method is called when there's a change in network status. | 487 // This method is called when there's a change in network status. |
483 // This method is called on a background thread. | 488 // This method is called on a background thread. |
484 static void NetworkStatusChangedHandler(void* object); | 489 static void NetworkStatusChangedHandler(void* object); |
485 | 490 |
486 // This parses SystemInfo into: | 491 // This parses SystemInfo into: |
487 // - an EthernetNetwork | 492 // - an EthernetNetwork |
488 // - a WifiNetworkVector of wifi networks | 493 // - a WifiNetworkVector of wifi networks |
489 // - a CellularNetworkVector of cellular networks. | 494 // - a CellularNetworkVector of cellular networks. |
490 // - a WifiNetworkVector of remembered wifi networks | 495 // - a WifiNetworkVector of remembered wifi networks |
491 // - a CellularNetworkVector of remembered cellular networks. | 496 // - a CellularNetworkVector of remembered cellular networks. |
492 static void ParseSystem(SystemInfo* system, | 497 static void ParseSystem(SystemInfo* system, |
493 EthernetNetwork* ethernet, | 498 EthernetNetwork* ethernet, |
494 WifiNetworkVector* wifi_networks, | 499 WifiNetworkVector* wifi_networks, |
495 CellularNetworkVector* ceullular_networks, | 500 CellularNetworkVector* ceullular_networks, |
496 WifiNetworkVector* remembered_wifi_networks, | 501 WifiNetworkVector* remembered_wifi_networks, |
497 CellularNetworkVector* remembered_ceullular_networks); | 502 CellularNetworkVector* remembered_ceullular_networks); |
498 | 503 |
499 // This methods loads the initial list of networks on startup and starts the | 504 // This methods loads the initial list of networks on startup and starts the |
500 // monitoring of network changes. | 505 // monitoring of network changes. |
501 void Init(); | 506 void Init(); |
502 | 507 |
503 // Force an update of the system info. | |
504 void UpdateSystemInfo(); | |
505 | |
506 // Returns the preferred wifi network. | 508 // Returns the preferred wifi network. |
507 WifiNetwork* GetPreferredNetwork(); | 509 WifiNetwork* GetPreferredNetwork(); |
508 | 510 |
509 // Gets the WifiNetwork with the given name. Returns NULL if not found. | 511 // Gets the WifiNetwork with the given name. Returns NULL if not found. |
510 // Only used by GetPreferredNetwork() to lookup "Google" and "GoogleA" (hack) | 512 // Only used by GetPreferredNetwork() to lookup "Google" and "GoogleA" (hack) |
511 WifiNetwork* GetWifiNetworkByName(const std::string& name); | 513 WifiNetwork* GetWifiNetworkByName(const std::string& name); |
512 | 514 |
513 // Gets the WirelessNetwork (WifiNetwork or CellularNetwork) by path | 515 // Gets the WirelessNetwork (WifiNetwork or CellularNetwork) by path |
514 template<typename T> | 516 template<typename T> |
515 T* GetWirelessNetworkByPath(std::vector<T>& networks, | 517 T* GetWirelessNetworkByPath(std::vector<T>& networks, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 int connected_devices_; | 590 int connected_devices_; |
589 | 591 |
590 bool offline_mode_; | 592 bool offline_mode_; |
591 | 593 |
592 DISALLOW_COPY_AND_ASSIGN(NetworkLibraryImpl); | 594 DISALLOW_COPY_AND_ASSIGN(NetworkLibraryImpl); |
593 }; | 595 }; |
594 | 596 |
595 } // namespace chromeos | 597 } // namespace chromeos |
596 | 598 |
597 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 599 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |