| OLD | NEW |
| 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 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
| 13 #include "chrome/browser/history/url_database.h" // For DBCloseScoper. | 13 #include "chrome/browser/history/url_database.h" // For DBCloseScoper. |
| 14 #include "sql/meta_table.h" | 14 #include "sql/meta_table.h" |
| 15 | 15 |
| 16 namespace base { |
| 16 class FilePath; | 17 class FilePath; |
| 18 } |
| 17 | 19 |
| 18 namespace sql { | 20 namespace sql { |
| 19 class Connection; | 21 class Connection; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace history { | 24 namespace history { |
| 23 | 25 |
| 24 class TopSitesDatabase { | 26 class TopSitesDatabase { |
| 25 public: | 27 public: |
| 26 TopSitesDatabase(); | 28 TopSitesDatabase(); |
| 27 ~TopSitesDatabase(); | 29 ~TopSitesDatabase(); |
| 28 | 30 |
| 29 // Must be called after creation but before any other methods are called. | 31 // Must be called after creation but before any other methods are called. |
| 30 // Returns true on success. If false, no other functions should be called. | 32 // Returns true on success. If false, no other functions should be called. |
| 31 bool Init(const FilePath& db_name); | 33 bool Init(const base::FilePath& db_name); |
| 32 | 34 |
| 33 // Returns true if migration of top sites from history may be needed. A value | 35 // Returns true if migration of top sites from history may be needed. A value |
| 34 // of true means either migration is definitely needed (the top sites file is | 36 // of true means either migration is definitely needed (the top sites file is |
| 35 // old) or doesn't exist (as would happen for a new user). | 37 // old) or doesn't exist (as would happen for a new user). |
| 36 bool may_need_history_migration() const { | 38 bool may_need_history_migration() const { |
| 37 return may_need_history_migration_; | 39 return may_need_history_migration_; |
| 38 } | 40 } |
| 39 | 41 |
| 40 // Thumbnails ---------------------------------------------------------------- | 42 // Thumbnails ---------------------------------------------------------------- |
| 41 | 43 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Returns true if the database query succeeds. | 87 // Returns true if the database query succeeds. |
| 86 bool UpdatePageThumbnail(const MostVisitedURL& url, | 88 bool UpdatePageThumbnail(const MostVisitedURL& url, |
| 87 const Images& thumbnail); | 89 const Images& thumbnail); |
| 88 | 90 |
| 89 // Returns the URL's current rank or -1 if it is not present. | 91 // Returns the URL's current rank or -1 if it is not present. |
| 90 int GetURLRank(const MostVisitedURL& url); | 92 int GetURLRank(const MostVisitedURL& url); |
| 91 | 93 |
| 92 // Returns the number of URLs (rows) in the database. | 94 // Returns the number of URLs (rows) in the database. |
| 93 int GetRowCount(); | 95 int GetRowCount(); |
| 94 | 96 |
| 95 sql::Connection* CreateDB(const FilePath& db_name); | 97 sql::Connection* CreateDB(const base::FilePath& db_name); |
| 96 | 98 |
| 97 // Encodes redirects into a string. | 99 // Encodes redirects into a string. |
| 98 static std::string GetRedirects(const MostVisitedURL& url); | 100 static std::string GetRedirects(const MostVisitedURL& url); |
| 99 | 101 |
| 100 // Decodes redirects from a string and sets them for the url. | 102 // Decodes redirects from a string and sets them for the url. |
| 101 static void SetRedirects(const std::string& redirects, MostVisitedURL* url); | 103 static void SetRedirects(const std::string& redirects, MostVisitedURL* url); |
| 102 | 104 |
| 103 scoped_ptr<sql::Connection> db_; | 105 scoped_ptr<sql::Connection> db_; |
| 104 sql::MetaTable meta_table_; | 106 sql::MetaTable meta_table_; |
| 105 | 107 |
| 106 // See description above class. | 108 // See description above class. |
| 107 bool may_need_history_migration_; | 109 bool may_need_history_migration_; |
| 108 | 110 |
| 109 DISALLOW_COPY_AND_ASSIGN(TopSitesDatabase); | 111 DISALLOW_COPY_AND_ASSIGN(TopSitesDatabase); |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 } // namespace history | 114 } // namespace history |
| 113 | 115 |
| 114 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_ | 116 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_ |
| OLD | NEW |