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

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

Issue 12022041: Separate local and remote sync invalidations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments Created 7 years, 10 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"
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 JsEventDetails(&details)); 1240 JsEventDetails(&details));
1241 } 1241 }
1242 } 1242 }
1243 1243
1244 void SyncManagerImpl::OnIncomingInvalidation( 1244 void SyncManagerImpl::OnIncomingInvalidation(
1245 const ObjectIdInvalidationMap& invalidation_map, 1245 const ObjectIdInvalidationMap& invalidation_map,
1246 IncomingInvalidationSource source) { 1246 IncomingInvalidationSource source) {
1247 DCHECK(thread_checker_.CalledOnValidThread()); 1247 DCHECK(thread_checker_.CalledOnValidThread());
1248 const ModelTypeInvalidationMap& type_invalidation_map = 1248 const ModelTypeInvalidationMap& type_invalidation_map =
1249 ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map); 1249 ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map);
1250 if (source == LOCAL_INVALIDATION) { 1250 if (type_invalidation_map.empty()) {
1251 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_LOCAL_REFRESH); 1251 LOG(WARNING) << "Sync received invalidation without any type information.";
1252 scheduler_->ScheduleNudgeWithStatesAsync( 1252 } else {
1253 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec),
1254 NUDGE_SOURCE_LOCAL_REFRESH,
1255 type_invalidation_map, FROM_HERE);
1256 } else if (!type_invalidation_map.empty()) {
1257 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION); 1253 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_NOTIFICATION);
1258 scheduler_->ScheduleNudgeWithStatesAsync( 1254 scheduler_->ScheduleNudgeWithStatesAsync(
1259 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), 1255 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec),
1260 NUDGE_SOURCE_NOTIFICATION, 1256 NUDGE_SOURCE_NOTIFICATION,
1261 type_invalidation_map, FROM_HERE); 1257 type_invalidation_map, FROM_HERE);
1262 allstatus_.IncrementNotificationsReceived(); 1258 allstatus_.IncrementNotificationsReceived();
1263 UpdateNotificationInfo(type_invalidation_map); 1259 UpdateNotificationInfo(type_invalidation_map);
1264 debug_info_event_listener_.OnIncomingNotification(type_invalidation_map); 1260 debug_info_event_listener_.OnIncomingNotification(type_invalidation_map);
1265 } else {
1266 LOG(WARNING) << "Sync received invalidation without any type information.";
1267 } 1261 }
1268 1262
1269 if (js_event_handler_.IsInitialized()) { 1263 if (js_event_handler_.IsInitialized()) {
1264 DictionaryValue details;
1265 ListValue* changed_types = new ListValue();
1266 details.Set("changedTypes", changed_types);
1267 for (ModelTypeInvalidationMap::const_iterator it =
1268 type_invalidation_map.begin(); it != type_invalidation_map.end();
1269 ++it) {
1270 const std::string& model_type_str =
1271 ModelTypeToString(it->first);
1272 changed_types->Append(Value::CreateStringValue(model_type_str));
1273 }
1274 details.SetString("source", "REMOTE_INVALIDATION");
1275 js_event_handler_.Call(FROM_HERE,
1276 &JsEventHandler::HandleJsEvent,
1277 "onIncomingNotification",
1278 JsEventDetails(&details));
1279 }
1280 }
1281
1282 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) {
1283 DCHECK(thread_checker_.CalledOnValidThread());
1284 const ModelTypeInvalidationMap& type_invalidation_map =
1285 ModelTypeSetToInvalidationMap(types, "");
1286 if (type_invalidation_map.empty()) {
1287 LOG(WARNING) << "Sync received refresh request with no types specified.";
1288 } else {
1289 allstatus_.IncrementNudgeCounter(NUDGE_SOURCE_LOCAL_REFRESH);
1290 scheduler_->ScheduleNudgeWithStatesAsync(
1291 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec),
1292 NUDGE_SOURCE_LOCAL_REFRESH,
1293 type_invalidation_map, FROM_HERE);
1294 }
1295
1296 if (js_event_handler_.IsInitialized()) {
1270 DictionaryValue details; 1297 DictionaryValue details;
1271 ListValue* changed_types = new ListValue(); 1298 ListValue* changed_types = new ListValue();
1272 details.Set("changedTypes", changed_types); 1299 details.Set("changedTypes", changed_types);
1273 for (ModelTypeInvalidationMap::const_iterator it = 1300 for (ModelTypeInvalidationMap::const_iterator it =
1274 type_invalidation_map.begin(); it != type_invalidation_map.end(); 1301 type_invalidation_map.begin(); it != type_invalidation_map.end();
1275 ++it) { 1302 ++it) {
1276 const std::string& model_type_str = 1303 const std::string& model_type_str =
1277 ModelTypeToString(it->first); 1304 ModelTypeToString(it->first);
1278 changed_types->Append(Value::CreateStringValue(model_type_str)); 1305 changed_types->Append(Value::CreateStringValue(model_type_str));
1279 } 1306 }
1280 details.SetString("source", (source == LOCAL_INVALIDATION) ? 1307 details.SetString("source", "LOCAL_INVALIDATION");
1281 "LOCAL_INVALIDATION" : "REMOTE_INVALIDATION");
1282 js_event_handler_.Call(FROM_HERE, 1308 js_event_handler_.Call(FROM_HERE,
1283 &JsEventHandler::HandleJsEvent, 1309 &JsEventHandler::HandleJsEvent,
1284 "onIncomingNotification", 1310 "onIncomingNotification",
1285 JsEventDetails(&details)); 1311 JsEventDetails(&details));
1286 } 1312 }
1287 } 1313 }
1288 1314
1289 SyncStatus SyncManagerImpl::GetDetailedStatus() const { 1315 SyncStatus SyncManagerImpl::GetDetailedStatus() const {
1290 return allstatus_.status(); 1316 return allstatus_.status();
1291 } 1317 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 int SyncManagerImpl::GetDefaultNudgeDelay() { 1382 int SyncManagerImpl::GetDefaultNudgeDelay() {
1357 return kDefaultNudgeDelayMilliseconds; 1383 return kDefaultNudgeDelayMilliseconds;
1358 } 1384 }
1359 1385
1360 // static. 1386 // static.
1361 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1387 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1362 return kPreferencesNudgeDelayMilliseconds; 1388 return kPreferencesNudgeDelayMilliseconds;
1363 } 1389 }
1364 1390
1365 } // namespace syncer 1391 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698