| 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 "components/sync_bookmarks/bookmark_model_associator.h" | 5 #include "components/sync_bookmarks/bookmark_model_associator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 bookmark_model_->root_node()->sync_transaction_version(); | 956 bookmark_model_->root_node()->sync_transaction_version(); |
| 957 | 957 |
| 958 syncer::ReadTransaction trans(FROM_HERE, user_share_); | 958 syncer::ReadTransaction trans(FROM_HERE, user_share_); |
| 959 int64_t sync_version = trans.GetModelVersion(syncer::BOOKMARKS); | 959 int64_t sync_version = trans.GetModelVersion(syncer::BOOKMARKS); |
| 960 context->SetPreAssociationVersions(native_version, sync_version); | 960 context->SetPreAssociationVersions(native_version, sync_version); |
| 961 | 961 |
| 962 if (native_version != syncer::syncable::kInvalidTransactionVersion) { | 962 if (native_version != syncer::syncable::kInvalidTransactionVersion) { |
| 963 if (native_version == sync_version) { | 963 if (native_version == sync_version) { |
| 964 context->set_native_model_sync_state(IN_SYNC); | 964 context->set_native_model_sync_state(IN_SYNC); |
| 965 } else { | 965 } else { |
| 966 // TODO(wychen): enum uma should be strongly typed. crbug.com/661401 |
| 966 UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", | 967 UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", |
| 967 ModelTypeToHistogramInt(syncer::BOOKMARKS), | 968 ModelTypeToHistogramInt(syncer::BOOKMARKS), |
| 968 syncer::MODEL_TYPE_COUNT); | 969 static_cast<int>(syncer::MODEL_TYPE_COUNT)); |
| 969 | 970 |
| 970 // Clear version on bookmark model so that we only report error once. | 971 // Clear version on bookmark model so that we only report error once. |
| 971 bookmark_model_->SetNodeSyncTransactionVersion( | 972 bookmark_model_->SetNodeSyncTransactionVersion( |
| 972 bookmark_model_->root_node(), | 973 bookmark_model_->root_node(), |
| 973 syncer::syncable::kInvalidTransactionVersion); | 974 syncer::syncable::kInvalidTransactionVersion); |
| 974 | 975 |
| 975 // If the native version is higher, there was a sync persistence failure, | 976 // If the native version is higher, there was a sync persistence failure, |
| 976 // and we need to delay association until after a GetUpdates. | 977 // and we need to delay association until after a GetUpdates. |
| 977 if (native_version > sync_version) { | 978 if (native_version > sync_version) { |
| 978 context->set_native_model_sync_state(AHEAD); | 979 context->set_native_model_sync_state(AHEAD); |
| 979 std::string message = base::StringPrintf( | 980 std::string message = base::StringPrintf( |
| 980 "Native version (%" PRId64 ") does not match sync version (%" | 981 "Native version (%" PRId64 ") does not match sync version (%" |
| 981 PRId64 ")", | 982 PRId64 ")", |
| 982 native_version, | 983 native_version, |
| 983 sync_version); | 984 sync_version); |
| 984 return syncer::SyncError(FROM_HERE, | 985 return syncer::SyncError(FROM_HERE, |
| 985 syncer::SyncError::PERSISTENCE_ERROR, | 986 syncer::SyncError::PERSISTENCE_ERROR, |
| 986 message, | 987 message, |
| 987 syncer::BOOKMARKS); | 988 syncer::BOOKMARKS); |
| 988 } else { | 989 } else { |
| 989 context->set_native_model_sync_state(BEHIND); | 990 context->set_native_model_sync_state(BEHIND); |
| 990 } | 991 } |
| 991 } | 992 } |
| 992 } | 993 } |
| 993 return syncer::SyncError(); | 994 return syncer::SyncError(); |
| 994 } | 995 } |
| 995 | 996 |
| 996 } // namespace sync_bookmarks | 997 } // namespace sync_bookmarks |
| OLD | NEW |