OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VISIT_DATABASE_H__ | 5 #ifndef CHROME_BROWSER_HISTORY_VISIT_DATABASE_H__ |
6 #define CHROME_BROWSER_HISTORY_VISIT_DATABASE_H__ | 6 #define CHROME_BROWSER_HISTORY_VISIT_DATABASE_H__ |
7 | 7 |
8 #include "chrome/browser/history/history_types.h" | 8 #include "chrome/browser/history/history_types.h" |
9 | 9 |
10 struct sqlite3; | 10 struct sqlite3; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Fills all visits in the time range [begin, end) to the given vector. Either | 55 // Fills all visits in the time range [begin, end) to the given vector. Either |
56 // time can be is_null(), in which case the times in that direction are | 56 // time can be is_null(), in which case the times in that direction are |
57 // unbounded. | 57 // unbounded. |
58 // | 58 // |
59 // If |max_results| is non-zero, up to that many results will be returned. If | 59 // If |max_results| is non-zero, up to that many results will be returned. If |
60 // there are more results than that, the oldest ones will be returned. (This | 60 // there are more results than that, the oldest ones will be returned. (This |
61 // is used for history expiration.) | 61 // is used for history expiration.) |
62 // | 62 // |
63 // The results will be in increasing order of date. | 63 // The results will be in increasing order of date. |
64 void GetAllVisitsInRange(Time begin_time, Time end_time, int max_results, | 64 void GetAllVisitsInRange(base::Time begin_time, base::Time end_time, |
65 VisitVector* visits); | 65 int max_results, VisitVector* visits); |
66 | 66 |
67 // Fills all visits in the given time range into the given vector that should | 67 // Fills all visits in the given time range into the given vector that should |
68 // be user-visible, which excludes things like redirects and subframes. The | 68 // be user-visible, which excludes things like redirects and subframes. The |
69 // begin time is inclusive, the end time is exclusive. Either time can be | 69 // begin time is inclusive, the end time is exclusive. Either time can be |
70 // is_null(), in which case the times in that direction are unbounded. | 70 // is_null(), in which case the times in that direction are unbounded. |
71 // | 71 // |
72 // Up to |max_count| visits will be returned. If there are more visits than | 72 // Up to |max_count| visits will be returned. If there are more visits than |
73 // that, the most recent |max_count| will be returned. If 0, all visits in the | 73 // that, the most recent |max_count| will be returned. If 0, all visits in the |
74 // range will be computed. | 74 // range will be computed. |
75 // | 75 // |
76 // When |most_recent_visit_only| is set, only one visit for each URL will be | 76 // When |most_recent_visit_only| is set, only one visit for each URL will be |
77 // returned, and it will be the most recent one in the time range. | 77 // returned, and it will be the most recent one in the time range. |
78 void GetVisibleVisitsInRange(Time begin_time, Time end_time, | 78 void GetVisibleVisitsInRange(base::Time begin_time, base::Time end_time, |
79 bool most_recent_visit_only, | 79 bool most_recent_visit_only, |
80 int max_count, | 80 int max_count, |
81 VisitVector* visits); | 81 VisitVector* visits); |
82 | 82 |
83 // Returns the visit ID for the most recent visit of the given URL ID, or 0 | 83 // Returns the visit ID for the most recent visit of the given URL ID, or 0 |
84 // if there is no visit for the URL. | 84 // if there is no visit for the URL. |
85 // | 85 // |
86 // If non-NULL, the given visit row will be filled with the information of | 86 // If non-NULL, the given visit row will be filled with the information of |
87 // the found visit. When no visit is found, the row will be unchanged. | 87 // the found visit. When no visit is found, the row will be unchanged. |
88 VisitID GetMostRecentVisitForURL(URLID url_id, | 88 VisitID GetMostRecentVisitForURL(URLID url_id, |
(...skipping 20 matching lines...) Expand all Loading... |
109 // to_visit and to_url can be NULL in which case they are ignored. | 109 // to_visit and to_url can be NULL in which case they are ignored. |
110 bool GetRedirectFromVisit(VisitID from_visit, | 110 bool GetRedirectFromVisit(VisitID from_visit, |
111 VisitID* to_visit, | 111 VisitID* to_visit, |
112 GURL* to_url); | 112 GURL* to_url); |
113 | 113 |
114 // Returns the number of visits to all urls on the scheme/host/post | 114 // Returns the number of visits to all urls on the scheme/host/post |
115 // identified by url. This is only valid for http and https urls (all other | 115 // identified by url. This is only valid for http and https urls (all other |
116 // schemes are ignored and false is returned). | 116 // schemes are ignored and false is returned). |
117 // count is set to the number of visits, first_visit is set to the first time | 117 // count is set to the number of visits, first_visit is set to the first time |
118 // the host was visited. Returns true on success. | 118 // the host was visited. Returns true on success. |
119 bool GetVisitCountToHost(const GURL& url, int* count, Time* first_visit); | 119 bool GetVisitCountToHost(const GURL& url, int* count, |
| 120 base::Time* first_visit); |
120 | 121 |
121 protected: | 122 protected: |
122 // Returns the database and statement cache for the functions in this | 123 // Returns the database and statement cache for the functions in this |
123 // interface. The decendent of this class implements these functions to | 124 // interface. The decendent of this class implements these functions to |
124 // return its objects. | 125 // return its objects. |
125 virtual sqlite3* GetDB() = 0; | 126 virtual sqlite3* GetDB() = 0; |
126 virtual SqliteStatementCache& GetStatementCache() = 0; | 127 virtual SqliteStatementCache& GetStatementCache() = 0; |
127 | 128 |
128 // Called by the derived classes on initialization to make sure the tables | 129 // Called by the derived classes on initialization to make sure the tables |
129 // and indices are properly set up. Must be called before anything else. | 130 // and indices are properly set up. Must be called before anything else. |
130 bool InitVisitTable(); | 131 bool InitVisitTable(); |
131 | 132 |
132 // Convenience to fill a VisitRow. Assumes the visit values are bound starting | 133 // Convenience to fill a VisitRow. Assumes the visit values are bound starting |
133 // at index 0. | 134 // at index 0. |
134 static void FillVisitRow(SQLStatement& statement, VisitRow* visit); | 135 static void FillVisitRow(SQLStatement& statement, VisitRow* visit); |
135 | 136 |
136 // Convenience to fill a VisitVector. Assumes that statement.step() | 137 // Convenience to fill a VisitVector. Assumes that statement.step() |
137 // hasn't happened yet. | 138 // hasn't happened yet. |
138 static void FillVisitVector(SQLStatement& statement, VisitVector* visits); | 139 static void FillVisitVector(SQLStatement& statement, VisitVector* visits); |
139 | 140 |
140 private: | 141 private: |
141 DISALLOW_EVIL_CONSTRUCTORS(VisitDatabase); | 142 DISALLOW_EVIL_CONSTRUCTORS(VisitDatabase); |
142 }; | 143 }; |
143 | 144 |
144 } // history | 145 } // history |
145 | 146 |
146 #endif // CHROME_BROWSER_HISTORY_VISIT_DATABASE_H__ | 147 #endif // CHROME_BROWSER_HISTORY_VISIT_DATABASE_H__ |
147 | |
OLD | NEW |