| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 void SyncedDeviceTracker::WriteDeviceInfo( | 173 void SyncedDeviceTracker::WriteDeviceInfo( |
| 174 const sync_pb::DeviceInfoSpecifics& specifics, | 174 const sync_pb::DeviceInfoSpecifics& specifics, |
| 175 const std::string& tag) { | 175 const std::string& tag) { |
| 176 syncer::WriteTransaction trans(FROM_HERE, user_share_); | 176 syncer::WriteTransaction trans(FROM_HERE, user_share_); |
| 177 syncer::WriteNode node(&trans); | 177 syncer::WriteNode node(&trans); |
| 178 | 178 |
| 179 if (node.InitByClientTagLookup(syncer::DEVICE_INFO, tag) == | 179 if (node.InitByClientTagLookup(syncer::DEVICE_INFO, tag) == |
| 180 syncer::BaseNode::INIT_OK) { | 180 syncer::BaseNode::INIT_OK) { |
| 181 node.SetDeviceInfoSpecifics(specifics); | 181 node.SetDeviceInfoSpecifics(specifics); |
| 182 node.SetTitle(UTF8ToWide(specifics.client_name())); | 182 node.SetTitle(base::UTF8ToWide(specifics.client_name())); |
| 183 } else { | 183 } else { |
| 184 syncer::ReadNode type_root(&trans); | 184 syncer::ReadNode type_root(&trans); |
| 185 syncer::BaseNode::InitByLookupResult type_root_lookup_result = | 185 syncer::BaseNode::InitByLookupResult type_root_lookup_result = |
| 186 type_root.InitByTagLookup(ModelTypeToRootTag(syncer::DEVICE_INFO)); | 186 type_root.InitByTagLookup(ModelTypeToRootTag(syncer::DEVICE_INFO)); |
| 187 DCHECK_EQ(syncer::BaseNode::INIT_OK, type_root_lookup_result); | 187 DCHECK_EQ(syncer::BaseNode::INIT_OK, type_root_lookup_result); |
| 188 | 188 |
| 189 syncer::WriteNode new_node(&trans); | 189 syncer::WriteNode new_node(&trans); |
| 190 syncer::WriteNode::InitUniqueByCreationResult create_result = | 190 syncer::WriteNode::InitUniqueByCreationResult create_result = |
| 191 new_node.InitUniqueByCreation(syncer::DEVICE_INFO, | 191 new_node.InitUniqueByCreation(syncer::DEVICE_INFO, |
| 192 type_root, | 192 type_root, |
| 193 tag); | 193 tag); |
| 194 DCHECK_EQ(syncer::WriteNode::INIT_SUCCESS, create_result); | 194 DCHECK_EQ(syncer::WriteNode::INIT_SUCCESS, create_result); |
| 195 new_node.SetDeviceInfoSpecifics(specifics); | 195 new_node.SetDeviceInfoSpecifics(specifics); |
| 196 new_node.SetTitle(UTF8ToWide(specifics.client_name())); | 196 new_node.SetTitle(base::UTF8ToWide(specifics.client_name())); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace browser_sync | 200 } // namespace browser_sync |
| OLD | NEW |