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_THUMBNAIL_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
6 #define CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 6 #define CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
13 #include "sql/connection.h" | 13 #include "sql/connection.h" |
14 #include "sql/init_status.h" | 14 #include "sql/init_status.h" |
15 #include "sql/meta_table.h" | 15 #include "sql/meta_table.h" |
16 #include "sql/statement.h" | 16 #include "sql/statement.h" |
17 | 17 |
18 class FilePath; | |
19 struct ThumbnailScore; | 18 struct ThumbnailScore; |
20 class SkBitmap; | 19 class SkBitmap; |
21 | 20 |
22 namespace base { | 21 namespace base { |
| 22 class FilePath; |
23 class RefCountedMemory; | 23 class RefCountedMemory; |
24 class Time; | 24 class Time; |
25 } | 25 } |
26 | 26 |
27 namespace gfx { | 27 namespace gfx { |
28 class Image; | 28 class Image; |
29 } | 29 } |
30 | 30 |
31 namespace history { | 31 namespace history { |
32 | 32 |
33 class ExpireHistoryBackend; | 33 class ExpireHistoryBackend; |
34 class HistoryPublisher; | 34 class HistoryPublisher; |
35 | 35 |
36 // This database interface is owned by the history backend and runs on the | 36 // This database interface is owned by the history backend and runs on the |
37 // history thread. It is a totally separate component from history partially | 37 // history thread. It is a totally separate component from history partially |
38 // because we may want to move it to its own thread in the future. The | 38 // because we may want to move it to its own thread in the future. The |
39 // operations we will do on this database will be slow, but we can tolerate | 39 // operations we will do on this database will be slow, but we can tolerate |
40 // higher latency (it's OK for thumbnails to come in slower than the rest | 40 // higher latency (it's OK for thumbnails to come in slower than the rest |
41 // of the data). Moving this to a separate thread would not block potentially | 41 // of the data). Moving this to a separate thread would not block potentially |
42 // higher priority history operations. | 42 // higher priority history operations. |
43 class ThumbnailDatabase { | 43 class ThumbnailDatabase { |
44 public: | 44 public: |
45 ThumbnailDatabase(); | 45 ThumbnailDatabase(); |
46 ~ThumbnailDatabase(); | 46 ~ThumbnailDatabase(); |
47 | 47 |
48 // Must be called after creation but before any other methods are called. | 48 // Must be called after creation but before any other methods are called. |
49 // When not INIT_OK, no other functions should be called. | 49 // When not INIT_OK, no other functions should be called. |
50 sql::InitStatus Init(const FilePath& db_name, | 50 sql::InitStatus Init(const base::FilePath& db_name, |
51 const HistoryPublisher* history_publisher, | 51 const HistoryPublisher* history_publisher, |
52 URLDatabase* url_database); | 52 URLDatabase* url_database); |
53 | 53 |
54 // Open database on a given filename. If the file does not exist, | 54 // Open database on a given filename. If the file does not exist, |
55 // it is created. | 55 // it is created. |
56 // |db| is the database to open. | 56 // |db| is the database to open. |
57 // |db_name| is a path to the database file. | 57 // |db_name| is a path to the database file. |
58 static sql::InitStatus OpenDatabase(sql::Connection* db, | 58 static sql::InitStatus OpenDatabase(sql::Connection* db, |
59 const FilePath& db_name); | 59 const base::FilePath& db_name); |
60 | 60 |
61 // Transactions on the database. | 61 // Transactions on the database. |
62 void BeginTransaction(); | 62 void BeginTransaction(); |
63 void CommitTransaction(); | 63 void CommitTransaction(); |
64 int transaction_nesting() const { | 64 int transaction_nesting() const { |
65 return db_.transaction_nesting(); | 65 return db_.transaction_nesting(); |
66 } | 66 } |
67 void RollbackTransaction(); | 67 void RollbackTransaction(); |
68 | 68 |
69 // Vacuums the database. This will cause sqlite to defragment and collect | 69 // Vacuums the database. This will cause sqlite to defragment and collect |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // | 301 // |
302 // The ID of the favicon will change when this copy takes place. The new ID | 302 // The ID of the favicon will change when this copy takes place. The new ID |
303 // is returned, or 0 on failure. | 303 // is returned, or 0 on failure. |
304 FaviconID CopyFaviconAndFaviconBitmapsToTemporaryTables(FaviconID source); | 304 FaviconID CopyFaviconAndFaviconBitmapsToTemporaryTables(FaviconID source); |
305 | 305 |
306 // Returns true iff the thumbnails table exists. | 306 // Returns true iff the thumbnails table exists. |
307 // Migrating to TopSites is dropping the thumbnails table. | 307 // Migrating to TopSites is dropping the thumbnails table. |
308 bool NeedsMigrationToTopSites(); | 308 bool NeedsMigrationToTopSites(); |
309 | 309 |
310 // Renames the database file and drops the Thumbnails table. | 310 // Renames the database file and drops the Thumbnails table. |
311 bool RenameAndDropThumbnails(const FilePath& old_db_file, | 311 bool RenameAndDropThumbnails(const base::FilePath& old_db_file, |
312 const FilePath& new_db_file); | 312 const base::FilePath& new_db_file); |
313 | 313 |
314 private: | 314 private: |
315 friend class ExpireHistoryBackend; | 315 friend class ExpireHistoryBackend; |
316 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, | 316 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, |
317 GetFaviconAfterMigrationToTopSites); | 317 GetFaviconAfterMigrationToTopSites); |
318 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion4); | 318 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion4); |
319 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion5); | 319 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion5); |
320 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion6); | 320 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion6); |
321 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, FaviconSizesToAndFromString); | 321 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, FaviconSizesToAndFromString); |
322 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); | 322 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 const HistoryPublisher* history_publisher_; | 421 const HistoryPublisher* history_publisher_; |
422 | 422 |
423 // True if migration to TopSites has been done and the thumbnails | 423 // True if migration to TopSites has been done and the thumbnails |
424 // table should not be used. | 424 // table should not be used. |
425 bool use_top_sites_; | 425 bool use_top_sites_; |
426 }; | 426 }; |
427 | 427 |
428 } // namespace history | 428 } // namespace history |
429 | 429 |
430 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 430 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
OLD | NEW |