summaryrefslogtreecommitdiffstats
path: root/sync/notifier
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-25 19:18:53 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-25 19:18:53 +0000
commit140cf0d9293928220fa0220479b1078a353c50e2 (patch)
tree92adbac603a9ef7fdbde7cb662669da5d0ed84c8 /sync/notifier
parent54a37cdc60ec727d603e1073cc0c8259d6067cd9 (diff)
downloadchromium_src-140cf0d9293928220fa0220479b1078a353c50e2.zip
chromium_src-140cf0d9293928220fa0220479b1078a353c50e2.tar.gz
chromium_src-140cf0d9293928220fa0220479b1078a353c50e2.tar.bz2
[Sync] Make P2PNotifier emit a notification only if some enabled types changed
Relaxed some integrations tests that failed because of this. A client with type X disabled shouldn't be expected to quiesce with other clients that with X enabled given a change to X. Cleaned up indentation in preferences integration test. BUG=138893 TEST= Review URL: https://chromiumcodereview.appspot.com/10833004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/notifier')
-rw-r--r--sync/notifier/p2p_notifier.cc9
-rw-r--r--sync/notifier/p2p_notifier_unittest.cc16
2 files changed, 13 insertions, 12 deletions
diff --git a/sync/notifier/p2p_notifier.cc b/sync/notifier/p2p_notifier.cc
index e2a4209..c4fcfbe 100644
--- a/sync/notifier/p2p_notifier.cc
+++ b/sync/notifier/p2p_notifier.cc
@@ -260,13 +260,14 @@ void P2PNotifier::OnIncomingNotification(
<< "not emitting notification";
return;
}
- if (notification_data.GetChangedTypes().Empty()) {
- DVLOG(1) << "No changed types -- not emitting notification";
+ const ModelTypeSet types_to_notify =
+ Intersection(enabled_types_, notification_data.GetChangedTypes());
+ if (types_to_notify.Empty()) {
+ DVLOG(1) << "No enabled and changed types -- not emitting notification";
return;
}
const ModelTypePayloadMap& type_payloads =
- ModelTypePayloadMapFromEnumSet(
- notification_data.GetChangedTypes(), std::string());
+ ModelTypePayloadMapFromEnumSet(types_to_notify, std::string());
FOR_EACH_OBSERVER(SyncNotifierObserver, observer_list_,
OnIncomingNotification(type_payloads, REMOTE_NOTIFICATION));
}
diff --git a/sync/notifier/p2p_notifier_unittest.cc b/sync/notifier/p2p_notifier_unittest.cc
index e6e406a..055fd1b 100644
--- a/sync/notifier/p2p_notifier_unittest.cc
+++ b/sync/notifier/p2p_notifier_unittest.cc
@@ -182,12 +182,12 @@ TEST_F(P2PNotifierTest, NotificationsBasic) {
// target settings. The notifications received by the observer should
// be consistent with the target settings.
TEST_F(P2PNotifierTest, SendNotificationData) {
- ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
-
+ ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
ModelTypeSet changed_types(THEMES, APPS);
+ ModelTypeSet expected_types(THEMES);
- const ModelTypePayloadMap& changed_payload_map =
- MakePayloadMap(changed_types);
+ const ModelTypePayloadMap& expected_payload_map =
+ MakePayloadMap(expected_types);
EXPECT_CALL(mock_observer_, OnNotificationsEnabled());
EXPECT_CALL(mock_observer_,
@@ -211,7 +211,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
+ EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_SELF, changed_types));
@@ -240,7 +240,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
+ EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types));
@@ -256,7 +256,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
+ EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_ALL, changed_types));
@@ -265,7 +265,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
- EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
+ EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_ALL, changed_types));