| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/sync_rollback_manager_base.h" | 5 #include "sync/internal_api/sync_rollback_manager_base.h" |
| 6 | 6 |
| 7 #include "sync/internal_api/public/base/model_type.h" | 7 #include "sync/internal_api/public/base/model_type.h" |
| 8 #include "sync/internal_api/public/internal_components_factory.h" | 8 #include "sync/internal_api/public/internal_components_factory.h" |
| 9 #include "sync/internal_api/public/read_node.h" | 9 #include "sync/internal_api/public/read_node.h" |
| 10 #include "sync/internal_api/public/read_transaction.h" | 10 #include "sync/internal_api/public/read_transaction.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 NULL)); | 271 NULL)); |
| 272 return syncable::OPENED == | 272 return syncable::OPENED == |
| 273 share_.directory->Open( | 273 share_.directory->Open( |
| 274 "backup", this, | 274 "backup", this, |
| 275 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr())); | 275 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr())); |
| 276 } | 276 } |
| 277 | 277 |
| 278 bool SyncRollbackManagerBase::InitTypeRootNode(ModelType type) { | 278 bool SyncRollbackManagerBase::InitTypeRootNode(ModelType type) { |
| 279 WriteTransaction trans(FROM_HERE, &share_); | 279 WriteTransaction trans(FROM_HERE, &share_); |
| 280 ReadNode root(&trans); | 280 ReadNode root(&trans); |
| 281 if (BaseNode::INIT_OK == root.InitByTagLookup(ModelTypeToRootTag(type))) | 281 if (BaseNode::INIT_OK == root.InitTypeRoot(type)) |
| 282 return true; | 282 return true; |
| 283 | 283 |
| 284 syncable::MutableEntry entry(trans.GetWrappedWriteTrans(), | 284 syncable::MutableEntry entry(trans.GetWrappedWriteTrans(), |
| 285 syncable::CREATE_NEW_UPDATE_ITEM, | 285 syncable::CREATE_NEW_UPDATE_ITEM, |
| 286 syncable::Id::CreateFromServerId( | 286 syncable::Id::CreateFromServerId( |
| 287 ModelTypeToString(type))); | 287 ModelTypeToString(type))); |
| 288 if (!entry.good()) | 288 if (!entry.good()) |
| 289 return false; | 289 return false; |
| 290 | 290 |
| 291 entry.PutParentId(syncable::Id()); | 291 entry.PutParentId(syncable::Id()); |
| 292 entry.PutBaseVersion(1); | 292 entry.PutBaseVersion(1); |
| 293 entry.PutUniqueServerTag(ModelTypeToRootTag(type)); | 293 entry.PutUniqueServerTag(ModelTypeToRootTag(type)); |
| 294 entry.PutNonUniqueName(ModelTypeToString(type)); | 294 entry.PutNonUniqueName(ModelTypeToString(type)); |
| 295 entry.PutIsDel(false); | 295 entry.PutIsDel(false); |
| 296 entry.PutIsDir(true); | 296 entry.PutIsDir(true); |
| 297 | 297 |
| 298 sync_pb::EntitySpecifics specifics; | 298 sync_pb::EntitySpecifics specifics; |
| 299 AddDefaultFieldValue(type, &specifics); | 299 AddDefaultFieldValue(type, &specifics); |
| 300 entry.PutSpecifics(specifics); | 300 entry.PutSpecifics(specifics); |
| 301 | 301 |
| 302 return true; | 302 return true; |
| 303 } | 303 } |
| 304 | 304 |
| 305 void SyncRollbackManagerBase::InitBookmarkFolder(const std::string& folder) { | 305 void SyncRollbackManagerBase::InitBookmarkFolder(const std::string& folder) { |
| 306 WriteTransaction trans(FROM_HERE, &share_); | 306 WriteTransaction trans(FROM_HERE, &share_); |
| 307 syncable::Entry bookmark_root(trans.GetWrappedTrans(), | 307 syncable::Entry bookmark_root(trans.GetWrappedTrans(), |
| 308 syncable::GET_BY_SERVER_TAG, | 308 syncable::GET_TYPE_ROOT, |
| 309 ModelTypeToRootTag(BOOKMARKS)); | 309 BOOKMARKS); |
| 310 if (!bookmark_root.good()) | 310 if (!bookmark_root.good()) |
| 311 return; | 311 return; |
| 312 | 312 |
| 313 syncable::MutableEntry entry(trans.GetWrappedWriteTrans(), | 313 syncable::MutableEntry entry(trans.GetWrappedWriteTrans(), |
| 314 syncable::CREATE_NEW_UPDATE_ITEM, | 314 syncable::CREATE_NEW_UPDATE_ITEM, |
| 315 syncable::Id::CreateFromServerId(folder)); | 315 syncable::Id::CreateFromServerId(folder)); |
| 316 if (!entry.good()) | 316 if (!entry.good()) |
| 317 return; | 317 return; |
| 318 | 318 |
| 319 entry.PutParentId(bookmark_root.GetId()); | 319 entry.PutParentId(bookmark_root.GetId()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 337 | 337 |
| 338 void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver( | 338 void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver( |
| 339 syncer::TypeDebugInfoObserver* observer) {} | 339 syncer::TypeDebugInfoObserver* observer) {} |
| 340 | 340 |
| 341 bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver( | 341 bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver( |
| 342 syncer::TypeDebugInfoObserver* observer) { return false; } | 342 syncer::TypeDebugInfoObserver* observer) { return false; } |
| 343 | 343 |
| 344 void SyncRollbackManagerBase::RequestEmitDebugInfo() {} | 344 void SyncRollbackManagerBase::RequestEmitDebugInfo() {} |
| 345 | 345 |
| 346 } // namespace syncer | 346 } // namespace syncer |
| OLD | NEW |