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 "chrome/browser/sync/glue/synced_device_tracker.h" | 5 #include "chrome/browser/sync/glue/synced_device_tracker.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/sync/glue/device_info.h" | 9 #include "chrome/browser/sync/glue/device_info.h" |
10 #include "sync/internal_api/public/base/model_type.h" | 10 #include "sync/internal_api/public/base/model_type.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void SyncedDeviceTracker::GetAllSyncedDeviceInfo( | 97 void SyncedDeviceTracker::GetAllSyncedDeviceInfo( |
98 ScopedVector<DeviceInfo>* device_info) const { | 98 ScopedVector<DeviceInfo>* device_info) const { |
99 if (device_info == NULL) | 99 if (device_info == NULL) |
100 return; | 100 return; |
101 | 101 |
102 device_info->clear(); | 102 device_info->clear(); |
103 | 103 |
104 syncer::ReadTransaction trans(FROM_HERE, user_share_); | 104 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
105 syncer::ReadNode root_node(&trans); | 105 syncer::ReadNode root_node(&trans); |
106 | 106 |
107 if (root_node.InitByTagLookup( | 107 if (root_node.InitTypeRoot(syncer::DEVICE_INFO) != |
108 syncer::ModelTypeToRootTag(syncer::DEVICE_INFO)) != | |
109 syncer::BaseNode::INIT_OK) { | 108 syncer::BaseNode::INIT_OK) { |
110 return; | 109 return; |
111 } | 110 } |
112 | 111 |
113 // Get all the children of the root node and use the child id to read | 112 // Get all the children of the root node and use the child id to read |
114 // device info for devices. | 113 // device info for devices. |
115 std::vector<int64> children; | 114 std::vector<int64> children; |
116 root_node.GetChildIds(&children); | 115 root_node.GetChildIds(&children); |
117 | 116 |
118 for (std::vector<int64>::const_iterator it = children.begin(); | 117 for (std::vector<int64>::const_iterator it = children.begin(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 syncer::WriteTransaction trans(FROM_HERE, user_share_); | 174 syncer::WriteTransaction trans(FROM_HERE, user_share_); |
176 syncer::WriteNode node(&trans); | 175 syncer::WriteNode node(&trans); |
177 | 176 |
178 if (node.InitByClientTagLookup(syncer::DEVICE_INFO, tag) == | 177 if (node.InitByClientTagLookup(syncer::DEVICE_INFO, tag) == |
179 syncer::BaseNode::INIT_OK) { | 178 syncer::BaseNode::INIT_OK) { |
180 node.SetDeviceInfoSpecifics(specifics); | 179 node.SetDeviceInfoSpecifics(specifics); |
181 node.SetTitle(specifics.client_name()); | 180 node.SetTitle(specifics.client_name()); |
182 } else { | 181 } else { |
183 syncer::ReadNode type_root(&trans); | 182 syncer::ReadNode type_root(&trans); |
184 syncer::BaseNode::InitByLookupResult type_root_lookup_result = | 183 syncer::BaseNode::InitByLookupResult type_root_lookup_result = |
185 type_root.InitByTagLookup(ModelTypeToRootTag(syncer::DEVICE_INFO)); | 184 type_root.InitTypeRoot(syncer::DEVICE_INFO); |
186 DCHECK_EQ(syncer::BaseNode::INIT_OK, type_root_lookup_result); | 185 DCHECK_EQ(syncer::BaseNode::INIT_OK, type_root_lookup_result); |
187 | 186 |
188 syncer::WriteNode new_node(&trans); | 187 syncer::WriteNode new_node(&trans); |
189 syncer::WriteNode::InitUniqueByCreationResult create_result = | 188 syncer::WriteNode::InitUniqueByCreationResult create_result = |
190 new_node.InitUniqueByCreation(syncer::DEVICE_INFO, | 189 new_node.InitUniqueByCreation(syncer::DEVICE_INFO, |
191 type_root, | 190 type_root, |
192 tag); | 191 tag); |
193 DCHECK_EQ(syncer::WriteNode::INIT_SUCCESS, create_result); | 192 DCHECK_EQ(syncer::WriteNode::INIT_SUCCESS, create_result); |
194 new_node.SetDeviceInfoSpecifics(specifics); | 193 new_node.SetDeviceInfoSpecifics(specifics); |
195 new_node.SetTitle(specifics.client_name()); | 194 new_node.SetTitle(specifics.client_name()); |
196 } | 195 } |
197 } | 196 } |
198 | 197 |
199 } // namespace browser_sync | 198 } // namespace browser_sync |
OLD | NEW |