OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_H_ | |
6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ | |
7 | |
8 #include "chromeos/network/managed_state.h" | |
9 | |
10 namespace chromeos { | |
11 | |
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 | |
14 // on to. Store network_state->path() (defined in ManagedState) instead and | |
15 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for | |
16 // the network. | |
17 class CHROMEOS_EXPORT NetworkState : public ManagedState { | |
18 public: | |
19 explicit NetworkState(const std::string& path); | |
20 virtual ~NetworkState(); | |
21 | |
22 // ManagedState overrides | |
23 virtual bool PropertyChanged(const std::string& key, | |
24 const base::Value& value) OVERRIDE; | |
25 | |
26 // Accessors | |
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_; } | |
30 const std::string& device_path() const { return device_path_; } | |
31 const std::string& state() const { return state_; } | |
32 const std::string& error() const { return error_; } | |
33 const std::string& activation_state() const { return activation_state_; } | |
34 const std::string& roaming() const { return roaming_; } | |
35 int signal_strength() const { return signal_strength_; } | |
36 | |
37 bool IsConnectedState() const; | |
38 bool IsConnectingState() const; | |
39 | |
40 // Helpers (used e.g. when a state is cached) | |
gauravsh
2012/11/06 01:56:59
Are there any places where one might be interested
stevenjb
2012/11/06 03:17:03
There is only a single error state "kStateFailure"
gauravsh
2012/11/06 22:51:41
Cool, there are a few other error states but not s
stevenjb
2012/11/07 01:38:13
The only other one I see in service_constants.h is
| |
41 static bool StateIsConnected(const std::string& state); | |
42 static bool StateIsConnecting(const std::string& state); | |
43 | |
44 private: | |
45 friend class NetworkStateHandler; | |
46 | |
47 // Called by NetworkStateHandler when the ip config changes. | |
48 void set_ip_address(const std::string& ip_address) { | |
49 ip_address_ = ip_address; | |
50 } | |
51 | |
52 // Common Network Service properties | |
53 std::string security_; | |
54 std::string device_path_; | |
55 std::string ip_address_; | |
56 std::string state_; | |
57 std::string error_; | |
58 // Wireless properties | |
59 int signal_strength_; | |
60 // Cellular properties | |
61 std::string technology_; | |
62 std::string activation_state_; | |
63 std::string roaming_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(NetworkState); | |
66 }; | |
67 | |
68 } // namespace chromeos | |
69 | |
70 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ | |
OLD | NEW |