Index: chrome/browser/history/top_sites_database.h |
diff --git a/chrome/browser/history/top_sites_database.h b/chrome/browser/history/top_sites_database.h |
index 9659d2a937f97d42fcd823023a0b899d43c1efc6..80e8395ec7072d076cc8c55228f6028ae7010339 100644 |
--- a/chrome/browser/history/top_sites_database.h |
+++ b/chrome/browser/history/top_sites_database.h |
@@ -7,6 +7,7 @@ |
#include <map> |
#include <string> |
+#include <vector> |
#include "base/gtest_prod_util.h" |
#include "chrome/browser/history/history_types.h" |
@@ -57,13 +58,22 @@ class TopSitesDatabase { |
bool RemoveURL(const MostVisitedURL& url); |
private: |
+ friend class TopSitesDatabaseTest; |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version1); |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version2); |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version3); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version4); |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Recovery1); |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Recovery2); |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Recovery3); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Recovery4); |
FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, AddRemoveEditThumbnails); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, EncodeCSVString); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, DecodeCSVStringSucceed); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, DecodeCSVStringFail); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, EncodeRedirects); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, DecodeRedirects); |
+ FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, DecodeRedirectsFallback); |
// Rank of all URLs that are forced and therefore cannot be automatically |
// evicted. |
@@ -72,15 +82,33 @@ class TopSitesDatabase { |
// Rank used to indicate that a URL is not stored in the database. |
static const int kRankOfNonExistingURL; |
- // Upgrades the thumbnail table to version 3, returning true if the |
- // upgrade was successful. |
+ // Upgrades the thumbnail table to version 3, returning true if successful. |
bool UpgradeToVersion3(); |
+ // Upgrades the thumbnail table to version 4, returning true if successful. |
+ bool UpgradeToVersion4(); |
+ |
// Adds a new URL to the database. |
void AddPageThumbnail(const MostVisitedURL& url, |
int new_rank, |
const Images& thumbnail); |
+ // Encodes a vector of strings inside a single string, as a comma-separated |
+ // list of quoted strings. Quotes are escaped into two quotes. |
+ static std::string EncodeCSVString(const std::vector<std::string> str_list); |
+ |
+ // Decodes a string encoded by EncodeCSVString() as a vector of strings, |
+ // On success returns true, otherwise returns false and ignores |str_list|. |
+ static bool DecodeCSVString(const std::string csv, |
+ std::vector<std::string>* str_list); |
+ |
+ // Encodes |redirects| as string. |
+ static std::string EncodeRedirects(const RedirectList& redirects); |
+ |
+ // Decodes a redirects string, appends the result to |redirects|. |
+ static void DecodeRedirects(const std::string& encoded_redirects, |
+ RedirectList* redirects); |
+ |
// Sets the page rank. Should be called within an open transaction. |
void UpdatePageRankNoTransaction(const MostVisitedURL& url, int new_rank); |