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_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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/history/history_types.h" | 10 #include "chrome/browser/history/history_types.h" |
11 | 11 |
12 namespace sql { | 12 namespace sql { |
13 class Connection; | 13 class Connection; |
14 class Statement; | 14 class Statement; |
15 } | 15 } |
16 | 16 |
17 namespace history { | 17 namespace history { |
18 | 18 |
| 19 class TimeFilter; |
| 20 |
19 // A visit database is one which stores visits for URLs, that is, times and | 21 // A visit database is one which stores visits for URLs, that is, times and |
20 // linking information. A visit database must also be a URLDatabase, as this | 22 // linking information. A visit database must also be a URLDatabase, as this |
21 // modifies tables used by URLs directly and could be thought of as inheriting | 23 // modifies tables used by URLs directly and could be thought of as inheriting |
22 // from URLDatabase. However, this inheritance is not explicit as things would | 24 // from URLDatabase. However, this inheritance is not explicit as things would |
23 // get too complicated and have multiple inheritance. | 25 // get too complicated and have multiple inheritance. |
24 class VisitDatabase { | 26 class VisitDatabase { |
25 public: | 27 public: |
26 // Must call InitVisitTable() before using to make sure the database is | 28 // Must call InitVisitTable() before using to make sure the database is |
27 // initialized. | 29 // initialized. |
28 VisitDatabase(); | 30 VisitDatabase(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // unbounded. | 68 // unbounded. |
67 // | 69 // |
68 // If |max_results| is non-zero, up to that many results will be returned. If | 70 // If |max_results| is non-zero, up to that many results will be returned. If |
69 // there are more results than that, the oldest ones will be returned. (This | 71 // there are more results than that, the oldest ones will be returned. (This |
70 // is used for history expiration.) | 72 // is used for history expiration.) |
71 // | 73 // |
72 // The results will be in increasing order of date. | 74 // The results will be in increasing order of date. |
73 bool GetAllVisitsInRange(base::Time begin_time, base::Time end_time, | 75 bool GetAllVisitsInRange(base::Time begin_time, base::Time end_time, |
74 int max_results, VisitVector* visits); | 76 int max_results, VisitVector* visits); |
75 | 77 |
| 78 // Fills all visits in the time ranges embedded in |time_filter| to the given |
| 79 // vector. |
| 80 // |
| 81 // If |max_results| is non-zero, up to that many results will be returned. If |
| 82 // there are more results than that, the oldest ones will be returned. (This |
| 83 // is used for history expiration.) |
| 84 // |
| 85 // The results will be in increasing order of date. |
| 86 bool GetAllVisitsDuringTimes(const TimeFilter& time_filter, |
| 87 int max_results, VisitVector* visits); |
| 88 |
76 // Fills all visits with specified transition in the time range [begin, end) | 89 // Fills all visits with specified transition in the time range [begin, end) |
77 // to the given vector. Either time can be is_null(), in which case the times | 90 // to the given vector. Either time can be is_null(), in which case the times |
78 // in that direction are unbounded. | 91 // in that direction are unbounded. |
79 // | 92 // |
80 // If |max_results| is non-zero, up to that many results will be returned. If | 93 // If |max_results| is non-zero, up to that many results will be returned. If |
81 // there are more results than that, the oldest ones will be returned. (This | 94 // there are more results than that, the oldest ones will be returned. (This |
82 // is used for history expiration.) | 95 // is used for history expiration.) |
83 // | 96 // |
84 // The results will be in increasing order of date. | 97 // The results will be in increasing order of date. |
85 bool GetVisitsInRangeForTransition(base::Time begin_time, | 98 bool GetVisitsInRangeForTransition(base::Time begin_time, |
(...skipping 10 matching lines...) Expand all Loading... |
96 // Up to |max_count| visits will be returned. If there are more visits than | 109 // Up to |max_count| visits will be returned. If there are more visits than |
97 // that, the most recent |max_count| will be returned. If 0, all visits in the | 110 // that, the most recent |max_count| will be returned. If 0, all visits in the |
98 // range will be computed. | 111 // range will be computed. |
99 // | 112 // |
100 // Only one visit for each URL will be returned, and it will be the most | 113 // Only one visit for each URL will be returned, and it will be the most |
101 // recent one in the time range. | 114 // recent one in the time range. |
102 void GetVisibleVisitsInRange(base::Time begin_time, base::Time end_time, | 115 void GetVisibleVisitsInRange(base::Time begin_time, base::Time end_time, |
103 int max_count, | 116 int max_count, |
104 VisitVector* visits); | 117 VisitVector* visits); |
105 | 118 |
| 119 // Fills all visits in the given time ranges into the given vector that should |
| 120 // be user-visible, which excludes things like redirects and subframes. The |
| 121 // begin time is inclusive, the end time is exclusive. |
| 122 // |
| 123 // Up to |max_count| visits will be returned. If there are more visits than |
| 124 // that, the most recent |max_count| will be returned. If 0, all visits in the |
| 125 // range will be computed. |
| 126 // |
| 127 // Only one visit for each URL will be returned, and it will be the most |
| 128 // recent one in the time range. |
| 129 void GetVisibleVisitsDuringTimes(const TimeFilter& time_filter, |
| 130 int max_count, |
| 131 VisitVector* visits); |
| 132 |
106 // Returns the visit ID for the most recent visit of the given URL ID, or 0 | 133 // Returns the visit ID for the most recent visit of the given URL ID, or 0 |
107 // if there is no visit for the URL. | 134 // if there is no visit for the URL. |
108 // | 135 // |
109 // If non-NULL, the given visit row will be filled with the information of | 136 // If non-NULL, the given visit row will be filled with the information of |
110 // the found visit. When no visit is found, the row will be unchanged. | 137 // the found visit. When no visit is found, the row will be unchanged. |
111 VisitID GetMostRecentVisitForURL(URLID url_id, | 138 VisitID GetMostRecentVisitForURL(URLID url_id, |
112 VisitRow* visit_row); | 139 VisitRow* visit_row); |
113 | 140 |
114 // Returns the |max_results| most recent visit sessions for |url_id|. | 141 // Returns the |max_results| most recent visit sessions for |url_id|. |
115 // | 142 // |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 private: | 203 private: |
177 class VisitAnalysis; | 204 class VisitAnalysis; |
178 scoped_ptr<VisitAnalysis> visit_analysis_; | 205 scoped_ptr<VisitAnalysis> visit_analysis_; |
179 | 206 |
180 DISALLOW_COPY_AND_ASSIGN(VisitDatabase); | 207 DISALLOW_COPY_AND_ASSIGN(VisitDatabase); |
181 }; | 208 }; |
182 | 209 |
183 } // history | 210 } // history |
184 | 211 |
185 #endif // CHROME_BROWSER_HISTORY_VISIT_DATABASE_H_ | 212 #endif // CHROME_BROWSER_HISTORY_VISIT_DATABASE_H_ |
OLD | NEW |