| 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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "sync/engine/sync_scheduler.h" | 19 #include "sync/engine/sync_scheduler.h" |
| 20 #include "sync/engine/syncer_types.h" | 20 #include "sync/engine/syncer_types.h" |
| 21 #include "sync/internal_api/change_reorder_buffer.h" | 21 #include "sync/internal_api/change_reorder_buffer.h" |
| 22 #include "sync/internal_api/public/base/cancelation_signal.h" | 22 #include "sync/internal_api/public/base/cancelation_signal.h" |
| 23 #include "sync/internal_api/public/base/invalidation_interface.h" |
| 23 #include "sync/internal_api/public/base/model_type.h" | 24 #include "sync/internal_api/public/base/model_type.h" |
| 24 #include "sync/internal_api/public/base_node.h" | 25 #include "sync/internal_api/public/base_node.h" |
| 25 #include "sync/internal_api/public/configure_reason.h" | 26 #include "sync/internal_api/public/configure_reason.h" |
| 26 #include "sync/internal_api/public/engine/polling_constants.h" | 27 #include "sync/internal_api/public/engine/polling_constants.h" |
| 27 #include "sync/internal_api/public/http_post_provider_factory.h" | 28 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 28 #include "sync/internal_api/public/internal_components_factory.h" | 29 #include "sync/internal_api/public/internal_components_factory.h" |
| 29 #include "sync/internal_api/public/read_node.h" | 30 #include "sync/internal_api/public/read_node.h" |
| 30 #include "sync/internal_api/public/read_transaction.h" | 31 #include "sync/internal_api/public/read_transaction.h" |
| 31 #include "sync/internal_api/public/sync_core_proxy.h" | 32 #include "sync/internal_api/public/sync_core_proxy.h" |
| 32 #include "sync/internal_api/public/user_share.h" | 33 #include "sync/internal_api/public/user_share.h" |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 const std::string& state_str = InvalidatorStateToString(state); | 968 const std::string& state_str = InvalidatorStateToString(state); |
| 968 invalidator_state_ = state; | 969 invalidator_state_ = state; |
| 969 DVLOG(1) << "Invalidator state changed to: " << state_str; | 970 DVLOG(1) << "Invalidator state changed to: " << state_str; |
| 970 const bool notifications_enabled = | 971 const bool notifications_enabled = |
| 971 (invalidator_state_ == INVALIDATIONS_ENABLED); | 972 (invalidator_state_ == INVALIDATIONS_ENABLED); |
| 972 allstatus_.SetNotificationsEnabled(notifications_enabled); | 973 allstatus_.SetNotificationsEnabled(notifications_enabled); |
| 973 scheduler_->SetNotificationsEnabled(notifications_enabled); | 974 scheduler_->SetNotificationsEnabled(notifications_enabled); |
| 974 } | 975 } |
| 975 | 976 |
| 976 void SyncManagerImpl::OnIncomingInvalidation( | 977 void SyncManagerImpl::OnIncomingInvalidation( |
| 977 const ObjectIdInvalidationMap& invalidation_map) { | 978 syncer::ModelType type, |
| 979 scoped_ptr<InvalidationInterface> invalidation) { |
| 978 DCHECK(thread_checker_.CalledOnValidThread()); | 980 DCHECK(thread_checker_.CalledOnValidThread()); |
| 979 | 981 |
| 980 // We should never receive IDs from non-sync objects. | 982 scheduler_->ScheduleInvalidationNudge( |
| 981 ObjectIdSet ids = invalidation_map.GetObjectIds(); | 983 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), |
| 982 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | 984 type, |
| 983 ModelType type; | 985 invalidation.Pass(), |
| 984 if (!ObjectIdToRealModelType(*it, &type)) { | 986 FROM_HERE); |
| 985 DLOG(WARNING) << "Notification has invalid id: " << ObjectIdToString(*it); | |
| 986 } | |
| 987 } | |
| 988 | |
| 989 if (invalidation_map.Empty()) { | |
| 990 LOG(WARNING) << "Sync received invalidation without any type information."; | |
| 991 } else { | |
| 992 scheduler_->ScheduleInvalidationNudge( | |
| 993 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), | |
| 994 invalidation_map, FROM_HERE); | |
| 995 debug_info_event_listener_.OnIncomingNotification(invalidation_map); | |
| 996 } | |
| 997 } | 987 } |
| 998 | 988 |
| 999 std::string SyncManagerImpl::GetOwnerName() const { return "SyncManagerImpl"; } | |
| 1000 | |
| 1001 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { | 989 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { |
| 1002 DCHECK(thread_checker_.CalledOnValidThread()); | 990 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1003 if (types.Empty()) { | 991 if (types.Empty()) { |
| 1004 LOG(WARNING) << "Sync received refresh request with no types specified."; | 992 LOG(WARNING) << "Sync received refresh request with no types specified."; |
| 1005 } else { | 993 } else { |
| 1006 scheduler_->ScheduleLocalRefreshRequest( | 994 scheduler_->ScheduleLocalRefreshRequest( |
| 1007 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), | 995 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), |
| 1008 types, FROM_HERE); | 996 types, FROM_HERE); |
| 1009 } | 997 } |
| 1010 } | 998 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1130 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1143 return kDefaultNudgeDelayMilliseconds; | 1131 return kDefaultNudgeDelayMilliseconds; |
| 1144 } | 1132 } |
| 1145 | 1133 |
| 1146 // static. | 1134 // static. |
| 1147 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1135 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1148 return kPreferencesNudgeDelayMilliseconds; | 1136 return kPreferencesNudgeDelayMilliseconds; |
| 1149 } | 1137 } |
| 1150 | 1138 |
| 1151 } // namespace syncer | 1139 } // namespace syncer |
| OLD | NEW |