| 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 #ifndef BASE_JSON_JSON_VALUE_CONVERTER_H_ | 5 #ifndef BASE_JSON_JSON_VALUE_CONVERTER_H_ |
| 6 #define BASE_JSON_JSON_VALUE_CONVERTER_H_ | 6 #define BASE_JSON_JSON_VALUE_CONVERTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 498 } |
| 499 | 499 |
| 500 bool Convert(const base::Value& value, StructType* output) const { | 500 bool Convert(const base::Value& value, StructType* output) const { |
| 501 const DictionaryValue* dictionary_value = NULL; | 501 const DictionaryValue* dictionary_value = NULL; |
| 502 if (!value.GetAsDictionary(&dictionary_value)) | 502 if (!value.GetAsDictionary(&dictionary_value)) |
| 503 return false; | 503 return false; |
| 504 | 504 |
| 505 for(size_t i = 0; i < fields_.size(); ++i) { | 505 for(size_t i = 0; i < fields_.size(); ++i) { |
| 506 const internal::FieldConverterBase<StructType>* field_converter = | 506 const internal::FieldConverterBase<StructType>* field_converter = |
| 507 fields_[i]; | 507 fields_[i]; |
| 508 base::Value* field = NULL; | 508 const base::Value* field = NULL; |
| 509 if (dictionary_value->Get(field_converter->field_path(), &field)) { | 509 if (dictionary_value->Get(field_converter->field_path(), &field)) { |
| 510 if (!field_converter->ConvertField(*field, output)) { | 510 if (!field_converter->ConvertField(*field, output)) { |
| 511 DVLOG(1) << "failure at field " << field_converter->field_path(); | 511 DVLOG(1) << "failure at field " << field_converter->field_path(); |
| 512 return false; | 512 return false; |
| 513 } | 513 } |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 return true; | 516 return true; |
| 517 } | 517 } |
| 518 | 518 |
| 519 private: | 519 private: |
| 520 ScopedVector<internal::FieldConverterBase<StructType> > fields_; | 520 ScopedVector<internal::FieldConverterBase<StructType> > fields_; |
| 521 | 521 |
| 522 DISALLOW_COPY_AND_ASSIGN(JSONValueConverter); | 522 DISALLOW_COPY_AND_ASSIGN(JSONValueConverter); |
| 523 }; | 523 }; |
| 524 | 524 |
| 525 } // namespace base | 525 } // namespace base |
| 526 | 526 |
| 527 #endif // BASE_JSON_JSON_VALUE_CONVERTER_H_ | 527 #endif // BASE_JSON_JSON_VALUE_CONVERTER_H_ |
| OLD | NEW |