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/internal_api/public/engine/model_safe_worker.h" | 5 #include "sync/internal_api/public/engine/model_safe_worker.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 | 10 |
11 namespace syncer { | 11 namespace syncer { |
12 | 12 |
13 base::DictionaryValue* ModelSafeRoutingInfoToValue( | 13 base::DictionaryValue* ModelSafeRoutingInfoToValue( |
14 const ModelSafeRoutingInfo& routing_info) { | 14 const ModelSafeRoutingInfo& routing_info) { |
15 base::DictionaryValue* dict = new base::DictionaryValue(); | 15 base::DictionaryValue* dict = new base::DictionaryValue(); |
16 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); | 16 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); |
17 it != routing_info.end(); ++it) { | 17 it != routing_info.end(); ++it) { |
18 dict->SetString(ModelTypeToString(it->first), | 18 dict->SetString(ModelTypeToString(it->first), |
19 ModelSafeGroupToString(it->second)); | 19 ModelSafeGroupToString(it->second)); |
20 } | 20 } |
21 return dict; | 21 return dict; |
22 } | 22 } |
23 | 23 |
24 std::string ModelSafeRoutingInfoToString( | 24 std::string ModelSafeRoutingInfoToString( |
25 const ModelSafeRoutingInfo& routing_info) { | 25 const ModelSafeRoutingInfo& routing_info) { |
26 scoped_ptr<DictionaryValue> dict(ModelSafeRoutingInfoToValue(routing_info)); | 26 scoped_ptr<base::DictionaryValue> dict( |
| 27 ModelSafeRoutingInfoToValue(routing_info)); |
27 std::string json; | 28 std::string json; |
28 base::JSONWriter::Write(dict.get(), &json); | 29 base::JSONWriter::Write(dict.get(), &json); |
29 return json; | 30 return json; |
30 } | 31 } |
31 | 32 |
32 ModelTypeInvalidationMap ModelSafeRoutingInfoToInvalidationMap( | 33 ModelTypeInvalidationMap ModelSafeRoutingInfoToInvalidationMap( |
33 const ModelSafeRoutingInfo& routes, | 34 const ModelSafeRoutingInfo& routes, |
34 const std::string& payload) { | 35 const std::string& payload) { |
35 ModelTypeInvalidationMap invalidation_map; | 36 ModelTypeInvalidationMap invalidation_map; |
36 for (ModelSafeRoutingInfo::const_iterator i = routes.begin(); | 37 for (ModelSafeRoutingInfo::const_iterator i = routes.begin(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 129 |
129 DVLOG(1) << ModelSafeGroupToString(GetModelSafeGroup()) | 130 DVLOG(1) << ModelSafeGroupToString(GetModelSafeGroup()) |
130 << " worker stops on destruction of its working thread."; | 131 << " worker stops on destruction of its working thread."; |
131 } | 132 } |
132 | 133 |
133 if (observer_) | 134 if (observer_) |
134 observer_->OnWorkerLoopDestroyed(GetModelSafeGroup()); | 135 observer_->OnWorkerLoopDestroyed(GetModelSafeGroup()); |
135 } | 136 } |
136 | 137 |
137 } // namespace syncer | 138 } // namespace syncer |
OLD | NEW |