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

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: Sort entries in gyp files 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
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = UNSPECIFIED;
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 // We should never receive IDs from non-sync objects.
1190 ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map); 1192 ObjectIdSet ids = ObjectIdInvalidationMapToSet(invalidation_map);
1191 if (type_invalidation_map.empty()) { 1193 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
1194 ModelType type;
1195 if (!ObjectIdToRealModelType(*it, &type)) {
1196 DLOG(WARNING) << "Notification has invalid id: " << ObjectIdToString(*it);
1197 }
1198 }
1199
1200 if (invalidation_map.empty()) {
1192 LOG(WARNING) << "Sync received invalidation without any type information."; 1201 LOG(WARNING) << "Sync received invalidation without any type information.";
1193 } else { 1202 } else {
1194 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION); 1203 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION);
1195 scheduler_->ScheduleInvalidationNudge( 1204 scheduler_->ScheduleInvalidationNudge(
1196 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), 1205 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec),
1197 type_invalidation_map, FROM_HERE); 1206 invalidation_map, FROM_HERE);
1198 allstatus_.IncrementNotificationsReceived(); 1207 allstatus_.IncrementNotificationsReceived();
1199 UpdateNotificationInfo(type_invalidation_map); 1208 UpdateNotificationInfo(invalidation_map);
1200 debug_info_event_listener_.OnIncomingNotification(type_invalidation_map); 1209 debug_info_event_listener_.OnIncomingNotification(invalidation_map);
1201 } 1210 }
1202 1211
1203 if (js_event_handler_.IsInitialized()) { 1212 if (js_event_handler_.IsInitialized()) {
1204 base::DictionaryValue details; 1213 base::DictionaryValue details;
1205 base::ListValue* changed_types = new base::ListValue(); 1214 base::ListValue* changed_types = new base::ListValue();
1206 details.Set("changedTypes", changed_types); 1215 details.Set("changedTypes", changed_types);
1207 for (ModelTypeInvalidationMap::const_iterator it = 1216 ObjectIdSet id_set = ObjectIdInvalidationMapToSet(invalidation_map);
1208 type_invalidation_map.begin(); it != type_invalidation_map.end(); 1217 ModelTypeSet nudged_types = ObjectIdSetToModelTypeSet(id_set);
1209 ++it) { 1218 DCHECK(!nudged_types.Empty());
1210 const std::string& model_type_str = 1219 for (ModelTypeSet::Iterator it = nudged_types.First();
1211 ModelTypeToString(it->first); 1220 it.Good(); it.Inc()) {
1221 const std::string model_type_str = ModelTypeToString(it.Get());
1212 changed_types->Append(new base::StringValue(model_type_str)); 1222 changed_types->Append(new base::StringValue(model_type_str));
1213 } 1223 }
1214 details.SetString("source", "REMOTE_INVALIDATION"); 1224 details.SetString("source", "REMOTE_INVALIDATION");
1215 js_event_handler_.Call(FROM_HERE, 1225 js_event_handler_.Call(FROM_HERE,
1216 &JsEventHandler::HandleJsEvent, 1226 &JsEventHandler::HandleJsEvent,
1217 "onIncomingNotification", 1227 "onIncomingNotification",
1218 JsEventDetails(&details)); 1228 JsEventDetails(&details));
1219 } 1229 }
1220 } 1230 }
1221 1231
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 int SyncManagerImpl::GetDefaultNudgeDelay() { 1331 int SyncManagerImpl::GetDefaultNudgeDelay() {
1322 return kDefaultNudgeDelayMilliseconds; 1332 return kDefaultNudgeDelayMilliseconds;
1323 } 1333 }
1324 1334
1325 // static. 1335 // static.
1326 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1336 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1327 return kPreferencesNudgeDelayMilliseconds; 1337 return kPreferencesNudgeDelayMilliseconds;
1328 } 1338 }
1329 1339
1330 } // namespace syncer 1340 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698