OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 std::string firmware_revision_; | 246 std::string firmware_revision_; |
247 std::string hardware_revision_; | 247 std::string hardware_revision_; |
248 std::string last_update_; | 248 std::string last_update_; |
249 int PRL_version_; | 249 int PRL_version_; |
250 std::string selected_cellular_network_; | 250 std::string selected_cellular_network_; |
251 CellularNetworkList found_cellular_networks_; | 251 CellularNetworkList found_cellular_networks_; |
252 | 252 |
253 friend class NetworkLibraryImpl; | 253 friend class NetworkLibraryImpl; |
254 DISALLOW_COPY_AND_ASSIGN(NetworkDevice); | 254 DISALLOW_COPY_AND_ASSIGN(NetworkDevice); |
255 }; | 255 }; |
256 typedef std::vector<NetworkDevice*> NetworkDeviceVector; | |
256 | 257 |
257 // Contains data common to all network service types. | 258 // Contains data common to all network service types. |
258 class Network { | 259 class Network { |
259 public: | 260 public: |
260 virtual ~Network() {} | 261 virtual ~Network() {} |
261 | 262 |
262 const std::string& service_path() const { return service_path_; } | 263 const std::string& service_path() const { return service_path_; } |
263 const std::string& name() const { return name_; } | 264 const std::string& name() const { return name_; } |
264 const std::string& device_path() const { return device_path_; } | 265 const std::string& device_path() const { return device_path_; } |
265 const std::string& ip_address() const { return ip_address_; } | 266 const std::string& ip_address() const { return ip_address_; } |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 std::string gateway; | 841 std::string gateway; |
841 std::string name_servers; | 842 std::string name_servers; |
842 }; | 843 }; |
843 typedef std::vector<NetworkIPConfig> NetworkIPConfigVector; | 844 typedef std::vector<NetworkIPConfig> NetworkIPConfigVector; |
844 | 845 |
845 // This class handles the interaction with the ChromeOS network library APIs. | 846 // This class handles the interaction with the ChromeOS network library APIs. |
846 // Classes can add themselves as observers. Users can get an instance of the | 847 // Classes can add themselves as observers. Users can get an instance of the |
847 // library like this: chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 848 // library like this: chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
848 class NetworkLibrary { | 849 class NetworkLibrary { |
849 public: | 850 public: |
851 enum HardwareAddressFormat { | |
852 FORMAT_RAW_HEX, | |
853 FORMAT_COLON_SEPARATED_HEX | |
854 }; | |
855 | |
850 class NetworkManagerObserver { | 856 class NetworkManagerObserver { |
851 public: | 857 public: |
852 // Called when the state of the network manager has changed, | 858 // Called when the state of the network manager has changed, |
853 // for example, networks have appeared or disappeared. | 859 // for example, networks have appeared or disappeared. |
854 virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; | 860 virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; |
855 }; | 861 }; |
856 | 862 |
857 class NetworkObserver { | 863 class NetworkObserver { |
858 public: | 864 public: |
859 // Called when the state of a single network has changed, | 865 // Called when the state of a single network has changed, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 // Returns the current list of cellular networks. | 979 // Returns the current list of cellular networks. |
974 virtual const CellularNetworkVector& cellular_networks() const = 0; | 980 virtual const CellularNetworkVector& cellular_networks() const = 0; |
975 | 981 |
976 // Returns the current list of virtual networks. | 982 // Returns the current list of virtual networks. |
977 virtual const VirtualNetworkVector& virtual_networks() const = 0; | 983 virtual const VirtualNetworkVector& virtual_networks() const = 0; |
978 | 984 |
979 // Return a pointer to the device, if it exists, or NULL. | 985 // Return a pointer to the device, if it exists, or NULL. |
980 virtual const NetworkDevice* FindNetworkDeviceByPath( | 986 virtual const NetworkDevice* FindNetworkDeviceByPath( |
981 const std::string& path) const = 0; | 987 const std::string& path) const = 0; |
982 | 988 |
983 // Returns device with TYPE_CELLULAR. Returns NULL if such a device doesn't | 989 // Returns device with TYPE_CELLULAR. Returns NULL if none exists. |
984 // exist. | |
985 virtual const NetworkDevice* FindCellularDevice() const = 0; | 990 virtual const NetworkDevice* FindCellularDevice() const = 0; |
986 | 991 |
992 // Returns random device with TYPE_ETHERNET. Returns NULL if none exists. | |
Nikita (slow)
2011/04/25 08:51:35
"Returns random device with TYPE_ETHERNET" is misl
stevenjb
2011/04/25 17:54:27
In the future, there may be hardware more than one
Denis Lagno
2011/04/26 15:54:58
Done.
| |
993 virtual NetworkDeviceVector FindEthernetDevices() const = 0; | |
994 | |
995 // Returns random device with TYPE_WIFI. Returns NULL if none exists. | |
996 virtual NetworkDeviceVector FindWifiDevices() const = 0; | |
997 | |
987 // Return a pointer to the network, if it exists, or NULL. | 998 // Return a pointer to the network, if it exists, or NULL. |
988 // NOTE: Never store these results, store service paths instead. | 999 // NOTE: Never store these results, store service paths instead. |
989 // The pattern for doing an operation on a Network is: | 1000 // The pattern for doing an operation on a Network is: |
990 // Network* network = cros->FindNetworkByPath(service_path); | 1001 // Network* network = cros->FindNetworkByPath(service_path); |
991 // network->SetFoo(); | 1002 // network->SetFoo(); |
992 // network->Connect(); | 1003 // network->Connect(); |
993 // As long as this is done in sequence on the UI thread it will be safe; | 1004 // As long as this is done in sequence on the UI thread it will be safe; |
994 // the network list only gets updated on the UI thread. | 1005 // the network list only gets updated on the UI thread. |
995 virtual Network* FindNetworkByPath(const std::string& path) const = 0; | 1006 virtual Network* FindNetworkByPath(const std::string& path) const = 0; |
996 virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0; | 1007 virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1129 | 1140 |
1130 // Enables/disables offline mode. | 1141 // Enables/disables offline mode. |
1131 virtual void EnableOfflineMode(bool enable) = 0; | 1142 virtual void EnableOfflineMode(bool enable) = 0; |
1132 | 1143 |
1133 // Fetches IP configs and hardware address for a given device_path. | 1144 // Fetches IP configs and hardware address for a given device_path. |
1134 // The hardware address is usually a MAC address like "0011AA22BB33". | 1145 // The hardware address is usually a MAC address like "0011AA22BB33". |
1135 // |hardware_address| will be an empty string, if no hardware address is | 1146 // |hardware_address| will be an empty string, if no hardware address is |
1136 // found. | 1147 // found. |
1137 virtual NetworkIPConfigVector GetIPConfigs( | 1148 virtual NetworkIPConfigVector GetIPConfigs( |
1138 const std::string& device_path, | 1149 const std::string& device_path, |
1139 std::string* hardware_address) = 0; | 1150 std::string* hardware_address, |
1151 HardwareAddressFormat) = 0; | |
1140 | 1152 |
1141 // Factory function, creates a new instance and returns ownership. | 1153 // Factory function, creates a new instance and returns ownership. |
1142 // For normal usage, access the singleton via CrosLibrary::Get(). | 1154 // For normal usage, access the singleton via CrosLibrary::Get(). |
1143 static NetworkLibrary* GetImpl(bool stub); | 1155 static NetworkLibrary* GetImpl(bool stub); |
1144 }; | 1156 }; |
1145 | 1157 |
1146 } // namespace chromeos | 1158 } // namespace chromeos |
1147 | 1159 |
1148 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1160 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |