OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROMEOS_NETWORK_NETWORK_STATE_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ |
7 | 7 |
8 #include "chromeos/network/managed_state.h" | 8 #include "chromeos/network/managed_state.h" |
9 | 9 |
10 namespace chromeos { | 10 namespace chromeos { |
11 | 11 |
12 // Simple class to provide network state information about a network service. | 12 // Simple class to provide network state information about a network service. |
13 // This class should always be passed as a const* and should never be held | 13 // This class should always be passed as a const* and should never be held |
14 // on to. Store network_state->path() (defined in ManagedState) instead and | 14 // on to. Store network_state->path() (defined in ManagedState) instead and |
15 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for | 15 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for |
16 // the network. | 16 // the network. |
17 class CHROMEOS_EXPORT NetworkState : public ManagedState { | 17 class CHROMEOS_EXPORT NetworkState : public ManagedState { |
18 public: | 18 public: |
19 explicit NetworkState(const std::string& path); | 19 explicit NetworkState(const std::string& path); |
20 virtual ~NetworkState(); | 20 virtual ~NetworkState(); |
21 | 21 |
22 // ManagedState overrides | 22 // ManagedState overrides |
23 virtual bool PropertyChanged(const std::string& key, | 23 virtual bool PropertyChanged(const std::string& key, |
24 const base::Value& value) OVERRIDE; | 24 const base::Value& value) OVERRIDE; |
25 | 25 |
26 // Accessors | 26 // Accessors |
27 const std::string& security() const { return security_; } | 27 const std::string& security() const { return security_; } |
28 const std::string& technology() const { return technology_; } | |
29 const std::string& ip_address() const { return ip_address_; } | 28 const std::string& ip_address() const { return ip_address_; } |
30 const std::string& device_path() const { return device_path_; } | 29 const std::string& device_path() const { return device_path_; } |
| 30 const std::string& guid() const { return guid_; } |
31 const std::string& connection_state() const { return connection_state_; } | 31 const std::string& connection_state() const { return connection_state_; } |
32 const std::string& error() const { return error_; } | 32 const std::string& error() const { return error_; } |
| 33 // Wireless property accessors |
| 34 int signal_strength() const { return signal_strength_; } |
| 35 // Cellular property accessors |
| 36 const std::string& technology() const { return technology_; } |
33 const std::string& activation_state() const { return activation_state_; } | 37 const std::string& activation_state() const { return activation_state_; } |
34 const std::string& roaming() const { return roaming_; } | 38 const std::string& roaming() const { return roaming_; } |
35 int signal_strength() const { return signal_strength_; } | |
36 | 39 |
37 bool IsConnectedState() const; | 40 bool IsConnectedState() const; |
38 bool IsConnectingState() const; | 41 bool IsConnectingState() const; |
39 | 42 |
40 // Helpers (used e.g. when a state is cached) | 43 // Helpers (used e.g. when a state is cached) |
41 static bool StateIsConnected(const std::string& connection_state); | 44 static bool StateIsConnected(const std::string& connection_state); |
42 static bool StateIsConnecting(const std::string& connection_state); | 45 static bool StateIsConnecting(const std::string& connection_state); |
43 | 46 |
44 private: | 47 private: |
45 friend class NetworkStateHandler; | 48 friend class NetworkStateHandler; |
46 friend class NetworkChangeNotifierChromeosUpdateTest; | 49 friend class NetworkChangeNotifierChromeosUpdateTest; |
47 | 50 |
48 // Called by NetworkStateHandler when the ip config changes. | 51 // Called by NetworkStateHandler when the ip config changes. |
49 void set_ip_address(const std::string& ip_address) { | 52 void set_ip_address(const std::string& ip_address) { |
50 ip_address_ = ip_address; | 53 ip_address_ = ip_address; |
51 } | 54 } |
52 | 55 |
53 // Common Network Service properties | 56 // Common Network Service properties |
54 std::string security_; | 57 std::string security_; |
55 std::string device_path_; | 58 std::string device_path_; |
| 59 std::string guid_; |
56 std::string ip_address_; | 60 std::string ip_address_; |
57 std::string connection_state_; | 61 std::string connection_state_; |
58 std::string error_; | 62 std::string error_; |
59 // Wireless properties | 63 // Wireless properties |
60 int signal_strength_; | 64 int signal_strength_; |
61 // Cellular properties | 65 // Cellular properties |
62 std::string technology_; | 66 std::string technology_; |
63 std::string activation_state_; | 67 std::string activation_state_; |
64 std::string roaming_; | 68 std::string roaming_; |
65 | 69 |
66 DISALLOW_COPY_AND_ASSIGN(NetworkState); | 70 DISALLOW_COPY_AND_ASSIGN(NetworkState); |
67 }; | 71 }; |
68 | 72 |
69 } // namespace chromeos | 73 } // namespace chromeos |
70 | 74 |
71 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ | 75 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ |
OLD | NEW |