Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: chrome/browser/history/top_sites_database.h

Issue 39053005: Adding last_forced column to thumbnails database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Answered Brett's comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history_types.cc ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_ 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // Get a thumbnail for a given page. Returns true iff we have the thumbnail. 54 // Get a thumbnail for a given page. Returns true iff we have the thumbnail.
55 bool GetPageThumbnail(const GURL& url, Images* thumbnail); 55 bool GetPageThumbnail(const GURL& url, Images* thumbnail);
56 56
57 // Remove the record for this URL. Returns true iff removed successfully. 57 // Remove the record for this URL. Returns true iff removed successfully.
58 bool RemoveURL(const MostVisitedURL& url); 58 bool RemoveURL(const MostVisitedURL& url);
59 59
60 private: 60 private:
61 FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version1); 61 FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version1);
62 FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version2); 62 FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version2);
63 FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, Version3);
64 FRIEND_TEST_ALL_PREFIXES(TopSitesDatabaseTest, AddRemoveEditThumbnails);
65
66 // Rank of all URLs that are forced and therefore cannot be automatically
67 // evicted.
68 static const int kRankOfForcedURL = -1;
69
70 // Rank used to indicate that a URL is not stored in the database.
71 static const int kRankOfNonExistingURL = -2;
63 72
64 // Creates the thumbnail table, returning true if the table already exists 73 // Creates the thumbnail table, returning true if the table already exists
65 // or was successfully created. 74 // or was successfully created.
66 bool InitThumbnailTable(); 75 bool InitThumbnailTable();
67 76
68 // Upgrades the thumbnail table to version 2, returning true if the 77 // Upgrades the thumbnail table to version 2, returning true if the
69 // upgrade was successful. 78 // upgrade was successful.
70 bool UpgradeToVersion2(); 79 bool UpgradeToVersion2();
71 80
81 // Upgrades the thumbnail table to version 3, returning true if the
82 // upgrade was successful.
83 bool UpgradeToVersion3();
84
72 // Adds a new URL to the database. 85 // Adds a new URL to the database.
73 void AddPageThumbnail(const MostVisitedURL& url, 86 void AddPageThumbnail(const MostVisitedURL& url,
74 int new_rank, 87 int new_rank,
75 const Images& thumbnail); 88 const Images& thumbnail);
76 89
77 // Sets the page rank. Should be called within an open transaction. 90 // Sets the page rank. Should be called within an open transaction.
78 void UpdatePageRankNoTransaction(const MostVisitedURL& url, int new_rank); 91 void UpdatePageRankNoTransaction(const MostVisitedURL& url, int new_rank);
79 92
80 // Updates thumbnail of a URL that's already in the database. 93 // Updates thumbnail of a URL that's already in the database.
81 // Returns true if the database query succeeds. 94 // Returns true if the database query succeeds.
82 bool UpdatePageThumbnail(const MostVisitedURL& url, 95 bool UpdatePageThumbnail(const MostVisitedURL& url,
83 const Images& thumbnail); 96 const Images& thumbnail);
84 97
85 // Returns the URL's current rank or -1 if it is not present. 98 // Returns |url|'s current rank or kRankOfNonExistingURL if not present.
86 int GetURLRank(const MostVisitedURL& url); 99 int GetURLRank(const MostVisitedURL& url);
87 100
88 // Returns the number of URLs (rows) in the database.
89 int GetRowCount();
90
91 sql::Connection* CreateDB(const base::FilePath& db_name); 101 sql::Connection* CreateDB(const base::FilePath& db_name);
92 102
93 // Encodes redirects into a string. 103 // Encodes redirects into a string.
94 static std::string GetRedirects(const MostVisitedURL& url); 104 static std::string GetRedirects(const MostVisitedURL& url);
95 105
96 // Decodes redirects from a string and sets them for the url. 106 // Decodes redirects from a string and sets them for the url.
97 static void SetRedirects(const std::string& redirects, MostVisitedURL* url); 107 static void SetRedirects(const std::string& redirects, MostVisitedURL* url);
98 108
99 scoped_ptr<sql::Connection> db_; 109 scoped_ptr<sql::Connection> db_;
100 sql::MetaTable meta_table_; 110 sql::MetaTable meta_table_;
101 111
102 DISALLOW_COPY_AND_ASSIGN(TopSitesDatabase); 112 DISALLOW_COPY_AND_ASSIGN(TopSitesDatabase);
103 }; 113 };
104 114
105 } // namespace history 115 } // namespace history
106 116
107 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_ 117 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/history_types.cc ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698