| 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/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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // This algorithm will not do well if the folder name has changes but the | 390 // This algorithm will not do well if the folder name has changes but the |
| 391 // children under them are all the same. | 391 // children under them are all the same. |
| 392 | 392 |
| 393 syncer::SyncError error; | 393 syncer::SyncError error; |
| 394 DCHECK(bookmark_model_->IsLoaded()); | 394 DCHECK(bookmark_model_->IsLoaded()); |
| 395 | 395 |
| 396 // To prime our association, we associate the top-level nodes, Bookmark Bar | 396 // To prime our association, we associate the top-level nodes, Bookmark Bar |
| 397 // and Other Bookmarks. | 397 // and Other Bookmarks. |
| 398 error = AssociateTaggedPermanentNode(bookmark_model_->other_node(), | 398 error = AssociateTaggedPermanentNode(bookmark_model_->other_node(), |
| 399 kOtherBookmarksTag); | 399 kOtherBookmarksTag); |
| 400 if (error.IsSet()) { | 400 if (error.IsSet()) |
| 401 return error; | 401 return error; |
| 402 } | |
| 403 | 402 |
| 404 error = AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(), | 403 error = AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(), |
| 405 kBookmarkBarTag); | 404 kBookmarkBarTag); |
| 406 if (error.IsSet()) { | 405 if (error.IsSet()) |
| 407 return error; | 406 return error; |
| 408 } | |
| 409 | 407 |
| 410 if (expect_mobile_bookmarks_folder_) { | 408 error = AssociateTaggedPermanentNode(bookmark_model_->mobile_node(), |
| 411 error = AssociateTaggedPermanentNode(bookmark_model_->mobile_node(), | 409 kMobileBookmarksTag); |
| 412 kMobileBookmarksTag); | 410 if (error.IsSet() && expect_mobile_bookmarks_folder_) |
| 413 if (error.IsSet()) { | 411 return error; |
| 414 return error; | 412 error = syncer::SyncError(); |
| 415 } | |
| 416 } | |
| 417 | 413 |
| 418 int64 bookmark_bar_sync_id = GetSyncIdFromChromeId( | 414 int64 bookmark_bar_sync_id = GetSyncIdFromChromeId( |
| 419 bookmark_model_->bookmark_bar_node()->id()); | 415 bookmark_model_->bookmark_bar_node()->id()); |
| 420 DCHECK_NE(bookmark_bar_sync_id, syncer::kInvalidId); | 416 DCHECK_NE(bookmark_bar_sync_id, syncer::kInvalidId); |
| 421 int64 other_bookmarks_sync_id = GetSyncIdFromChromeId( | 417 int64 other_bookmarks_sync_id = GetSyncIdFromChromeId( |
| 422 bookmark_model_->other_node()->id()); | 418 bookmark_model_->other_node()->id()); |
| 423 DCHECK_NE(other_bookmarks_sync_id, syncer::kInvalidId); | 419 DCHECK_NE(other_bookmarks_sync_id, syncer::kInvalidId); |
| 424 int64 mobile_bookmarks_sync_id = GetSyncIdFromChromeId( | 420 int64 mobile_bookmarks_sync_id = GetSyncIdFromChromeId( |
| 425 bookmark_model_->mobile_node()->id()); | 421 bookmark_model_->mobile_node()->id()); |
| 426 if (expect_mobile_bookmarks_folder_) { | 422 if (expect_mobile_bookmarks_folder_) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { | 659 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { |
| 664 // We only access the cryptographer while holding a transaction. | 660 // We only access the cryptographer while holding a transaction. |
| 665 syncer::ReadTransaction trans(FROM_HERE, user_share_); | 661 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
| 666 const syncer::ModelTypeSet encrypted_types = | 662 const syncer::ModelTypeSet encrypted_types = |
| 667 syncer::GetEncryptedTypes(&trans); | 663 syncer::GetEncryptedTypes(&trans); |
| 668 return !encrypted_types.Has(syncer::BOOKMARKS) || | 664 return !encrypted_types.Has(syncer::BOOKMARKS) || |
| 669 trans.GetCryptographer()->is_ready(); | 665 trans.GetCryptographer()->is_ready(); |
| 670 } | 666 } |
| 671 | 667 |
| 672 } // namespace browser_sync | 668 } // namespace browser_sync |
| OLD | NEW |