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_context.h" | 32 #include "sync/internal_api/public/sync_context.h" |
32 #include "sync/internal_api/public/sync_context_proxy.h" | 33 #include "sync/internal_api/public/sync_context_proxy.h" |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 const std::string& state_str = InvalidatorStateToString(state); | 973 const std::string& state_str = InvalidatorStateToString(state); |
973 invalidator_state_ = state; | 974 invalidator_state_ = state; |
974 DVLOG(1) << "Invalidator state changed to: " << state_str; | 975 DVLOG(1) << "Invalidator state changed to: " << state_str; |
975 const bool notifications_enabled = | 976 const bool notifications_enabled = |
976 (invalidator_state_ == INVALIDATIONS_ENABLED); | 977 (invalidator_state_ == INVALIDATIONS_ENABLED); |
977 allstatus_.SetNotificationsEnabled(notifications_enabled); | 978 allstatus_.SetNotificationsEnabled(notifications_enabled); |
978 scheduler_->SetNotificationsEnabled(notifications_enabled); | 979 scheduler_->SetNotificationsEnabled(notifications_enabled); |
979 } | 980 } |
980 | 981 |
981 void SyncManagerImpl::OnIncomingInvalidation( | 982 void SyncManagerImpl::OnIncomingInvalidation( |
982 const ObjectIdInvalidationMap& invalidation_map) { | 983 syncer::ModelType type, |
| 984 scoped_ptr<InvalidationInterface> invalidation) { |
983 DCHECK(thread_checker_.CalledOnValidThread()); | 985 DCHECK(thread_checker_.CalledOnValidThread()); |
984 | 986 |
985 // We should never receive IDs from non-sync objects. | 987 scheduler_->ScheduleInvalidationNudge( |
986 ObjectIdSet ids = invalidation_map.GetObjectIds(); | 988 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), |
987 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | 989 type, |
988 ModelType type; | 990 invalidation.Pass(), |
989 if (!ObjectIdToRealModelType(*it, &type)) { | 991 FROM_HERE); |
990 DLOG(WARNING) << "Notification has invalid id: " << ObjectIdToString(*it); | |
991 } | |
992 } | |
993 | |
994 if (invalidation_map.Empty()) { | |
995 LOG(WARNING) << "Sync received invalidation without any type information."; | |
996 } else { | |
997 scheduler_->ScheduleInvalidationNudge( | |
998 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), | |
999 invalidation_map, FROM_HERE); | |
1000 debug_info_event_listener_.OnIncomingNotification(invalidation_map); | |
1001 } | |
1002 } | 992 } |
1003 | 993 |
1004 std::string SyncManagerImpl::GetOwnerName() const { return "SyncManagerImpl"; } | |
1005 | |
1006 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { | 994 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { |
1007 DCHECK(thread_checker_.CalledOnValidThread()); | 995 DCHECK(thread_checker_.CalledOnValidThread()); |
1008 if (types.Empty()) { | 996 if (types.Empty()) { |
1009 LOG(WARNING) << "Sync received refresh request with no types specified."; | 997 LOG(WARNING) << "Sync received refresh request with no types specified."; |
1010 } else { | 998 } else { |
1011 scheduler_->ScheduleLocalRefreshRequest( | 999 scheduler_->ScheduleLocalRefreshRequest( |
1012 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), | 1000 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), |
1013 types, FROM_HERE); | 1001 types, FROM_HERE); |
1014 } | 1002 } |
1015 } | 1003 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1135 int SyncManagerImpl::GetDefaultNudgeDelay() { |
1148 return kDefaultNudgeDelayMilliseconds; | 1136 return kDefaultNudgeDelayMilliseconds; |
1149 } | 1137 } |
1150 | 1138 |
1151 // static. | 1139 // static. |
1152 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1140 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
1153 return kPreferencesNudgeDelayMilliseconds; | 1141 return kPreferencesNudgeDelayMilliseconds; |
1154 } | 1142 } |
1155 | 1143 |
1156 } // namespace syncer | 1144 } // namespace syncer |
OLD | NEW |