| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PARSER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PARSER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PARSER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PARSER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Subclasses of this can then customize its methods to parse either | 76 // Subclasses of this can then customize its methods to parse either |
| 77 // libcros (flimflam) data or network setup information obtained from | 77 // libcros (flimflam) data or network setup information obtained from |
| 78 // policy or setup file import depending on the EnumMapper supplied. | 78 // policy or setup file import depending on the EnumMapper supplied. |
| 79 class NetworkDeviceParser { | 79 class NetworkDeviceParser { |
| 80 public: | 80 public: |
| 81 virtual NetworkDevice* CreateDeviceFromInfo(const std::string& device_path, | 81 virtual NetworkDevice* CreateDeviceFromInfo(const std::string& device_path, |
| 82 const DictionaryValue& info); | 82 const DictionaryValue& info); |
| 83 virtual bool UpdateDeviceFromInfo(const DictionaryValue& info, | 83 virtual bool UpdateDeviceFromInfo(const DictionaryValue& info, |
| 84 NetworkDevice* device); | 84 NetworkDevice* device); |
| 85 virtual bool UpdateStatus(const std::string& key, | 85 virtual bool UpdateStatus(const std::string& key, |
| 86 const Value& value, | 86 Value* value, |
| 87 NetworkDevice* device, | 87 NetworkDevice* device, |
| 88 PropertyIndex* index); | 88 PropertyIndex* index); |
| 89 |
| 89 protected: | 90 protected: |
| 90 // The NetworkDeviceParser does not take ownership of the |mapper|. | 91 // The NetworkDeviceParser does not take ownership of the |mapper|. |
| 91 explicit NetworkDeviceParser(const EnumMapper<PropertyIndex>* mapper); | 92 explicit NetworkDeviceParser(const EnumMapper<PropertyIndex>* mapper); |
| 92 virtual ~NetworkDeviceParser(); | 93 virtual ~NetworkDeviceParser(); |
| 93 | 94 |
| 94 virtual bool ParseValue(PropertyIndex index, | 95 virtual bool ParseValue(PropertyIndex index, |
| 95 const Value& value, | 96 Value* value, |
| 96 NetworkDevice* device) = 0; | 97 NetworkDevice* device) = 0; |
| 97 virtual ConnectionType ParseType(const std::string& type) = 0; | 98 virtual ConnectionType ParseType(const std::string& type) = 0; |
| 98 | 99 |
| 99 const EnumMapper<PropertyIndex>& mapper() const { | 100 const EnumMapper<PropertyIndex>& mapper() const { |
| 100 return *mapper_; | 101 return *mapper_; |
| 101 } | 102 } |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 const EnumMapper<PropertyIndex>* mapper_; | 105 const EnumMapper<PropertyIndex>* mapper_; |
| 105 DISALLOW_COPY_AND_ASSIGN(NetworkDeviceParser); | 106 DISALLOW_COPY_AND_ASSIGN(NetworkDeviceParser); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 118 // Called when an existing network is has new information that needs | 119 // Called when an existing network is has new information that needs |
| 119 // to be updated. Returns false upon failure. | 120 // to be updated. Returns false upon failure. |
| 120 virtual bool UpdateNetworkFromInfo(const DictionaryValue& info, | 121 virtual bool UpdateNetworkFromInfo(const DictionaryValue& info, |
| 121 Network* network); | 122 Network* network); |
| 122 | 123 |
| 123 // Called when an individual attribute of an existing network has | 124 // Called when an individual attribute of an existing network has |
| 124 // changed. |index| is a return value that supplies the appropriate | 125 // changed. |index| is a return value that supplies the appropriate |
| 125 // property index for the given key. |index| is filled in even if | 126 // property index for the given key. |index| is filled in even if |
| 126 // the update fails. Returns false upon failure. | 127 // the update fails. Returns false upon failure. |
| 127 virtual bool UpdateStatus(const std::string& key, | 128 virtual bool UpdateStatus(const std::string& key, |
| 128 const Value& value, | 129 Value* value, |
| 129 Network* network, | 130 Network* network, |
| 130 PropertyIndex* index); | 131 PropertyIndex* index); |
| 131 protected: | 132 protected: |
| 132 // The NetworkParser does not take ownership of the |mapper|. | 133 // The NetworkParser does not take ownership of the |mapper|. |
| 133 explicit NetworkParser(const EnumMapper<PropertyIndex>* mapper); | 134 explicit NetworkParser(const EnumMapper<PropertyIndex>* mapper); |
| 134 virtual ~NetworkParser(); | 135 virtual ~NetworkParser(); |
| 135 | 136 |
| 136 virtual bool ParseValue(PropertyIndex index, | 137 virtual bool ParseValue(PropertyIndex index, |
| 137 const Value& value, | 138 Value* value, |
| 138 Network* network) = 0; | 139 Network* network) = 0; |
| 139 virtual ConnectionType ParseType(const std::string& type) = 0; | 140 virtual ConnectionType ParseType(const std::string& type) = 0; |
| 140 virtual ConnectionType ParseTypeFromDictionary( | 141 virtual ConnectionType ParseTypeFromDictionary( |
| 141 const DictionaryValue& info) = 0; | 142 const DictionaryValue& info) = 0; |
| 142 virtual ConnectionMode ParseMode(const std::string& mode) = 0; | 143 virtual ConnectionMode ParseMode(const std::string& mode) = 0; |
| 143 virtual ConnectionState ParseState(const std::string& state) = 0; | 144 virtual ConnectionState ParseState(const std::string& state) = 0; |
| 144 virtual ConnectionError ParseError(const std::string& error) = 0; | 145 virtual ConnectionError ParseError(const std::string& error) = 0; |
| 145 | 146 |
| 146 const EnumMapper<PropertyIndex>& mapper() const { | 147 const EnumMapper<PropertyIndex>& mapper() const { |
| 147 return *mapper_; | 148 return *mapper_; |
| 148 } | 149 } |
| 149 | 150 |
| 150 private: | 151 private: |
| 151 const EnumMapper<PropertyIndex>* mapper_; | 152 const EnumMapper<PropertyIndex>* mapper_; |
| 152 DISALLOW_COPY_AND_ASSIGN(NetworkParser); | 153 DISALLOW_COPY_AND_ASSIGN(NetworkParser); |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 } // namespace chromeos | 156 } // namespace chromeos |
| 156 | 157 |
| 157 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PARSER_H_ | 158 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PARSER_H_ |
| OLD | NEW |