| 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 "sync/syncable/model_type_payload_map.h" | 5 #include "sync/syncable/model_type_payload_map.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 types_with_payloads[i->first] = payload; | 43 types_with_payloads[i->first] = payload; |
| 44 } | 44 } |
| 45 return types_with_payloads; | 45 return types_with_payloads; |
| 46 } | 46 } |
| 47 | 47 |
| 48 std::string ModelTypePayloadMapToString( | 48 std::string ModelTypePayloadMapToString( |
| 49 const ModelTypePayloadMap& type_payloads) { | 49 const ModelTypePayloadMap& type_payloads) { |
| 50 scoped_ptr<DictionaryValue> value( | 50 scoped_ptr<DictionaryValue> value( |
| 51 ModelTypePayloadMapToValue(type_payloads)); | 51 ModelTypePayloadMapToValue(type_payloads)); |
| 52 std::string json; | 52 std::string json; |
| 53 base::JSONWriter::Write(value.get(), false, &json); | 53 base::JSONWriter::Write(value.get(), &json); |
| 54 return json; | 54 return json; |
| 55 } | 55 } |
| 56 | 56 |
| 57 DictionaryValue* ModelTypePayloadMapToValue( | 57 DictionaryValue* ModelTypePayloadMapToValue( |
| 58 const ModelTypePayloadMap& type_payloads) { | 58 const ModelTypePayloadMap& type_payloads) { |
| 59 DictionaryValue* value = new DictionaryValue(); | 59 DictionaryValue* value = new DictionaryValue(); |
| 60 for (ModelTypePayloadMap::const_iterator it = type_payloads.begin(); | 60 for (ModelTypePayloadMap::const_iterator it = type_payloads.begin(); |
| 61 it != type_payloads.end(); ++it) { | 61 it != type_payloads.end(); ++it) { |
| 62 value->SetString(syncable::ModelTypeToString(it->first), it->second); | 62 value->SetString(syncable::ModelTypeToString(it->first), it->second); |
| 63 } | 63 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 for (std::vector<ModelTypePayloadMap::iterator>::iterator | 93 for (std::vector<ModelTypePayloadMap::iterator>::iterator |
| 94 it = iterators_to_delete.begin(); it != iterators_to_delete.end(); | 94 it = iterators_to_delete.begin(); it != iterators_to_delete.end(); |
| 95 ++it) { | 95 ++it) { |
| 96 original->erase(*it); | 96 original->erase(*it); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace syncable | 100 } // namespace syncable |
| OLD | NEW |