OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/bookmark_model_associator.h" | 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return false; | 380 return false; |
381 | 381 |
382 Associate(permanent_node, sync_id); | 382 Associate(permanent_node, sync_id); |
383 return true; | 383 return true; |
384 } | 384 } |
385 | 385 |
386 bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, | 386 bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, |
387 int64* sync_id) { | 387 int64* sync_id) { |
388 syncer::ReadTransaction trans(FROM_HERE, user_share_); | 388 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
389 syncer::ReadNode sync_node(&trans); | 389 syncer::ReadNode sync_node(&trans); |
390 if (sync_node.InitByTagLookup(tag.c_str()) != syncer::BaseNode::INIT_OK) | 390 if (sync_node.InitByTagLookupForBookmarks( |
| 391 tag.c_str()) != syncer::BaseNode::INIT_OK) |
391 return false; | 392 return false; |
392 *sync_id = sync_node.GetId(); | 393 *sync_id = sync_node.GetId(); |
393 return true; | 394 return true; |
394 } | 395 } |
395 | 396 |
396 syncer::SyncError BookmarkModelAssociator::AssociateModels( | 397 syncer::SyncError BookmarkModelAssociator::AssociateModels( |
397 syncer::SyncMergeResult* local_merge_result, | 398 syncer::SyncMergeResult* local_merge_result, |
398 syncer::SyncMergeResult* syncer_merge_result) { | 399 syncer::SyncMergeResult* syncer_merge_result) { |
399 // Since any changes to the bookmark model made here are not user initiated, | 400 // Since any changes to the bookmark model made here are not user initiated, |
400 // these change should not be undoable and so suspend the undo tracking. | 401 // these change should not be undoable and so suspend the undo tracking. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // WARNING: The order in which we push these should match their order in the | 478 // WARNING: The order in which we push these should match their order in the |
478 // bookmark model (see BookmarkModel::DoneLoading(..)). | 479 // bookmark model (see BookmarkModel::DoneLoading(..)). |
479 std::stack<int64> dfs_stack; | 480 std::stack<int64> dfs_stack; |
480 dfs_stack.push(bookmark_bar_sync_id); | 481 dfs_stack.push(bookmark_bar_sync_id); |
481 dfs_stack.push(other_bookmarks_sync_id); | 482 dfs_stack.push(other_bookmarks_sync_id); |
482 if (mobile_bookmarks_sync_id != syncer::kInvalidId) | 483 if (mobile_bookmarks_sync_id != syncer::kInvalidId) |
483 dfs_stack.push(mobile_bookmarks_sync_id); | 484 dfs_stack.push(mobile_bookmarks_sync_id); |
484 | 485 |
485 syncer::WriteTransaction trans(FROM_HERE, user_share_); | 486 syncer::WriteTransaction trans(FROM_HERE, user_share_); |
486 syncer::ReadNode bm_root(&trans); | 487 syncer::ReadNode bm_root(&trans); |
487 if (bm_root.InitByTagLookup(syncer::ModelTypeToRootTag(syncer::BOOKMARKS)) == | 488 if (bm_root.InitTypeRoot(syncer::BOOKMARKS) == syncer::BaseNode::INIT_OK) { |
488 syncer::BaseNode::INIT_OK) { | |
489 syncer_merge_result->set_num_items_before_association( | 489 syncer_merge_result->set_num_items_before_association( |
490 bm_root.GetTotalNodeCount()); | 490 bm_root.GetTotalNodeCount()); |
491 } | 491 } |
492 local_merge_result->set_num_items_before_association( | 492 local_merge_result->set_num_items_before_association( |
493 bookmark_model_->root_node()->GetTotalNodeCount()); | 493 bookmark_model_->root_node()->GetTotalNodeCount()); |
494 | 494 |
495 // Remove obsolete bookmarks according to sync delete journal. | 495 // Remove obsolete bookmarks according to sync delete journal. |
496 local_merge_result->set_num_items_deleted( | 496 local_merge_result->set_num_items_deleted( |
497 ApplyDeletesFromSyncJournal(&trans)); | 497 ApplyDeletesFromSyncJournal(&trans)); |
498 | 498 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 syncer::SyncError::PERSISTENCE_ERROR, | 775 syncer::SyncError::PERSISTENCE_ERROR, |
776 message, | 776 message, |
777 syncer::BOOKMARKS); | 777 syncer::BOOKMARKS); |
778 } | 778 } |
779 } | 779 } |
780 } | 780 } |
781 return syncer::SyncError(); | 781 return syncer::SyncError(); |
782 } | 782 } |
783 | 783 |
784 } // namespace browser_sync | 784 } // namespace browser_sync |
OLD | NEW |