Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 23238005: sync: Remove ModelTypeInvalidationMap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/model_type.h" 22 #include "sync/internal_api/public/base/model_type.h"
23 #include "sync/internal_api/public/base/model_type_invalidation_map.h"
24 #include "sync/internal_api/public/base_node.h" 23 #include "sync/internal_api/public/base_node.h"
25 #include "sync/internal_api/public/configure_reason.h" 24 #include "sync/internal_api/public/configure_reason.h"
26 #include "sync/internal_api/public/engine/polling_constants.h" 25 #include "sync/internal_api/public/engine/polling_constants.h"
27 #include "sync/internal_api/public/http_post_provider_factory.h" 26 #include "sync/internal_api/public/http_post_provider_factory.h"
28 #include "sync/internal_api/public/internal_components_factory.h" 27 #include "sync/internal_api/public/internal_components_factory.h"
29 #include "sync/internal_api/public/read_node.h" 28 #include "sync/internal_api/public/read_node.h"
30 #include "sync/internal_api/public/read_transaction.h" 29 #include "sync/internal_api/public/read_transaction.h"
31 #include "sync/internal_api/public/user_share.h" 30 #include "sync/internal_api/public/user_share.h"
32 #include "sync/internal_api/public/util/experiments.h" 31 #include "sync/internal_api/public/util/experiments.h"
33 #include "sync/internal_api/public/write_node.h" 32 #include "sync/internal_api/public/write_node.h"
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 id, &child_handles); 1144 id, &child_handles);
1146 for (syncable::Directory::Metahandles::const_iterator it = 1145 for (syncable::Directory::Metahandles::const_iterator it =
1147 child_handles.begin(); it != child_handles.end(); ++it) { 1146 child_handles.begin(); it != child_handles.end(); ++it) {
1148 child_ids->Append(new base::StringValue(base::Int64ToString(*it))); 1147 child_ids->Append(new base::StringValue(base::Int64ToString(*it)));
1149 } 1148 }
1150 } 1149 }
1151 return JsArgList(&return_args); 1150 return JsArgList(&return_args);
1152 } 1151 }
1153 1152
1154 void SyncManagerImpl::UpdateNotificationInfo( 1153 void SyncManagerImpl::UpdateNotificationInfo(
1155 const ModelTypeInvalidationMap& invalidation_map) { 1154 const ObjectIdInvalidationMap& invalidation_map) {
1156 for (ModelTypeInvalidationMap::const_iterator it = invalidation_map.begin(); 1155 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin();
1157 it != invalidation_map.end(); ++it) { 1156 it != invalidation_map.end(); ++it) {
1158 NotificationInfo* info = &notification_info_map_[it->first]; 1157 ModelType type;
tim (not reviewing) 2013/08/28 00:13:00 Initialize to UNSPECIFIED.
rlarocque 2013/08/28 01:00:35 Done.
1159 info->total_count++; 1158 if (ObjectIdToRealModelType(it->first, &type)) {
1160 info->payload = it->second.payload; 1159 NotificationInfo* info = &notification_info_map_[type];
1160 info->total_count++;
1161 info->payload = it->second.payload;
1162 }
1161 } 1163 }
1162 } 1164 }
1163 1165
1164 void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) { 1166 void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) {
1165 DCHECK(thread_checker_.CalledOnValidThread()); 1167 DCHECK(thread_checker_.CalledOnValidThread());
1166 1168
1167 const std::string& state_str = InvalidatorStateToString(state); 1169 const std::string& state_str = InvalidatorStateToString(state);
1168 invalidator_state_ = state; 1170 invalidator_state_ = state;
1169 DVLOG(1) << "Invalidator state changed to: " << state_str; 1171 DVLOG(1) << "Invalidator state changed to: " << state_str;
1170 const bool notifications_enabled = 1172 const bool notifications_enabled =
1171 (invalidator_state_ == INVALIDATIONS_ENABLED); 1173 (invalidator_state_ == INVALIDATIONS_ENABLED);
1172 allstatus_.SetNotificationsEnabled(notifications_enabled); 1174 allstatus_.SetNotificationsEnabled(notifications_enabled);
1173 scheduler_->SetNotificationsEnabled(notifications_enabled); 1175 scheduler_->SetNotificationsEnabled(notifications_enabled);
1174 1176
1175 if (js_event_handler_.IsInitialized()) { 1177 if (js_event_handler_.IsInitialized()) {
1176 base::DictionaryValue details; 1178 base::DictionaryValue details;
1177 details.SetString("state", state_str); 1179 details.SetString("state", state_str);
1178 js_event_handler_.Call(FROM_HERE, 1180 js_event_handler_.Call(FROM_HERE,
1179 &JsEventHandler::HandleJsEvent, 1181 &JsEventHandler::HandleJsEvent,
1180 "onNotificationStateChange", 1182 "onNotificationStateChange",
1181 JsEventDetails(&details)); 1183 JsEventDetails(&details));
1182 } 1184 }
1183 } 1185 }
1184 1186
1185 void SyncManagerImpl::OnIncomingInvalidation( 1187 void SyncManagerImpl::OnIncomingInvalidation(
1186 const ObjectIdInvalidationMap& invalidation_map) { 1188 const ObjectIdInvalidationMap& invalidation_map) {
1187 DCHECK(thread_checker_.CalledOnValidThread()); 1189 DCHECK(thread_checker_.CalledOnValidThread());
1188 1190
1189 const ModelTypeInvalidationMap& type_invalidation_map = 1191 if (invalidation_map.empty()) {
1190 ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map);
1191 if (type_invalidation_map.empty()) {
1192 LOG(WARNING) << "Sync received invalidation without any type information."; 1192 LOG(WARNING) << "Sync received invalidation without any type information.";
tim (not reviewing) 2013/08/28 00:13:00 Do we expect to be invoked here with non-sync Obje
rlarocque 2013/08/28 01:00:35 No, that should never happen.
tim (not reviewing) 2013/08/28 01:11:07 I ask just because before we were checking for tha
rlarocque 2013/08/28 17:50:22 Done. While we're on the subject, I also can't th
1193 } else { 1193 } else {
1194 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION); 1194 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION);
1195 scheduler_->ScheduleInvalidationNudge( 1195 scheduler_->ScheduleInvalidationNudge(
1196 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), 1196 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec),
1197 type_invalidation_map, FROM_HERE); 1197 invalidation_map, FROM_HERE);
1198 allstatus_.IncrementNotificationsReceived(); 1198 allstatus_.IncrementNotificationsReceived();
1199 UpdateNotificationInfo(type_invalidation_map); 1199 UpdateNotificationInfo(invalidation_map);
1200 debug_info_event_listener_.OnIncomingNotification(type_invalidation_map); 1200 debug_info_event_listener_.OnIncomingNotification(invalidation_map);
1201 } 1201 }
1202 1202
1203 if (js_event_handler_.IsInitialized()) { 1203 if (js_event_handler_.IsInitialized()) {
1204 base::DictionaryValue details; 1204 base::DictionaryValue details;
1205 base::ListValue* changed_types = new base::ListValue(); 1205 base::ListValue* changed_types = new base::ListValue();
1206 details.Set("changedTypes", changed_types); 1206 details.Set("changedTypes", changed_types);
1207 for (ModelTypeInvalidationMap::const_iterator it = 1207 ObjectIdSet id_set = ObjectIdInvalidationMapToSet(invalidation_map);
1208 type_invalidation_map.begin(); it != type_invalidation_map.end(); 1208 ModelTypeSet nudged_types = ObjectIdSetToModelTypeSet(id_set);
1209 ++it) { 1209 for (ModelTypeSet::Iterator it = nudged_types.First();
1210 const std::string& model_type_str = 1210 it.Good(); it.Inc()) {
1211 ModelTypeToString(it->first); 1211 const std::string& model_type_str = ModelTypeToString(it.Get());
tim (not reviewing) 2013/08/28 00:13:00 nit - I tend to prefer explicitly forcing the copy
rlarocque 2013/08/28 01:00:35 Fixed. Either way is OK with me.
1212 changed_types->Append(new base::StringValue(model_type_str)); 1212 changed_types->Append(new base::StringValue(model_type_str));
1213 } 1213 }
1214 details.SetString("source", "REMOTE_INVALIDATION"); 1214 details.SetString("source", "REMOTE_INVALIDATION");
1215 js_event_handler_.Call(FROM_HERE, 1215 js_event_handler_.Call(FROM_HERE,
1216 &JsEventHandler::HandleJsEvent, 1216 &JsEventHandler::HandleJsEvent,
1217 "onIncomingNotification", 1217 "onIncomingNotification",
1218 JsEventDetails(&details)); 1218 JsEventDetails(&details));
1219 } 1219 }
1220 } 1220 }
1221 1221
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 int SyncManagerImpl::GetDefaultNudgeDelay() { 1321 int SyncManagerImpl::GetDefaultNudgeDelay() {
1322 return kDefaultNudgeDelayMilliseconds; 1322 return kDefaultNudgeDelayMilliseconds;
1323 } 1323 }
1324 1324
1325 // static. 1325 // static.
1326 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1326 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1327 return kPreferencesNudgeDelayMilliseconds; 1327 return kPreferencesNudgeDelayMilliseconds;
1328 } 1328 }
1329 1329
1330 } // namespace syncer 1330 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698