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

Side by Side Diff: sync/syncable/model_type_payload_map.cc

Issue 9590002: JSONWriter cleanup: integrate pretty print into write options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict 7. Created 8 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/sessions/session_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « sync/sessions/session_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698