[STTS]change model observer to only notify in the case of remote updates
Bug: 910390
Change-Id: Ib5b4228f6b7b04c2f14e65ad153236576734e134
Reviewed-on: https://chromium-review.googlesource.com/c/1476056
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Reviewed-by: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633308}
diff --git a/chrome/browser/sync/test/integration/send_tab_to_self_helper.cc b/chrome/browser/sync/test/integration/send_tab_to_self_helper.cc
index 9515e31..a2f4a0ff 100644
--- a/chrome/browser/sync/test/integration/send_tab_to_self_helper.cc
+++ b/chrome/browser/sync/test/integration/send_tab_to_self_helper.cc
@@ -43,13 +43,13 @@
CheckExitCondition();
}
-void SendTabToSelfUrlChecker::SendTabToSelfEntriesAdded(
+void SendTabToSelfUrlChecker::EntriesAddedRemotely(
const std::vector<const send_tab_to_self::SendTabToSelfEntry*>&
new_entries) {
CheckExitCondition();
}
-void SendTabToSelfUrlChecker::SendTabToSelfEntriesRemoved(
+void SendTabToSelfUrlChecker::EntriesRemovedRemotely(
const std::vector<std::string>& guids_removed) {
CheckExitCondition();
}
@@ -106,13 +106,13 @@
CheckExitCondition();
}
-void SendTabToSelfModelEqualityChecker::SendTabToSelfEntriesAdded(
+void SendTabToSelfModelEqualityChecker::EntriesAddedRemotely(
const std::vector<const send_tab_to_self::SendTabToSelfEntry*>&
new_entries) {
CheckExitCondition();
}
-void SendTabToSelfModelEqualityChecker::SendTabToSelfEntriesRemoved(
+void SendTabToSelfModelEqualityChecker::EntriesRemovedRemotely(
const std::vector<std::string>& guids_removed) {
CheckExitCondition();
}
diff --git a/chrome/browser/sync/test/integration/send_tab_to_self_helper.h b/chrome/browser/sync/test/integration/send_tab_to_self_helper.h
index 4a3764f5..fbb4754 100644
--- a/chrome/browser/sync/test/integration/send_tab_to_self_helper.h
+++ b/chrome/browser/sync/test/integration/send_tab_to_self_helper.h
@@ -35,10 +35,10 @@
// SendTabToSelfModelObserver implementation.
void SendTabToSelfModelLoaded() override;
- void SendTabToSelfEntriesAdded(
+ void EntriesAddedRemotely(
const std::vector<const send_tab_to_self::SendTabToSelfEntry*>&
new_entries) override;
- void SendTabToSelfEntriesRemoved(
+ void EntriesRemovedRemotely(
const std::vector<std::string>& guids_removed) override;
private:
@@ -65,10 +65,10 @@
// SendTabToSelfModelObserver implementation.
void SendTabToSelfModelLoaded() override;
- void SendTabToSelfEntriesAdded(
+ void EntriesAddedRemotely(
const std::vector<const send_tab_to_self::SendTabToSelfEntry*>&
new_entries) override;
- void SendTabToSelfEntriesRemoved(
+ void EntriesRemovedRemotely(
const std::vector<std::string>& guids_removed) override;
private:
diff --git a/components/send_tab_to_self/send_tab_to_self_bridge.cc b/components/send_tab_to_self/send_tab_to_self_bridge.cc
index ac8c8bf..7f2875be 100644
--- a/components/send_tab_to_self/send_tab_to_self_bridge.cc
+++ b/components/send_tab_to_self/send_tab_to_self_bridge.cc
@@ -85,10 +85,10 @@
}
}
if (!removed.empty()) {
- NotifySendTabToSelfEntryDeleted(removed);
+ NotifyRemoteSendTabToSelfEntryDeleted(removed);
}
if (!added.empty()) {
- NotifySendTabToSelfEntryAdded(added);
+ NotifyRemoteSendTabToSelfEntryAdded(added);
}
return base::nullopt;
}
@@ -187,12 +187,7 @@
change_processor()->Put(guid, std::move(entity_data), &metadata_change_list);
- const SendTabToSelfEntry* result =
- entries_.emplace(guid, std::move(entry)).first->second.get();
-
- NotifySendTabToSelfEntryAdded(std::vector<const SendTabToSelfEntry*>{result});
-
- return result;
+ return entries_.emplace(guid, std::move(entry)).first->second.get();
}
void SendTabToSelfBridge::DeleteEntry(const std::string& guid) {
@@ -207,7 +202,6 @@
entries_.erase(guid);
- NotifySendTabToSelfEntryDeleted(std::vector<std::string>{guid});
}
void SendTabToSelfBridge::DismissEntry(const std::string& guid) {
@@ -220,17 +214,17 @@
// TODO(jeffreycohen) Implement once there is local storage.
}
-void SendTabToSelfBridge::NotifySendTabToSelfEntryAdded(
+void SendTabToSelfBridge::NotifyRemoteSendTabToSelfEntryAdded(
const std::vector<const SendTabToSelfEntry*>& new_entries) {
for (SendTabToSelfModelObserver& observer : observers_) {
- observer.SendTabToSelfEntriesAdded(new_entries);
+ observer.EntriesAddedRemotely(new_entries);
}
}
-void SendTabToSelfBridge::NotifySendTabToSelfEntryDeleted(
+void SendTabToSelfBridge::NotifyRemoteSendTabToSelfEntryDeleted(
const std::vector<std::string>& guids) {
for (SendTabToSelfModelObserver& observer : observers_) {
- observer.SendTabToSelfEntriesRemoved(guids);
+ observer.EntriesRemovedRemotely(guids);
}
}
diff --git a/components/send_tab_to_self/send_tab_to_self_bridge.h b/components/send_tab_to_self/send_tab_to_self_bridge.h
index 76a5dd1..89da9b1 100644
--- a/components/send_tab_to_self/send_tab_to_self_bridge.h
+++ b/components/send_tab_to_self/send_tab_to_self_bridge.h
@@ -72,13 +72,15 @@
using SendTabToSelfEntries =
std::map<std::string, std::unique_ptr<SendTabToSelfEntry>>;
- // Notify all observers of added |entries| when the underlying model changes.
- void NotifySendTabToSelfEntryAdded(
+ // Notify all observers of any added |entries| when they are added the the
+ // model via sync.
+ void NotifyRemoteSendTabToSelfEntryAdded(
const std::vector<const SendTabToSelfEntry*>& new_entries);
// Notify all observers when the entries with |guids| have been removed from
- // the model.
- void NotifySendTabToSelfEntryDeleted(const std::vector<std::string>& guids);
+ // the model via sync.
+ void NotifyRemoteSendTabToSelfEntryDeleted(
+ const std::vector<std::string>& guids);
// Used as callback given to LocalDeviceInfoProvider.
void OnDeviceProviderInitialized();
diff --git a/components/send_tab_to_self/send_tab_to_self_model_observer.h b/components/send_tab_to_self/send_tab_to_self_model_observer.h
index fdfda2c..78589b6 100644
--- a/components/send_tab_to_self/send_tab_to_self_model_observer.h
+++ b/components/send_tab_to_self/send_tab_to_self_model_observer.h
@@ -26,9 +26,9 @@
// Invoked when elements of the model are added or removed. This is the
// mechanism for the sync server to push changes in the state of the model to
// clients.
- virtual void SendTabToSelfEntriesAdded(
+ virtual void EntriesAddedRemotely(
const std::vector<const SendTabToSelfEntry*>& new_entries) = 0;
- virtual void SendTabToSelfEntriesRemoved(
+ virtual void EntriesRemovedRemotely(
const std::vector<std::string>& guids) = 0;
private: