Chromium Code Reviews| Index: chrome/browser/sync/engine/syncapi.cc |
| =================================================================== |
| --- chrome/browser/sync/engine/syncapi.cc (revision 71618) |
| +++ chrome/browser/sync/engine/syncapi.cc (working copy) |
| @@ -7,6 +7,7 @@ |
| #include <bitset> |
| #include <iomanip> |
| #include <list> |
| +#include <map> |
| #include <string> |
| #include <vector> |
| @@ -83,6 +84,7 @@ |
| static const int kThreadExitTimeoutMsec = 60000; |
| static const int kSSLPort = 443; |
| +const int kSyncerThreadDelayMsec = 250; |
| #if defined(OS_CHROMEOS) |
| static const int kChromeOSNetworkChangeReactionDelayHackMsec = 5000; |
| @@ -2194,26 +2196,37 @@ |
| void SyncManager::SyncInternal::OnIncomingNotification( |
| const IncomingNotificationData& notification_data) { |
| syncable::ModelTypeBitSet model_types; |
| + std::map<syncable::ModelType, std::string> payloads; |
| // Check if the service url is a sync URL. An empty service URL is |
| // treated as a legacy sync notification. If we're listening to |
| // server-issued notifications, no need to check the service_url. |
| if (notifier_options_.notification_method == |
| notifier::NOTIFICATION_SERVER) { |
| - VLOG(1) << "Sync received server notification: " << |
| + VLOG(1) << "Sync received server notification from " << |
| + notification_data.service_url << ": " << |
| notification_data.service_specific_data; |
| + const std::string& model_type_list = notification_data.service_url; |
| + const std::string& notification_payload = |
| + notification_data.service_specific_data; |
| - if (!syncable::ModelTypeBitSetFromString( |
| - notification_data.service_specific_data, |
| - &model_types)) { |
| + if (!syncable::ModelTypeBitSetFromString(model_type_list, &model_types)) { |
| LOG(DFATAL) << "Could not extract model types from server data."; |
| model_types.set(); |
| } |
| + |
| + for (size_t i = syncable::FIRST_REAL_MODEL_TYPE; |
|
akalin
2011/01/21 19:50:09
I think there's room for a utility function that c
Nicolas Zea
2011/01/21 21:57:44
Done.
|
| + i < model_types.size(); |
| + ++i) { |
| + if (model_types[i]) { |
| + payloads[syncable::ModelTypeFromInt(i)] = notification_payload; |
| + } |
| + } |
| } else if (notification_data.service_url.empty() || |
| - (notification_data.service_url == |
| - browser_sync::kSyncLegacyServiceUrl) || |
| - (notification_data.service_url == |
| - browser_sync::kSyncServiceUrl)) { |
| + (notification_data.service_url == |
|
akalin
2011/01/21 19:50:09
revert indentation?
Nicolas Zea
2011/01/21 21:57:44
Done.
|
| + browser_sync::kSyncLegacyServiceUrl) || |
| + (notification_data.service_url == |
| + browser_sync::kSyncServiceUrl)) { |
| VLOG(1) << "Sync received P2P notification."; |
| // Catch for sync integration tests (uses p2p). Just set all datatypes. |
| @@ -2225,11 +2238,10 @@ |
| if (model_types.any()) { |
| if (syncer_thread()) { |
| - // Introduce a delay to help coalesce initial notifications. |
| - syncer_thread()->NudgeSyncerWithDataTypes( |
| - 250, |
| - SyncerThread::kNotification, |
| - model_types); |
| + syncer_thread()->NudgeSyncerWithPayloads( |
| + kSyncerThreadDelayMsec, |
| + SyncerThread::kNotification, |
| + payloads); |
| } |
| allstatus_.IncrementNotificationsReceived(); |
| } else { |