summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz <pkotwicz@chromium.org>2015-04-08 12:20:28 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-08 19:21:42 +0000
commite66a6984230f0005a184edae8c03ea7f46a1f8a4 (patch)
treeaafd0a74aaed1021115a28ad1fd88d9c62f86b7b
parente13f573064ee476198208d4524aa0dfb898b266a (diff)
downloadchromium_src-e66a6984230f0005a184edae8c03ea7f46a1f8a4.zip
chromium_src-e66a6984230f0005a184edae8c03ea7f46a1f8a4.tar.gz
chromium_src-e66a6984230f0005a184edae8c03ea7f46a1f8a4.tar.bz2
Remove unused ThumbnailDatabase::UpdateIconMapping() and ThumbnailDatabase::CloneIconMappings()
BUG=None TEST=None Review URL: https://codereview.chromium.org/1055173003 Cr-Commit-Position: refs/heads/master@{#324267}
-rw-r--r--chrome/browser/history/history_backend_unittest.cc43
-rw-r--r--chrome/browser/history/thumbnail_database_unittest.cc93
-rw-r--r--components/favicon/core/favicon_service.cc6
-rw-r--r--components/favicon/core/favicon_service.h7
-rw-r--r--components/history/core/browser/history_backend.cc13
-rw-r--r--components/history/core/browser/history_backend.h4
-rw-r--r--components/history/core/browser/history_service.cc9
-rw-r--r--components/history/core/browser/history_service.h4
-rw-r--r--components/history/core/browser/thumbnail_database.cc33
-rw-r--r--components/history/core/browser/thumbnail_database.h10
10 files changed, 0 insertions, 222 deletions
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index 245a30b..c6de4d0 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -2642,49 +2642,6 @@ TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchNoDB) {
EXPECT_TRUE(bitmap_results.empty());
}
-TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) {
- const GURL url("http://www.google.com/");
- const GURL same_domain_url("http://www.google.com/subdir/index.html");
- const GURL foreign_domain_url("http://www.not-google.com/");
- const GURL icon_url("http://www.google.com/icon.png");
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateBitmap(SK_ColorBLUE, kSmallEdgeSize));
-
- // Add a favicon
- backend_->SetFavicons(url, favicon_base::FAVICON, icon_url, bitmaps);
- EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(
- url, favicon_base::FAVICON, NULL));
-
- // Validate starting state.
- std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
- EXPECT_TRUE(backend_->GetFaviconsFromDB(url,
- favicon_base::FAVICON,
- GetEdgeSizesSmallAndLarge(),
- &bitmap_results_out));
- EXPECT_FALSE(backend_->GetFaviconsFromDB(same_domain_url,
- favicon_base::FAVICON,
- GetEdgeSizesSmallAndLarge(),
- &bitmap_results_out));
- EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url,
- favicon_base::FAVICON,
- GetEdgeSizesSmallAndLarge(),
- &bitmap_results_out));
-
- // Same-domain cloning should work.
- backend_->CloneFavicons(url, same_domain_url);
- EXPECT_TRUE(backend_->GetFaviconsFromDB(same_domain_url,
- favicon_base::FAVICON,
- GetEdgeSizesSmallAndLarge(),
- &bitmap_results_out));
-
- // Foreign-domain cloning is forbidden.
- backend_->CloneFavicons(url, foreign_domain_url);
- EXPECT_FALSE(backend_->GetFaviconsFromDB(foreign_domain_url,
- favicon_base::FAVICON,
- GetEdgeSizesSmallAndLarge(),
- &bitmap_results_out));
-}
-
TEST_F(HistoryBackendTest, QueryFilteredURLs) {
const char* google = "http://www.google.com/";
const char* yahoo = "http://www.yahoo.com/";
diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc
index fcab1eb..9cca3cd 100644
--- a/chrome/browser/history/thumbnail_database_unittest.cc
+++ b/chrome/browser/history/thumbnail_database_unittest.cc
@@ -247,34 +247,6 @@ TEST_F(ThumbnailDatabaseTest, LastRequestedTime) {
EXPECT_EQ(last_requested, now);
}
-TEST_F(ThumbnailDatabaseTest, UpdateIconMapping) {
- ThumbnailDatabase db(NULL);
- ASSERT_EQ(sql::INIT_OK, db.Init(file_name_));
- db.BeginTransaction();
-
- GURL url("http://google.com");
- favicon_base::FaviconID id = db.AddFavicon(url, favicon_base::TOUCH_ICON);
-
- EXPECT_LT(0, db.AddIconMapping(url, id));
- std::vector<IconMapping> icon_mapping;
- EXPECT_TRUE(db.GetIconMappingsForPageURL(url, &icon_mapping));
- ASSERT_EQ(1u, icon_mapping.size());
- EXPECT_EQ(url, icon_mapping.front().page_url);
- EXPECT_EQ(id, icon_mapping.front().icon_id);
-
- GURL url1("http://www.google.com/");
- favicon_base::FaviconID new_id =
- db.AddFavicon(url1, favicon_base::TOUCH_ICON);
- EXPECT_TRUE(db.UpdateIconMapping(icon_mapping.front().mapping_id, new_id));
-
- icon_mapping.clear();
- EXPECT_TRUE(db.GetIconMappingsForPageURL(url, &icon_mapping));
- ASSERT_EQ(1u, icon_mapping.size());
- EXPECT_EQ(url, icon_mapping.front().page_url);
- EXPECT_EQ(new_id, icon_mapping.front().icon_id);
- EXPECT_NE(id, icon_mapping.front().icon_id);
-}
-
TEST_F(ThumbnailDatabaseTest, DeleteIconMappings) {
ThumbnailDatabase db(NULL);
ASSERT_EQ(sql::INIT_OK, db.Init(file_name_));
@@ -614,71 +586,6 @@ TEST_F(ThumbnailDatabaseTest, HasMappingFor) {
EXPECT_FALSE(db.HasMappingFor(id3));
}
-TEST_F(ThumbnailDatabaseTest, CloneIconMappings) {
- ThumbnailDatabase db(NULL);
- ASSERT_EQ(sql::INIT_OK, db.Init(file_name_));
- db.BeginTransaction();
-
- std::vector<unsigned char> data(kBlob1, kBlob1 + sizeof(kBlob1));
- scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data));
-
- // Add a favicon which will have icon_mappings
- favicon_base::FaviconID id1 =
- db.AddFavicon(GURL("http://google.com"), favicon_base::FAVICON);
- EXPECT_NE(0, id1);
- base::Time time = base::Time::Now();
- db.AddFaviconBitmap(id1, favicon, time, gfx::Size());
-
- // Add another type of favicon
- favicon_base::FaviconID id2 = db.AddFavicon(
- GURL("http://www.google.com/icon"), favicon_base::TOUCH_ICON);
- EXPECT_NE(0, id2);
- time = base::Time::Now();
- db.AddFaviconBitmap(id2, favicon, time, gfx::Size());
-
- // Add 3rd favicon
- favicon_base::FaviconID id3 = db.AddFavicon(
- GURL("http://www.google.com/icon"), favicon_base::TOUCH_ICON);
- EXPECT_NE(0, id3);
- time = base::Time::Now();
- db.AddFaviconBitmap(id3, favicon, time, gfx::Size());
-
- GURL page1_url("http://page1.com");
- EXPECT_TRUE(db.AddIconMapping(page1_url, id1));
- EXPECT_TRUE(db.AddIconMapping(page1_url, id2));
-
- GURL page2_url("http://page2.com");
- EXPECT_TRUE(db.AddIconMapping(page2_url, id3));
-
- // Test we do nothing with existing mappings.
- std::vector<IconMapping> icon_mapping;
- EXPECT_TRUE(db.GetIconMappingsForPageURL(page2_url, &icon_mapping));
- ASSERT_EQ(1U, icon_mapping.size());
-
- EXPECT_TRUE(db.CloneIconMappings(page1_url, page2_url));
-
- icon_mapping.clear();
- EXPECT_TRUE(db.GetIconMappingsForPageURL(page2_url, &icon_mapping));
- ASSERT_EQ(1U, icon_mapping.size());
- EXPECT_EQ(page2_url, icon_mapping[0].page_url);
- EXPECT_EQ(id3, icon_mapping[0].icon_id);
-
- // Test we clone if the new page has no mappings.
- GURL page3_url("http://page3.com");
- EXPECT_TRUE(db.CloneIconMappings(page1_url, page3_url));
-
- icon_mapping.clear();
- EXPECT_TRUE(db.GetIconMappingsForPageURL(page3_url, &icon_mapping));
-
- ASSERT_EQ(2U, icon_mapping.size());
- if (icon_mapping[0].icon_id == id2)
- std::swap(icon_mapping[0], icon_mapping[1]);
- EXPECT_EQ(page3_url, icon_mapping[0].page_url);
- EXPECT_EQ(id1, icon_mapping[0].icon_id);
- EXPECT_EQ(page3_url, icon_mapping[1].page_url);
- EXPECT_EQ(id2, icon_mapping[1].icon_id);
-}
-
// Test loading version 3 database.
TEST_F(ThumbnailDatabaseTest, Version3) {
scoped_ptr<ThumbnailDatabase> db = LoadFromGolden("Favicons.v3.sql");
diff --git a/components/favicon/core/favicon_service.cc b/components/favicon/core/favicon_service.cc
index dd1ada4c..31c7041 100644
--- a/components/favicon/core/favicon_service.cc
+++ b/components/favicon/core/favicon_service.cc
@@ -231,12 +231,6 @@ void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) {
history_service_->SetFaviconsOutOfDateForPage(page_url);
}
-void FaviconService::CloneFavicon(const GURL& old_page_url,
- const GURL& new_page_url) {
- if (history_service_)
- history_service_->CloneFavicons(old_page_url, new_page_url);
-}
-
void FaviconService::SetImportedFavicons(
const favicon_base::FaviconUsageDataList& favicon_usage) {
if (history_service_)
diff --git a/components/favicon/core/favicon_service.h b/components/favicon/core/favicon_service.h
index d122e90..e237967 100644
--- a/components/favicon/core/favicon_service.h
+++ b/components/favicon/core/favicon_service.h
@@ -171,13 +171,6 @@ class FaviconService : public KeyedService {
// Marks all types of favicon for the page as being out of date.
void SetFaviconOutOfDateForPage(const GURL& page_url);
- // Clones all icons from an existing page. This associates the icons from
- // |old_page_url| with |new_page_url|, provided |new_page_url| has no
- // recorded associations to any other icons.
- // Needed if you want to declare favicons (tentatively) in advance, before a
- // page is ever visited.
- void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url);
-
// Allows the importer to set many favicons for many pages at once. The pages
// must exist, any favicon sets for unknown pages will be discarded. Existing
// favicons will not be overwritten.
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index c257a76..4abcca4 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -1769,19 +1769,6 @@ void HistoryBackend::SetFaviconsOutOfDateForPage(const GURL& page_url) {
ScheduleCommit();
}
-void HistoryBackend::CloneFavicons(const GURL& old_page_url,
- const GURL& new_page_url) {
- if (!thumbnail_db_)
- return;
-
- // Prevent cross-domain cloning.
- if (old_page_url.GetOrigin() != new_page_url.GetOrigin())
- return;
-
- thumbnail_db_->CloneIconMappings(old_page_url, new_page_url);
- ScheduleCommit();
-}
-
void HistoryBackend::SetImportedFavicons(
const favicon_base::FaviconUsageDataList& favicon_usage) {
if (!db_ || !thumbnail_db_)
diff --git a/components/history/core/browser/history_backend.h b/components/history/core/browser/history_backend.h
index 6c54b45..9a58cd4 100644
--- a/components/history/core/browser/history_backend.h
+++ b/components/history/core/browser/history_backend.h
@@ -300,8 +300,6 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
void SetFaviconsOutOfDateForPage(const GURL& page_url);
- void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url);
-
void SetImportedFavicons(
const favicon_base::FaviconUsageDataList& favicon_usage);
@@ -505,8 +503,6 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
UpdateFaviconMappingsAndFetchNoDB);
- FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
- CloneFaviconIsRestrictedToSameDomain);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration);
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes);
diff --git a/components/history/core/browser/history_service.cc b/components/history/core/browser/history_service.cc
index 296f833..238b682 100644
--- a/components/history/core/browser/history_service.cc
+++ b/components/history/core/browser/history_service.cc
@@ -622,15 +622,6 @@ void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) {
history_backend_.get(), page_url));
}
-void HistoryService::CloneFavicons(const GURL& old_page_url,
- const GURL& new_page_url) {
- DCHECK(thread_) << "History service being called after cleanup";
- DCHECK(thread_checker_.CalledOnValidThread());
- ScheduleTask(PRIORITY_NORMAL,
- base::Bind(&HistoryBackend::CloneFavicons,
- history_backend_.get(), old_page_url, new_page_url));
-}
-
void HistoryService::SetImportedFavicons(
const favicon_base::FaviconUsageDataList& favicon_usage) {
DCHECK(thread_) << "History service being called after cleanup";
diff --git a/components/history/core/browser/history_service.h b/components/history/core/browser/history_service.h
index 7d7b00c..aaab5f3 100644
--- a/components/history/core/browser/history_service.h
+++ b/components/history/core/browser/history_service.h
@@ -748,10 +748,6 @@ class HistoryService : public syncer::SyncableService, public KeyedService {
// of date.
void SetFaviconsOutOfDateForPage(const GURL& page_url);
- // Used by the FaviconService to clone favicons from one page to another,
- // provided that other page does not already have favicons.
- void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url);
-
// Used by the FaviconService for importing many favicons for many pages at
// once. The pages must exist, any favicon sets for unknown pages will be
// discarded. Existing favicons will not be overwritten.
diff --git a/components/history/core/browser/thumbnail_database.cc b/components/history/core/browser/thumbnail_database.cc
index 45bf299..e1579f9 100644
--- a/components/history/core/browser/thumbnail_database.cc
+++ b/components/history/core/browser/thumbnail_database.cc
@@ -1035,16 +1035,6 @@ IconMappingID ThumbnailDatabase::AddIconMapping(
return db_.GetLastInsertRowId();
}
-bool ThumbnailDatabase::UpdateIconMapping(IconMappingID mapping_id,
- favicon_base::FaviconID icon_id) {
- sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
- "UPDATE icon_mapping SET icon_id=? WHERE id=?"));
- statement.BindInt64(0, icon_id);
- statement.BindInt64(1, mapping_id);
-
- return statement.Run();
-}
-
bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) {
sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
"DELETE FROM icon_mapping WHERE page_url = ?"));
@@ -1070,29 +1060,6 @@ bool ThumbnailDatabase::HasMappingFor(favicon_base::FaviconID id) {
return statement.Step();
}
-bool ThumbnailDatabase::CloneIconMappings(const GURL& old_page_url,
- const GURL& new_page_url) {
- sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
- "SELECT icon_id FROM icon_mapping "
- "WHERE page_url=?"));
- if (!statement.is_valid())
- return false;
-
- // Do nothing if there are existing bindings
- statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url));
- if (statement.Step())
- return true;
-
- statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE,
- "INSERT INTO icon_mapping (page_url, icon_id) "
- "SELECT ?, icon_id FROM icon_mapping "
- "WHERE page_url = ?"));
-
- statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url));
- statement.BindString(1, URLDatabase::GURLToDatabaseURL(old_page_url));
- return statement.Run();
-}
-
bool ThumbnailDatabase::InitIconMappingEnumerator(
favicon_base::IconType type,
IconMappingEnumerator* enumerator) {
diff --git a/components/history/core/browser/thumbnail_database.h b/components/history/core/browser/thumbnail_database.h
index c3c2927..e75b495 100644
--- a/components/history/core/browser/thumbnail_database.h
+++ b/components/history/core/browser/thumbnail_database.h
@@ -190,12 +190,6 @@ class ThumbnailDatabase {
IconMappingID AddIconMapping(const GURL& page_url,
favicon_base::FaviconID icon_id);
- // Updates the page and icon mapping for the given mapping_id with the given
- // icon_id.
- // Returns true if the update succeeded.
- bool UpdateIconMapping(IconMappingID mapping_id,
- favicon_base::FaviconID icon_id);
-
// Deletes the icon mapping entries for the given page url.
// Returns true if the deletion succeeded.
bool DeleteIconMappings(const GURL& page_url);
@@ -207,10 +201,6 @@ class ThumbnailDatabase {
// Checks whether a favicon is used by any URLs in the database.
bool HasMappingFor(favicon_base::FaviconID id);
- // Clones the existing mappings from |old_page_url| if |new_page_url| has no
- // mappings. Otherwise, will leave mappings alone.
- bool CloneIconMappings(const GURL& old_page_url, const GURL& new_page_url);
-
// The class to enumerate icon mappings. Use InitIconMappingEnumerator to
// initialize.
class IconMappingEnumerator {