Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: chromeos/network/network_state.h

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to feedback Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b0d2cab295811f37c351ff17e2a5989f7802235e
--- /dev/null
+++ b/chromeos/network/network_state.h
@@ -0,0 +1,79 @@
+// 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"
+
+namespace chromeos {
+
+// Simple class to provide network state information about a network service.
+// 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 NetworkStateHandler::GetNetworkState(path) to retrieve the state for
+// the network.
+class CHROMEOS_EXPORT NetworkState : public ManagedState {
+ public:
+ enum DataRemaining {
+ DATA_UNKNOWN,
+ DATA_NORMAL,
+ DATA_LOW,
+ DATA_VERY_LOW,
+ DATA_NONE
+ };
+
+ explicit NetworkState(const std::string& path);
+
+ // ManagedState overrides.
+ virtual bool PropertyChanged(const std::string& key,
+ 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_; }
pneubeck (no reviews) 2012/10/25 14:42:17 Which format has this? If this class is directly a
stevenjb 2012/10/25 22:05:22 You're absolutely correct, this should be ip_addre
+ 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_; }
+ DataRemaining 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 NetworkStateHandler;
+
+ // Called by NetworkStateHandler 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_;
+ DataRemaining data_left_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkState);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_NETWORK_NETWORK_STATE_H_

Powered by Google App Engine
This is Rietveld 408576698