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 base { | |
11 class DictionaryValue; | |
12 } | |
13 | |
10 namespace chromeos { | 14 namespace chromeos { |
11 | 15 |
12 // Simple class to provide network state information about a network service. | 16 // 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 | 17 // 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 | 18 // on to. Store network_state->path() (defined in ManagedState) instead and |
15 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for | 19 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for |
16 // the network. | 20 // the network. |
17 class CHROMEOS_EXPORT NetworkState : public ManagedState { | 21 class CHROMEOS_EXPORT NetworkState : public ManagedState { |
18 public: | 22 public: |
19 explicit NetworkState(const std::string& path); | 23 explicit NetworkState(const std::string& path); |
20 virtual ~NetworkState(); | 24 virtual ~NetworkState(); |
21 | 25 |
22 // ManagedState overrides | 26 // ManagedState overrides. |
27 // If you change this method, update GetProperties too. | |
stevenjb
2013/03/07 18:29:54
nit: We should probably describe this function too
pneubeck (no reviews)
2013/03/07 19:26:36
This function is already documented in the base cl
| |
23 virtual bool PropertyChanged(const std::string& key, | 28 virtual bool PropertyChanged(const std::string& key, |
24 const base::Value& value) OVERRIDE; | 29 const base::Value& value) OVERRIDE; |
25 | 30 |
26 // Accessors | 31 // Fills |dictionary| with the state properties. All the properties that are |
32 // accepted by PropertyChanged are stored in |dictionary|, no other values are | |
33 // stored. | |
34 void GetProperties(base::DictionaryValue* dictionary) const; | |
35 | |
36 // Accessors. | |
27 const std::string& security() const { return security_; } | 37 const std::string& security() const { return security_; } |
28 const std::string& ip_address() const { return ip_address_; } | 38 const std::string& ip_address() const { return ip_address_; } |
29 const std::string& device_path() const { return device_path_; } | 39 const std::string& device_path() const { return device_path_; } |
30 const std::string& guid() const { return guid_; } | 40 const std::string& guid() const { return guid_; } |
31 const std::string& connection_state() const { return connection_state_; } | 41 const std::string& connection_state() const { return connection_state_; } |
32 const std::string& error() const { return error_; } | 42 const std::string& error() const { return error_; } |
33 // Wireless property accessors | 43 // Wireless property accessors. |
34 int signal_strength() const { return signal_strength_; } | 44 int signal_strength() const { return signal_strength_; } |
35 // Cellular property accessors | 45 // Cellular property accessors. |
36 const std::string& technology() const { return technology_; } | 46 const std::string& technology() const { return technology_; } |
37 const std::string& activation_state() const { return activation_state_; } | 47 const std::string& activation_state() const { return activation_state_; } |
38 const std::string& roaming() const { return roaming_; } | 48 const std::string& roaming() const { return roaming_; } |
39 | 49 |
40 bool IsConnectedState() const; | 50 bool IsConnectedState() const; |
41 bool IsConnectingState() const; | 51 bool IsConnectingState() const; |
42 | 52 |
43 // Helpers (used e.g. when a state is cached) | 53 // Helpers (used e.g. when a state is cached). |
44 static bool StateIsConnected(const std::string& connection_state); | 54 static bool StateIsConnected(const std::string& connection_state); |
45 static bool StateIsConnecting(const std::string& connection_state); | 55 static bool StateIsConnecting(const std::string& connection_state); |
46 | 56 |
47 private: | 57 private: |
48 friend class NetworkStateHandler; | 58 friend class NetworkStateHandler; |
49 friend class NetworkChangeNotifierChromeosUpdateTest; | 59 friend class NetworkChangeNotifierChromeosUpdateTest; |
50 | 60 |
51 // Called by NetworkStateHandler when the ip config changes. | 61 // Called by NetworkStateHandler when the ip config changes. |
52 void set_ip_address(const std::string& ip_address) { | 62 void set_ip_address(const std::string& ip_address) { |
53 ip_address_ = ip_address; | 63 ip_address_ = ip_address; |
54 } | 64 } |
55 | 65 |
56 // Common Network Service properties | 66 // Common Network Service properties. |
57 std::string security_; | 67 std::string security_; |
58 std::string device_path_; | 68 std::string device_path_; |
59 std::string guid_; | 69 std::string guid_; |
60 std::string ip_address_; | 70 std::string ip_address_; |
61 std::string connection_state_; | 71 std::string connection_state_; |
62 std::string error_; | 72 std::string error_; |
63 // Wireless properties | 73 // Wireless properties. |
64 int signal_strength_; | 74 int signal_strength_; |
65 // Cellular properties | 75 // Cellular properties. |
66 std::string technology_; | 76 std::string technology_; |
67 std::string activation_state_; | 77 std::string activation_state_; |
68 std::string roaming_; | 78 std::string roaming_; |
69 | 79 |
70 DISALLOW_COPY_AND_ASSIGN(NetworkState); | 80 DISALLOW_COPY_AND_ASSIGN(NetworkState); |
71 }; | 81 }; |
72 | 82 |
73 } // namespace chromeos | 83 } // namespace chromeos |
74 | 84 |
75 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ | 85 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ |
OLD | NEW |