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

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

Issue 2746002: 1. Create and use the TopSites database file.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months 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/top_sites.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "app/sql/connection.h" 11 #include "app/sql/connection.h"
12 #include "app/sql/init_status.h"
13 #include "app/sql/meta_table.h"
14 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
15 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
16 #include "chrome/browser/history/url_database.h" // For DBCloseScoper. 14 #include "chrome/browser/history/url_database.h" // For DBCloseScoper.
17 15
18 class FilePath; 16 class FilePath;
19 class RefCountedMemory; 17 class RefCountedMemory;
20 class SkBitmap; 18 class SkBitmap;
21 class TopSites; 19 class TopSites;
22 20
23 namespace base { 21 namespace base {
24 class Time; 22 class Time;
25 } 23 }
26 24
27 namespace history { 25 namespace history {
28 26
29 // Interface to be implemented by the real storage layer as well as 27 // Interface to be implemented by the real storage layer as well as
30 // the mockup database for testing. 28 // the mockup database for testing.
31 class TopSitesDatabase { 29 class TopSitesDatabase {
32 public: 30 public:
33 virtual ~TopSitesDatabase() {} 31 virtual ~TopSitesDatabase() {}
32 virtual bool Init(const FilePath& filename) {
33 return true;
34 }
34 35
35 // Returns a list of all URLs currently in the table. 36 // Returns a list of all URLs currently in the table.
36 virtual MostVisitedURLList GetTopURLs() = 0; 37 virtual MostVisitedURLList GetTopURLs() = 0;
37 38
38 // Set a thumbnail for a URL. |url_rank| is the position of the URL 39 // Set a thumbnail for a URL. |url_rank| is the position of the URL
39 // in the list of TopURLs, zero-based. 40 // in the list of TopURLs, zero-based.
40 // If the URL is not in the table, add it. If it is, replace its 41 // If the URL is not in the table, add it. If it is, replace its
41 // thumbnail. 42 // thumbnail.
42 virtual void SetPageThumbnail(const MostVisitedURL& url, 43 virtual void SetPageThumbnail(const MostVisitedURL& url,
43 int url_rank, 44 int url_rank,
44 const TopSites::Images& thumbnail) = 0; 45 const TopSites::Images& thumbnail) = 0;
45 46
46 // Get a thumbnail for a given page. Returns true iff we have the thumbnail. 47 // Get a thumbnail for a given page. Returns true iff we have the thumbnail.
47 virtual bool GetPageThumbnail(const MostVisitedURL& url, 48 virtual bool GetPageThumbnail(const MostVisitedURL& url,
48 TopSites::Images* thumbnail) = 0; 49 TopSites::Images* thumbnail) = 0;
49 50
50 // Remove the record for this URL. Returns true iff removed successfully. 51 // Remove the record for this URL. Returns true iff removed successfully.
51 virtual bool RemoveURL(const MostVisitedURL& url) = 0; 52 virtual bool RemoveURL(const MostVisitedURL& url) = 0;
52 }; 53 };
53 54
54 class TopSitesDatabaseImpl: public TopSitesDatabase { 55 class TopSitesDatabaseImpl : public TopSitesDatabase {
55 public: 56 public:
56 TopSitesDatabaseImpl(); 57 TopSitesDatabaseImpl();
57 ~TopSitesDatabaseImpl() {} 58 ~TopSitesDatabaseImpl() {}
58 59
59 // Must be called after creation but before any other methods are called. 60 // Must be called after creation but before any other methods are called.
60 // Returns true on success. If false, no other functions should be called. 61 // Returns true on success. If false, no other functions should be called.
61 bool Init(const FilePath& db_name); 62 virtual bool Init(const FilePath& db_name);
62 63
63 // Thumbnails ---------------------------------------------------------------- 64 // Thumbnails ----------------------------------------------------------------
64 65
65 // Returns a list of all URLs currently in the table. 66 // Returns a list of all URLs currently in the table.
66 virtual MostVisitedURLList GetTopURLs(); 67 virtual MostVisitedURLList GetTopURLs();
67 68
68 // Set a thumbnail for a URL. |url_rank| is the position of the URL 69 // Set a thumbnail for a URL. |url_rank| is the position of the URL
69 // in the list of TopURLs, zero-based. 70 // in the list of TopURLs, zero-based.
70 // If the URL is not in the table, add it. If it is, replace its 71 // If the URL is not in the table, add it. If it is, replace its
71 // thumbnail and rank. Shift the ranks of other URLs if necessary. 72 // thumbnail and rank. Shift the ranks of other URLs if necessary.
(...skipping 27 matching lines...) Expand all
99 100
100 // Decodes redirects from a string and sets them for the url. 101 // Decodes redirects from a string and sets them for the url.
101 static void SetRedirects(const std::string& redirects, MostVisitedURL* url); 102 static void SetRedirects(const std::string& redirects, MostVisitedURL* url);
102 103
103 sql::Connection db_; 104 sql::Connection db_;
104 }; 105 };
105 106
106 } // namespace history 107 } // namespace history
107 108
108 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_ 109 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/top_sites.cc ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698