Commit c5084714 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Cleanup dead sync-related dom_distiller code

article_entry.h/cc contained a bunch of code for converting from Sync
types (SyncData/SyncChange/EntitySpecifics) to dom_distiller types.
After recent changes, all that code isn't used anymore and can go.

This also lets us remove special workarounds for the deprecated
ARTICLES data type that we had in sync code.

Bug: 1007942
Change-Id: Ic9e4d243dd7a4276973398149fd14da61bf5fe05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835367
Commit-Queue: Marc Treib <treib@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Auto-Submit: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704728}
parent 1bcaec83
......@@ -5,11 +5,6 @@
#include "components/dom_distiller/core/article_entry.h"
#include "base/logging.h"
#include "components/sync/model/sync_change.h"
using sync_pb::ArticlePage;
using sync_pb::ArticleSpecifics;
using sync_pb::EntitySpecifics;
namespace dom_distiller {
......@@ -33,39 +28,4 @@ bool AreEntriesEqual(const ArticleEntry& left, const ArticleEntry& right) {
return left.SerializeAsString() == right.SerializeAsString();
}
ArticleEntry EntryFromSpecifics(const EntitySpecifics& specifics) {
DCHECK(specifics.has_article());
const ArticleSpecifics& article_specifics = specifics.article();
ArticleEntry entry = article_specifics;
DCHECK(IsEntryValid(entry));
return entry;
}
EntitySpecifics SpecificsFromEntry(const ArticleEntry& entry) {
DCHECK(IsEntryValid(entry));
EntitySpecifics specifics;
*specifics.mutable_article() = entry;
return specifics;
}
ArticleEntry GetEntryFromChange(const syncer::SyncChange& change) {
DCHECK(change.IsValid());
DCHECK(change.sync_data().IsValid());
return EntryFromSpecifics(change.sync_data().GetSpecifics());
}
std::string GetEntryIdFromSyncData(const syncer::SyncData& data) {
const EntitySpecifics& entity = data.GetSpecifics();
DCHECK(entity.has_article());
const ArticleSpecifics& specifics = entity.article();
DCHECK(specifics.has_entry_id());
return specifics.entry_id();
}
syncer::SyncData CreateLocalData(const ArticleEntry& entry) {
EntitySpecifics specifics = SpecificsFromEntry(entry);
const std::string& entry_id = entry.entry_id();
return syncer::SyncData::CreateLocalData(entry_id, entry_id, specifics);
}
} // namespace dom_distiller
......@@ -5,16 +5,7 @@
#ifndef COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ENTRY_H_
#define COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ENTRY_H_
#include <string>
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "components/sync/model/sync_data.h"
#include "components/sync/protocol/article_specifics.pb.h"
#include "components/sync/protocol/sync.pb.h"
namespace syncer {
class SyncChange;
}
namespace dom_distiller {
......@@ -26,13 +17,6 @@ bool IsEntryValid(const ArticleEntry& entry);
bool AreEntriesEqual(const ArticleEntry& left, const ArticleEntry& right);
sync_pb::EntitySpecifics SpecificsFromEntry(const ArticleEntry& entry);
ArticleEntry EntryFromSpecifics(const sync_pb::EntitySpecifics& specifics);
ArticleEntry GetEntryFromChange(const syncer::SyncChange& change);
std::string GetEntryIdFromSyncData(const syncer::SyncData& data);
syncer::SyncData CreateLocalData(const ArticleEntry& entry);
} // namespace dom_distiller
#endif // COMPONENTS_DOM_DISTILLER_CORE_ARTICLE_ENTRY_H_
......@@ -4,16 +4,8 @@
#include "components/dom_distiller/core/article_entry.h"
#include "components/sync/protocol/sync.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
using sync_pb::ArticlePage;
using sync_pb::ArticleSpecifics;
using sync_pb::EntitySpecifics;
using testing::AssertionFailure;
using testing::AssertionResult;
using testing::AssertionSuccess;
namespace dom_distiller {
TEST(DomDistillerArticleEntryTest, TestIsEntryValid) {
......
......@@ -32,14 +32,8 @@ bool SyncChange::IsValid() const {
// Local changes must always have a tag and specify a valid datatype.
if (SyncDataLocal(sync_data_).GetTag().empty())
return false;
// TODO(crbug.com/1007942): The ARTICLES data type has been removed and so is
// not considered a "real" data type anymore, but dom_distiller code still
// uses it for its local storage, and will DCHECK-fail if we don't consider
// article data as valid here.
if (!IsRealDataType(sync_data_.GetDataType()) &&
!sync_data_.GetSpecifics().has_article()) {
if (!IsRealDataType(sync_data_.GetDataType()))
return false;
}
// Adds and updates must have a non-unique-title.
if (change_type_ == ACTION_ADD || change_type_ == ACTION_UPDATE)
......
......@@ -22,7 +22,6 @@ import "app_notification_specifics.proto";
import "app_setting_specifics.proto";
import "app_specifics.proto";
import "arc_package_specifics.proto";
import "article_specifics.proto";
import "autofill_specifics.proto";
import "bookmark_specifics.proto";
import "client_commands.proto";
......@@ -143,9 +142,6 @@ message EntitySpecifics {
FaviconImageSpecifics favicon_image = 182019;
ManagedUserSettingSpecifics managed_user_setting = 186662;
ManagedUserWhitelistSpecifics managed_user_whitelist = 306060;
// TODO(crbug.com/1007942): |article| isn't used by Sync anymore, but it
// can't be removed because dom_distiller code uses it for local storage.
ArticleSpecifics article = 223759 [deprecated = true];
AppListSpecifics app_list = 229170;
AutofillWalletSpecifics autofill_wallet = 306270;
WalletMetadataSpecifics wallet_metadata = 330441;
......@@ -166,6 +162,8 @@ message EntitySpecifics {
reserved "managed_user_shared_setting";
reserved 218175;
reserved "wifi_credential";
reserved 223759;
reserved "article";
}
message SyncEntity {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment