OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/sessions/nudge_tracker.h" | 5 #include "sync/sessions/nudge_tracker.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "sync/internal_api/public/base/invalidation.h" | 8 #include "sync/internal_api/public/base/invalidation.h" |
| 9 #include "sync/notifier/invalidation_util.h" |
| 10 #include "sync/notifier/object_id_invalidation_map.h" |
9 #include "sync/protocol/sync.pb.h" | 11 #include "sync/protocol/sync.pb.h" |
10 | 12 |
11 namespace syncer { | 13 namespace syncer { |
12 namespace sessions { | 14 namespace sessions { |
13 | 15 |
14 size_t NudgeTracker::kDefaultMaxPayloadsPerType = 10; | 16 size_t NudgeTracker::kDefaultMaxPayloadsPerType = 10; |
15 | 17 |
16 NudgeTracker::NudgeTracker() | 18 NudgeTracker::NudgeTracker() |
17 : updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN), | 19 : updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN), |
18 invalidations_enabled_(false), | 20 invalidations_enabled_(false), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 updates_source_ = sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH; | 86 updates_source_ = sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH; |
85 } | 87 } |
86 | 88 |
87 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { | 89 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { |
88 DCHECK(type_trackers_.find(it.Get()) != type_trackers_.end()); | 90 DCHECK(type_trackers_.find(it.Get()) != type_trackers_.end()); |
89 type_trackers_[it.Get()].RecordLocalRefreshRequest(); | 91 type_trackers_[it.Get()].RecordLocalRefreshRequest(); |
90 } | 92 } |
91 } | 93 } |
92 | 94 |
93 void NudgeTracker::RecordRemoteInvalidation( | 95 void NudgeTracker::RecordRemoteInvalidation( |
94 const ModelTypeInvalidationMap& invalidation_map) { | 96 const ObjectIdInvalidationMap& invalidation_map) { |
95 updates_source_ = sync_pb::GetUpdatesCallerInfo::NOTIFICATION; | 97 updates_source_ = sync_pb::GetUpdatesCallerInfo::NOTIFICATION; |
96 | 98 |
97 for (ModelTypeInvalidationMap::const_iterator i = invalidation_map.begin(); | 99 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); |
98 i != invalidation_map.end(); ++i) { | 100 it != invalidation_map.end(); ++it) { |
99 const ModelType type = i->first; | 101 ModelType type; |
100 const std::string& payload = i->second.payload; | 102 if (!ObjectIdToRealModelType(it->first, &type)) { |
| 103 NOTREACHED() |
| 104 << "Object ID " << ObjectIdToString(it->first) |
| 105 << " does not map to valid model type"; |
| 106 } |
101 DCHECK(type_trackers_.find(type) != type_trackers_.end()); | 107 DCHECK(type_trackers_.find(type) != type_trackers_.end()); |
102 type_trackers_[type].RecordRemoteInvalidation(payload); | 108 type_trackers_[type].RecordRemoteInvalidation(it->second.payload); |
103 } | 109 } |
104 } | 110 } |
105 | 111 |
106 void NudgeTracker::OnInvalidationsEnabled() { | 112 void NudgeTracker::OnInvalidationsEnabled() { |
107 invalidations_enabled_ = true; | 113 invalidations_enabled_ = true; |
108 } | 114 } |
109 | 115 |
110 void NudgeTracker::OnInvalidationsDisabled() { | 116 void NudgeTracker::OnInvalidationsDisabled() { |
111 invalidations_enabled_ = false; | 117 invalidations_enabled_ = false; |
112 invalidations_out_of_sync_ = true; | 118 invalidations_out_of_sync_ = true; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 207 |
202 void NudgeTracker::SetHintBufferSize(size_t size) { | 208 void NudgeTracker::SetHintBufferSize(size_t size) { |
203 for (TypeTrackerMap::iterator it = type_trackers_.begin(); | 209 for (TypeTrackerMap::iterator it = type_trackers_.begin(); |
204 it != type_trackers_.end(); ++it) { | 210 it != type_trackers_.end(); ++it) { |
205 it->second.UpdatePayloadBufferSize(size); | 211 it->second.UpdatePayloadBufferSize(size); |
206 } | 212 } |
207 } | 213 } |
208 | 214 |
209 } // namespace sessions | 215 } // namespace sessions |
210 } // namespace syncer | 216 } // namespace syncer |
OLD | NEW |