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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 | 11 |
12 namespace syncer { | 12 namespace syncer { |
13 | 13 |
14 scoped_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( | 14 scoped_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( |
15 const ModelSafeRoutingInfo& routing_info) { | 15 const ModelSafeRoutingInfo& routing_info) { |
16 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 16 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
17 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); | 17 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); |
18 it != routing_info.end(); ++it) { | 18 it != routing_info.end(); ++it) { |
19 dict->SetString(ModelTypeToString(it->first), | 19 dict->SetString(ModelTypeToString(it->first), |
20 ModelSafeGroupToString(it->second)); | 20 ModelSafeGroupToString(it->second)); |
21 } | 21 } |
22 return dict; | 22 return dict; |
23 } | 23 } |
24 | 24 |
25 std::string ModelSafeRoutingInfoToString( | 25 std::string ModelSafeRoutingInfoToString( |
26 const ModelSafeRoutingInfo& routing_info) { | 26 const ModelSafeRoutingInfo& routing_info) { |
27 scoped_ptr<base::DictionaryValue> dict = | |
28 ModelSafeRoutingInfoToValue(routing_info); | |
29 std::string json; | 27 std::string json; |
30 base::JSONWriter::Write(dict.get(), &json); | 28 base::JSONWriter::Write(*ModelSafeRoutingInfoToValue(routing_info), &json); |
31 return json; | 29 return json; |
32 } | 30 } |
33 | 31 |
34 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info) { | 32 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info) { |
35 ModelTypeSet types; | 33 ModelTypeSet types; |
36 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); | 34 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); |
37 it != routing_info.end(); ++it) { | 35 it != routing_info.end(); ++it) { |
38 types.Put(it->first); | 36 types.Put(it->first); |
39 } | 37 } |
40 return types; | 38 return types; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return; | 189 return; |
192 DCHECK_EQ(base::MessageLoop::current(), working_loop_); | 190 DCHECK_EQ(base::MessageLoop::current(), working_loop_); |
193 } | 191 } |
194 | 192 |
195 DCHECK(stopped_); | 193 DCHECK(stopped_); |
196 base::MessageLoop::current()->RemoveDestructionObserver(this); | 194 base::MessageLoop::current()->RemoveDestructionObserver(this); |
197 unregister_done_callback.Run(GetModelSafeGroup()); | 195 unregister_done_callback.Run(GetModelSafeGroup()); |
198 } | 196 } |
199 | 197 |
200 } // namespace syncer | 198 } // namespace syncer |
OLD | NEW |