Commit 621e757d authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Query Tiles: Removes image id.

This is not needed. The only data needed by image cache is the URL.

Bug: 1058534
Change-Id: I7eecc924923efdf842f3475f82406d449187ca84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2163158
Commit-Queue: Xing Liu <xingliu@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarHesen Zhang <hesen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762150}
parent c9a63a2b
......@@ -38,7 +38,6 @@ void TileToProto(upboarding::Tile* entry,
// Set ImageMetadatas.
for (auto& image : entry->image_metadatas) {
auto* data = proto->add_image_metadatas();
data->set_id(image.id);
data->set_url(image.url.spec());
}
......@@ -58,7 +57,7 @@ void TileFromProto(upboarding::query_tiles::proto::Tile* proto,
entry->accessibility_text = proto->accessibility_text();
for (const auto& image_md : proto->image_metadatas()) {
entry->image_metadatas.emplace_back(image_md.id(), GURL(image_md.url()));
entry->image_metadatas.emplace_back(GURL(image_md.url()));
}
for (int i = 0; i < proto->sub_tiles_size(); i++) {
......
......@@ -12,13 +12,10 @@ package upboarding.query_tiles.proto;
// Next tag: 7
message Tile {
// Metadata about the image.
// Next tag: 3
// Next tag: 2
message ImageMetadata {
// Unique id of the query tile image.
string id = 1;
// URL of the image.
string url = 2;
string url = 1;
}
// Unique id of a query tile entry.
......
......@@ -27,8 +27,7 @@ void SerializeEntry(const Tile* entry, std::stringstream& out) {
<< " accessibility_text: " << entry->accessibility_text << " \n";
for (const auto& image : entry->image_metadatas)
out << "image id: " << image.id
<< " image url: " << image.url.possibly_invalid_spec() << " \n";
out << "image url: " << image.url.possibly_invalid_spec() << " \n";
}
} // namespace
......@@ -85,10 +84,8 @@ void ResetTestEntry(Tile* entry) {
entry->display_text = "test display text";
entry->accessibility_text = "read this test display text";
entry->image_metadatas.clear();
entry->image_metadatas.emplace_back("image-test-id-1",
GURL("http://www.example.com"));
entry->image_metadatas.emplace_back("image-test-id-2",
GURL("http://www.fakeurl.com"));
entry->image_metadatas.emplace_back(GURL("http://www.example.com"));
entry->image_metadatas.emplace_back(GURL("http://www.fakeurl.com"));
auto entry1 = std::make_unique<Tile>();
entry1->id = "guid-2-1";
......
......@@ -29,15 +29,14 @@ void DeepCopyTiles(const Tile& input, Tile* out) {
ImageMetadata::ImageMetadata() = default;
ImageMetadata::ImageMetadata(const std::string& id, const GURL& url)
: id(id), url(url) {}
ImageMetadata::ImageMetadata(const GURL& url) : url(url) {}
ImageMetadata::~ImageMetadata() = default;
ImageMetadata::ImageMetadata(const ImageMetadata& other) = default;
bool ImageMetadata::operator==(const ImageMetadata& other) const {
return id == other.id && url == other.url;
return url == other.url;
}
bool Tile::operator==(const Tile& other) const {
......
......@@ -14,18 +14,15 @@
namespace upboarding {
// Metadata of an query tile image.
// Metadata of a tile image.
struct ImageMetadata {
ImageMetadata();
ImageMetadata(const std::string& id, const GURL& url);
explicit ImageMetadata(const GURL& url);
~ImageMetadata();
ImageMetadata(const ImageMetadata& other);
bool operator==(const ImageMetadata& other) const;
// Unique Id for image.
std::string id;
// Origin URL the image fetched from.
// URL of the image.
GURL url;
};
......
......@@ -44,10 +44,6 @@ TEST(TileTest, DeepComparison) {
EXPECT_TRUE(test::AreTilesIdentical(lhs, rhs));
// Test image metadatas changed.
rhs.image_metadatas.front().id = "changed";
EXPECT_FALSE(test::AreTilesIdentical(lhs, rhs));
test::ResetTestEntry(&rhs);
rhs.image_metadatas.front().url = GURL("http://www.url-changed.com");
EXPECT_FALSE(test::AreTilesIdentical(lhs, rhs));
test::ResetTestEntry(&rhs);
......
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