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

Side by Side Diff: chrome/browser/sync/engine/model_safe_worker.cc

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/engine/model_safe_worker.h"
6
7 #include "base/json/json_writer.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
10
11 namespace browser_sync {
12
13 base::DictionaryValue* ModelSafeRoutingInfoToValue(
14 const ModelSafeRoutingInfo& routing_info) {
15 base::DictionaryValue* dict = new base::DictionaryValue();
16 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
17 it != routing_info.end(); ++it) {
18 dict->SetString(syncable::ModelTypeToString(it->first),
19 ModelSafeGroupToString(it->second));
20 }
21 return dict;
22 }
23
24 std::string ModelSafeRoutingInfoToString(
25 const ModelSafeRoutingInfo& routing_info) {
26 scoped_ptr<DictionaryValue> dict(ModelSafeRoutingInfoToValue(routing_info));
27 std::string json;
28 base::JSONWriter::Write(dict.get(), false, &json);
29 return json;
30 }
31
32 syncable::ModelTypeSet GetRoutingInfoTypes(
33 const ModelSafeRoutingInfo& routing_info) {
34 syncable::ModelTypeSet types;
35 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
36 it != routing_info.end(); ++it) {
37 types.Put(it->first);
38 }
39 return types;
40 }
41
42 ModelSafeGroup GetGroupForModelType(const syncable::ModelType type,
43 const ModelSafeRoutingInfo& routes) {
44 ModelSafeRoutingInfo::const_iterator it = routes.find(type);
45 if (it == routes.end()) {
46 if (type != syncable::UNSPECIFIED && type != syncable::TOP_LEVEL_FOLDER)
47 LOG(WARNING) << "Entry does not belong to active ModelSafeGroup!";
48 return GROUP_PASSIVE;
49 }
50 return it->second;
51 }
52
53 std::string ModelSafeGroupToString(ModelSafeGroup group) {
54 switch (group) {
55 case GROUP_UI:
56 return "GROUP_UI";
57 case GROUP_DB:
58 return "GROUP_DB";
59 case GROUP_FILE:
60 return "GROUP_FILE";
61 case GROUP_HISTORY:
62 return "GROUP_HISTORY";
63 case GROUP_PASSIVE:
64 return "GROUP_PASSIVE";
65 case GROUP_PASSWORD:
66 return "GROUP_PASSWORD";
67 default:
68 NOTREACHED();
69 return "INVALID";
70 }
71 }
72
73 ModelSafeWorker::~ModelSafeWorker() {}
74
75 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/model_safe_worker.h ('k') | chrome/browser/sync/engine/model_safe_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698