Chromium Code Reviews| 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_NETWORK_LIST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "chrome/browser/chromeos/cros/network_library.h" | 10 #include "chrome/browser/chromeos/cros/network_library.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 NetworkType network_type; | 40 NetworkType network_type; |
| 41 string16 label; // string representation of the network (shown in UI). | 41 string16 label; // string representation of the network (shown in UI). |
| 42 WifiNetwork wifi_network; | 42 WifiNetwork wifi_network; |
| 43 CellularNetwork cellular_network; | 43 CellularNetwork cellular_network; |
| 44 bool connected; | 44 bool connected; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 NetworkList(); | 47 NetworkList(); |
| 48 virtual ~NetworkList() {} | 48 virtual ~NetworkList() {} |
| 49 | 49 |
| 50 // True if network list is empty. | |
| 51 bool IsEmpty() const { | |
| 52 return networks_.empty(); | |
| 53 } | |
| 54 | |
| 55 // Returns currently connected network if there is one. | 50 // Returns currently connected network if there is one. |
| 56 const NetworkList::NetworkItem* ConnectedNetwork() const; | 51 const NetworkList::NetworkItem* ConnectedNetwork() const; |
| 57 | 52 |
| 58 // Returns currently connecting network if there is one. | 53 // Returns currently connecting network if there is one. |
| 59 const NetworkList::NetworkItem* ConnectingNetwork() const; | 54 const NetworkList::NetworkItem* ConnectingNetwork() const; |
| 60 | 55 |
| 61 // Returns network by it's type and ssid (Wifi) or id (Cellular). | 56 // Returns network by it's type and ssid (Wifi) or id (Cellular). |
| 62 // If network is not available NULL is returned. | 57 // If network is not available NULL is returned. |
| 63 const NetworkList::NetworkItem* GetNetworkById(NetworkType type, | 58 const NetworkList::NetworkItem* GetNetworkById(NetworkType type, |
| 64 const string16& id); | 59 const string16& id); |
| 65 | 60 |
| 66 // Returns network index by it's type and ssid (Wifi) or id (Cellular). | 61 // Returns network index by it's type and ssid (Wifi) or id (Cellular). |
| 67 // If network is not available -1 is returned. | 62 // If network is not available -1 is returned. |
| 68 int GetNetworkIndexById(NetworkType type, const string16& id) const; | 63 int GetNetworkIndexById(NetworkType type, const string16& id) const; |
| 69 | 64 |
| 70 // Returns number of networks. | |
| 71 size_t GetNetworkCount() const { | |
| 72 return networks_.size(); | |
| 73 } | |
| 74 | |
| 75 // Returns network by index. | 65 // Returns network by index. |
| 76 NetworkList::NetworkItem* GetNetworkAt(int index); | 66 NetworkList::NetworkItem* GetNetworkAt(int index); |
| 77 | 67 |
| 68 // Returns number of networks. | |
| 69 int size() const { return static_cast<int>(networks_.size()); } | |
|
Nikita (slow)
2010/05/04 17:46:30
I believe size() should still return size_t and wh
tfarina (gmail-do not use)
2010/05/04 18:18:46
Is better? Could you elaborate here?
(Why you wou
Nikita (slow)
2010/05/05 13:41:40
Argument was to use size_t for size() to keep cons
| |
| 70 | |
| 71 // True if network list is empty. | |
| 72 bool empty() const { return networks_.empty(); } | |
| 73 | |
| 78 // Callback from NetworkLibrary. | 74 // Callback from NetworkLibrary. |
| 79 void NetworkChanged(chromeos::NetworkLibrary* network_lib); | 75 void NetworkChanged(chromeos::NetworkLibrary* network_lib); |
| 80 | 76 |
| 81 private: | 77 private: |
| 82 typedef std::vector<NetworkItem> NetworkItemVector; | |
| 83 | |
| 84 // Set connected/connecting network indices. | 78 // Set connected/connecting network indices. |
| 85 // index - network index being processed | 79 // index - network index being processed |
| 86 void SetNetworksIndices(int index, bool connected, bool connecting); | 80 void SetNetworksIndices(int index, bool connected, bool connecting); |
| 87 | 81 |
| 82 typedef std::vector<NetworkItem> NetworkItemVector; | |
| 88 // Cached list of all available networks. | 83 // Cached list of all available networks. |
| 89 NetworkItemVector networks_; | 84 NetworkItemVector networks_; |
| 90 | 85 |
| 91 // Index of currently connected network or -1 if there's none. | 86 // Index of currently connected network or -1 if there's none. |
| 92 // If several networks are connected than single one is selected by priority: | 87 // If several networks are connected than single one is selected by priority: |
| 93 // Ethernet > WiFi > Cellular. | 88 // Ethernet > WiFi > Cellular. |
| 94 int connected_network_index_; | 89 int connected_network_index_; |
| 95 | 90 |
| 96 // Index of currently connecting network or -1 if there's none. | 91 // Index of currently connecting network or -1 if there's none. |
| 97 int connecting_network_index_; | 92 int connecting_network_index_; |
| 98 | 93 |
| 99 DISALLOW_COPY_AND_ASSIGN(NetworkList); | 94 DISALLOW_COPY_AND_ASSIGN(NetworkList); |
| 100 }; | 95 }; |
| 101 | 96 |
| 102 } // namespace chromeos | 97 } // namespace chromeos |
| 103 | 98 |
| 104 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_ | 99 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_LIST_H_ |
| OLD | NEW |