Chromium Code Reviews| 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 } | 705 } |
| 706 | 706 |
| 707 syncer::SyncError BookmarkModelAssociator::CheckModelSyncState() const { | 707 syncer::SyncError BookmarkModelAssociator::CheckModelSyncState() const { |
| 708 std::string version_str; | 708 std::string version_str; |
| 709 if (bookmark_model_->root_node()->GetMetaInfo(kBookmarkTransactionVersionKey, | 709 if (bookmark_model_->root_node()->GetMetaInfo(kBookmarkTransactionVersionKey, |
| 710 &version_str)) { | 710 &version_str)) { |
| 711 syncer::ReadTransaction trans(FROM_HERE, user_share_); | 711 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
| 712 int64 native_version = syncer::syncable::kInvalidTransactionVersion; | 712 int64 native_version = syncer::syncable::kInvalidTransactionVersion; |
| 713 int64 sync_version = trans.GetModelVersion(syncer::BOOKMARKS); | 713 int64 sync_version = trans.GetModelVersion(syncer::BOOKMARKS); |
| 714 if (base::StringToInt64(version_str, &native_version) && | 714 if (base::StringToInt64(version_str, &native_version) && |
| 715 native_version != sync_version) { | 715 (native_version != sync_version || native_version != 0)) { |
|
tim (not reviewing)
2013/07/01 21:10:18
So.. this is
!(native_version == sync_version &&
Nicolas Zea
2013/07/01 23:27:45
Done.
| |
| 716 UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", | 716 UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", |
| 717 ModelTypeToHistogramInt(syncer::BOOKMARKS), | 717 ModelTypeToHistogramInt(syncer::BOOKMARKS), |
| 718 syncer::MODEL_TYPE_COUNT); | 718 syncer::MODEL_TYPE_COUNT); |
| 719 | 719 |
| 720 // Clear version on bookmark model so that we only report error once. | 720 // Clear version on bookmark model so that we only report error once. |
| 721 bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), | 721 bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), |
| 722 kBookmarkTransactionVersionKey); | 722 kBookmarkTransactionVersionKey); |
| 723 | 723 |
| 724 // If the native version is higher, there was a sync persistence failure, | 724 // If the native version is higher, there was a sync persistence failure, |
| 725 // and we need to delay association until after a GetUpdates. | 725 // and we need to delay association until after a GetUpdates. |
| 726 if (sync_version < native_version) { | 726 if (sync_version < native_version || native_version != 0) { |
| 727 DVLOG(1) << "Native version (" << native_version << ") does not match " | 727 DVLOG(1) << "Native version (" << native_version << ") does not match " |
| 728 << "sync version (" << sync_version << ")."; | 728 << "sync version (" << sync_version << ")."; |
| 729 return syncer::SyncError(FROM_HERE, | 729 return syncer::SyncError(FROM_HERE, |
| 730 syncer::SyncError::PERSISTENCE_ERROR, | 730 syncer::SyncError::PERSISTENCE_ERROR, |
| 731 syncer::BOOKMARKS); | 731 syncer::BOOKMARKS); |
| 732 } | 732 } |
| 733 } | 733 } |
| 734 } | 734 } |
| 735 return syncer::SyncError(); | 735 return syncer::SyncError(); |
| 736 } | 736 } |
| 737 | 737 |
| 738 } // namespace browser_sync | 738 } // namespace browser_sync |
| OLD | NEW |