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

Unified Diff: chrome/browser/chromeos/cros/network_parser.h

Issue 8734013: Resubmit CL. See 8429004. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.cc ('k') | chrome/browser/chromeos/cros/network_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/network_parser.h
===================================================================
--- chrome/browser/chromeos/cros/network_parser.h (revision 112004)
+++ chrome/browser/chromeos/cros/network_parser.h (working copy)
@@ -52,8 +52,10 @@
EnumMapper(const Pair* list, size_t num_entries, EnumType unknown)
: unknown_value_(unknown) {
- for (size_t i = 0; i < num_entries; ++i, ++list)
+ for (size_t i = 0; i < num_entries; ++i, ++list) {
enum_map_[list->key] = list->value;
+ inverse_enum_map_[list->value] = list->key;
+ }
}
EnumType Get(const std::string& type) const {
@@ -63,10 +65,20 @@
return unknown_value_;
}
+ std::string GetKey(EnumType type) const {
+ InverseEnumMapConstIter iter = inverse_enum_map_.find(type);
+ if (iter != inverse_enum_map_.end())
+ return iter->second;
+ return std::string();
+ }
+
private:
typedef typename std::map<std::string, EnumType> EnumMap;
+ typedef typename std::map<EnumType, std::string> InverseEnumMap;
typedef typename EnumMap::const_iterator EnumMapConstIter;
+ typedef typename InverseEnumMap::const_iterator InverseEnumMapConstIter;
EnumMap enum_map_;
+ InverseEnumMap inverse_enum_map_;
EnumType unknown_value_;
DISALLOW_COPY_AND_ASSIGN(EnumMapper);
};
@@ -121,19 +133,24 @@
public:
virtual ~NetworkParser();
- // Called when a new network is encountered. Returns NULL upon failure.
+ // Called when a new network is encountered. In addition to setting the
+ // members on the Network object, the Network's property_map_ variable
+ // will include all the property and corresponding value in |info|.
+ // Returns NULL upon failure.
virtual Network* CreateNetworkFromInfo(const std::string& service_path,
const base::DictionaryValue& info);
// Called when an existing network is has new information that needs
- // to be updated. Returns false upon failure.
+ // to be updated. Network's property_map_ variable will be updated.
+ // Returns false upon failure.
virtual bool UpdateNetworkFromInfo(const base::DictionaryValue& info,
Network* network);
// Called when an individual attribute of an existing network has
// changed. |index| is a return value that supplies the appropriate
// property index for the given key. |index| is filled in even if
- // the update fails. Returns false upon failure.
+ // the update fails. Network's property_map_ variable will be updated.
+ // Returns false upon failure.
virtual bool UpdateStatus(const std::string& key,
const base::Value& value,
Network* network,
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.cc ('k') | chrome/browser/chromeos/cros/network_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698