| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 journals_to_purge.insert(bk_delete_journals[i].id); | 638 journals_to_purge.insert(bk_delete_journals[i].id); |
| 639 syncer::DeleteJournal::PurgeDeleteJournals(trans, journals_to_purge); | 639 syncer::DeleteJournal::PurgeDeleteJournals(trans, journals_to_purge); |
| 640 | 640 |
| 641 return num_bookmark_deleted; | 641 return num_bookmark_deleted; |
| 642 } | 642 } |
| 643 | 643 |
| 644 void BookmarkModelAssociator::PostPersistAssociationsTask() { | 644 void BookmarkModelAssociator::PostPersistAssociationsTask() { |
| 645 // No need to post a task if a task is already pending. | 645 // No need to post a task if a task is already pending. |
| 646 if (weak_factory_.HasWeakPtrs()) | 646 if (weak_factory_.HasWeakPtrs()) |
| 647 return; | 647 return; |
| 648 MessageLoop::current()->PostTask( | 648 base::MessageLoop::current()->PostTask( |
| 649 FROM_HERE, | 649 FROM_HERE, |
| 650 base::Bind( | 650 base::Bind(&BookmarkModelAssociator::PersistAssociations, |
| 651 &BookmarkModelAssociator::PersistAssociations, | 651 weak_factory_.GetWeakPtr())); |
| 652 weak_factory_.GetWeakPtr())); | |
| 653 } | 652 } |
| 654 | 653 |
| 655 void BookmarkModelAssociator::PersistAssociations() { | 654 void BookmarkModelAssociator::PersistAssociations() { |
| 656 // If there are no dirty associations we have nothing to do. We handle this | 655 // If there are no dirty associations we have nothing to do. We handle this |
| 657 // explicity instead of letting the for loop do it to avoid creating a write | 656 // explicity instead of letting the for loop do it to avoid creating a write |
| 658 // transaction in this case. | 657 // transaction in this case. |
| 659 if (dirty_associations_sync_ids_.empty()) { | 658 if (dirty_associations_sync_ids_.empty()) { |
| 660 DCHECK(id_map_.empty()); | 659 DCHECK(id_map_.empty()); |
| 661 DCHECK(id_map_inverse_.empty()); | 660 DCHECK(id_map_inverse_.empty()); |
| 662 return; | 661 return; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 ModelTypeToHistogramInt(syncer::BOOKMARKS), | 711 ModelTypeToHistogramInt(syncer::BOOKMARKS), |
| 713 syncer::MODEL_TYPE_COUNT); | 712 syncer::MODEL_TYPE_COUNT); |
| 714 // Clear version on bookmark model so that we only report error once. | 713 // Clear version on bookmark model so that we only report error once. |
| 715 bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), | 714 bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), |
| 716 kBookmarkTransactionVersionKey); | 715 kBookmarkTransactionVersionKey); |
| 717 } | 716 } |
| 718 } | 717 } |
| 719 } | 718 } |
| 720 | 719 |
| 721 } // namespace browser_sync | 720 } // namespace browser_sync |
| OLD | NEW |