Index: chromeos/network/network_state.h |
diff --git a/chromeos/network/network_state.h b/chromeos/network/network_state.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4a49d92cbc25371fc25781331a13569fd3563e31 |
--- /dev/null |
+++ b/chromeos/network/network_state.h |
@@ -0,0 +1,80 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROMEOS_NETWORK_NETWORK_STATE_H_ |
+#define CHROMEOS_NETWORK_NETWORK_STATE_H_ |
+ |
+#include "chromeos/network/managed_state.h" |
+ |
+// Simple class to provide network state information about a network service. |
Greg Spencer (Chromium)
2012/10/23 23:19:10
Move inside of namespace just before class declara
stevenjb
2012/10/25 00:41:58
Done.
|
+// This class should always be passed as a const* and should never be held |
+// on to. Use path() (in ManagedState) for storing network identifiers and |
+// call NetworkStateManager::GetNetworkState(path) to retrieve the state for |
+// the network. |
+ |
+namespace chromeos { |
+ |
+class CHROMEOS_EXPORT NetworkState : public ManagedState { |
+ public: |
+ enum DataLeft { |
Greg Spencer (Chromium)
2012/10/23 23:19:10
nit: Maybe "DataPlanRemaining"?
stevenjb
2012/10/25 00:41:58
Compromise: DataRemaing
|
+ DATA_UNKNOWN, |
+ DATA_NORMAL, |
+ DATA_LOW, |
+ DATA_VERY_LOW, |
+ DATA_NONE |
+ }; |
+ |
+ explicit NetworkState(const std::string& path); |
+ |
+ // Called by NetworkStateManager when a property changes. |
+ virtual bool PropertyChanged(const std::string& key, |
Greg Spencer (Chromium)
2012/10/23 23:19:10
Add which interface this overrides to the comment:
stevenjb
2012/10/25 00:41:58
Done.
|
+ const base::Value& value) OVERRIDE; |
+ |
+ // Accessors |
+ const std::string& name() const { return name_; } |
+ const std::string& type() const { return type_; } |
+ const std::string& security() const { return security_; } |
+ const std::string& technology() const { return technology_; } |
+ const std::string& ip_config() const { return ip_config_; } |
+ const std::string& device_path() const { return device_path_; } |
+ const std::string& state() const { return state_; } |
+ const std::string& error() const { return error_; } |
+ const std::string& activation() const { return activation_; } |
+ const std::string& roaming() const { return roaming_; } |
+ int strength() const { return strength_; } |
+ DataLeft data_left() const { return data_left_; } |
+ |
+ bool IsConnectedState() const; |
+ bool IsConnectingState() const; |
+ |
+ // Helpers (used e.g. when a state is cached). |
+ static bool StateIsConnected(const std::string& state); |
+ static bool StateIsConnecting(const std::string& state); |
+ |
+ private: |
+ friend class NetworkStateManager; |
+ |
+ // Called by NetworkStateManager when the ip config changes. |
+ void set_ip_config(const std::string& ip_config) {ip_config_ = ip_config; } |
+ |
+ // Network Service Properties |
+ std::string name_; |
+ std::string type_; |
+ std::string security_; |
+ std::string technology_; |
+ std::string device_path_; |
+ std::string ip_config_; |
+ std::string state_; |
+ std::string error_; |
+ std::string activation_; |
+ std::string roaming_; |
+ int strength_; |
+ DataLeft data_left_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NetworkState); |
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ |