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

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 Round 2 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..81bc3b39207a6002a38ff383983e16e12ca6dacd
--- /dev/null
+++ b/chromeos/network/network_state.h
@@ -0,0 +1,81 @@
+// 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
gauravsh 2012/10/25 23:41:05 I don't understand the second path of the comment.
stevenjb 2012/10/26 21:36:39 Clarified.
+// 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_address() const { return ip_address_; }
+ 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_address(const std::string& ip_address) {
+ ip_address_ = ip_address;
+ }
+
+ // Network Service Properties
+ std::string name_;
+ std::string type_;
gauravsh 2012/10/25 23:41:05 Just like my comment in device_state.h, this would
stevenjb 2012/10/26 21:36:39 Done.
+ std::string security_;
+ std::string technology_;
+ std::string device_path_;
+ std::string ip_address_;
+ std::string state_;
+ std::string error_;
+ std::string activation_;
gauravsh 2012/10/25 23:41:05 What does this track? Should this be a bool? Shoul
stevenjb 2012/10/26 21:36:39 Renamed
+ std::string roaming_;
+ int strength_;
gauravsh 2012/10/25 23:41:05 signal_strength_ would be a better name.
stevenjb 2012/10/26 21:36:39 Done.
+ 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