| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/cros/network_parser.h" | 5 #include "chrome/browser/chromeos/cros/network_parser.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" // for debug output only. | 8 #include "base/json/json_writer.h" // for debug output only. |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool NetworkDeviceParser::UpdateStatus(const std::string& key, | 58 bool NetworkDeviceParser::UpdateStatus(const std::string& key, |
| 59 const base::Value& value, | 59 const base::Value& value, |
| 60 NetworkDevice* device, | 60 NetworkDevice* device, |
| 61 PropertyIndex* index) { | 61 PropertyIndex* index) { |
| 62 PropertyIndex found_index = mapper().Get(key); | 62 PropertyIndex found_index = mapper().Get(key); |
| 63 if (index) | 63 if (index) |
| 64 *index = found_index; | 64 *index = found_index; |
| 65 if (!ParseValue(found_index, value, device)) { | 65 if (!ParseValue(found_index, value, device)) { |
| 66 VLOG(1) << "NetworkDeviceParser: Unhandled key: " << key; | 66 VLOG(3) << "NetworkDeviceParser: Unhandled key: " << key; |
| 67 return false; | 67 return false; |
| 68 } | 68 } |
| 69 if (VLOG_IS_ON(2)) { | 69 if (VLOG_IS_ON(3)) { |
| 70 std::string value_json; | 70 std::string value_json; |
| 71 base::JSONWriter::WriteWithOptions(&value, | 71 base::JSONWriter::WriteWithOptions(&value, |
| 72 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 72 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 73 &value_json); | 73 &value_json); |
| 74 VLOG(2) << "Updated value on device: " | 74 VLOG(3) << "Updated value on device: " |
| 75 << device->device_path() << "[" << key << "] = " << value_json; | 75 << device->device_path() << "[" << key << "] = " << value_json; |
| 76 } | 76 } |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 NetworkDevice* NetworkDeviceParser::CreateNewNetworkDevice( | 80 NetworkDevice* NetworkDeviceParser::CreateNewNetworkDevice( |
| 81 const std::string&device_path) { | 81 const std::string&device_path) { |
| 82 return new NetworkDevice(device_path); | 82 return new NetworkDevice(device_path); |
| 83 } | 83 } |
| 84 | 84 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 bool NetworkParser::UpdateStatus(const std::string& key, | 129 bool NetworkParser::UpdateStatus(const std::string& key, |
| 130 const base::Value& value, | 130 const base::Value& value, |
| 131 Network* network, | 131 Network* network, |
| 132 PropertyIndex* index) { | 132 PropertyIndex* index) { |
| 133 PropertyIndex found_index = mapper().Get(key); | 133 PropertyIndex found_index = mapper().Get(key); |
| 134 if (index) | 134 if (index) |
| 135 *index = found_index; | 135 *index = found_index; |
| 136 network->UpdatePropertyMap(found_index, &value); | 136 network->UpdatePropertyMap(found_index, &value); |
| 137 if (!ParseValue(found_index, value, network)) { | 137 if (!ParseValue(found_index, value, network)) { |
| 138 VLOG(1) << "Unhandled key '" << key << "' in Network: " << network->name() | 138 VLOG(3) << "Unhandled key '" << key << "' in Network: " << network->name() |
| 139 << " ID: " << network->unique_id() | 139 << " ID: " << network->unique_id() |
| 140 << " Type: " << ConnectionTypeToString(network->type()); | 140 << " Type: " << ConnectionTypeToString(network->type()); |
| 141 return false; | 141 return false; |
| 142 } | 142 } |
| 143 if (VLOG_IS_ON(2)) { | 143 if (VLOG_IS_ON(3)) { |
| 144 std::string value_json; | 144 std::string value_json; |
| 145 base::JSONWriter::WriteWithOptions(&value, | 145 base::JSONWriter::WriteWithOptions(&value, |
| 146 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 146 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 147 &value_json); | 147 &value_json); |
| 148 VLOG(2) << "Updated value on network: " | 148 VLOG(3) << "Updated value on network: " |
| 149 << network->unique_id() << "[" << key << "] = " << value_json; | 149 << network->unique_id() << "[" << key << "] = " << value_json; |
| 150 } | 150 } |
| 151 return true; | 151 return true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 Network* NetworkParser::CreateNewNetwork( | 154 Network* NetworkParser::CreateNewNetwork( |
| 155 ConnectionType type, const std::string& service_path) { | 155 ConnectionType type, const std::string& service_path) { |
| 156 switch (type) { | 156 switch (type) { |
| 157 case TYPE_ETHERNET: { | 157 case TYPE_ETHERNET: { |
| 158 EthernetNetwork* ethernet = new EthernetNetwork(service_path); | 158 EthernetNetwork* ethernet = new EthernetNetwork(service_path); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 network->set_ui_data(NetworkUIData(*ui_data_dict)); | 229 network->set_ui_data(NetworkUIData(*ui_data_dict)); |
| 230 return true; | 230 return true; |
| 231 } | 231 } |
| 232 default: | 232 default: |
| 233 break; | 233 break; |
| 234 } | 234 } |
| 235 return false; | 235 return false; |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace chromeos | 238 } // namespace chromeos |
| OLD | NEW |