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

Side by Side Diff: chrome/browser/common/url_database/url_database.h

Issue 10948045: introduce chrome/browser/common directory and move url_database(and its dependencies) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
OLDNEW
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_URL_DATABASE_H_ 5 #ifndef CHROME_BROWSER_COMMON_URL_DATABASE_URL_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_URL_DATABASE_H_ 6 #define CHROME_BROWSER_COMMON_URL_DATABASE_URL_DATABASE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "chrome/browser/history/history_types.h" 9 #include "chrome/browser/common/url_database/template_url_id.h"
10 #include "chrome/browser/search_engines/template_url_id.h" 10 #include "chrome/browser/common/url_database/url_database_types.h"
11 #include "sql/statement.h" 11 #include "sql/statement.h"
12 12
13 class GURL; 13 class GURL;
14 class IconMapping;
14 15
15 namespace sql { 16 namespace sql {
16 class Connection; 17 class Connection;
17 } 18 }
18 19
19 namespace history { 20 namespace history {
20 21
21 class VisitDatabase; // For friend statement.
22
23 // Encapsulates an SQL database that holds URL info. This is a subset of the 22 // Encapsulates an SQL database that holds URL info. This is a subset of the
24 // full history data. We split this class' functionality out from the larger 23 // full history data. We split this class' functionality out from the larger
25 // HistoryDatabase class to support maintaining separate databases of URLs with 24 // HistoryDatabase class to support maintaining separate databases of URLs with
26 // different capabilities (for example, in-memory, or archived). 25 // different capabilities (for example, in-memory, or archived).
27 // 26 //
28 // This is refcounted to support calling InvokeLater() with some of its methods 27 // This is refcounted to support calling InvokeLater() with some of its methods
29 // (necessary to maintain ordering of DB operations). 28 // (necessary to maintain ordering of DB operations).
30 class URLDatabase { 29 class URLDatabase {
31 public: 30 public:
32 // Must call CreateURLTable() and CreateURLIndexes() before using to make 31 // Must call CreateURLTable() and CreateURLIndexes() before using to make
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 123
125 DISALLOW_COPY_AND_ASSIGN(URLEnumeratorBase); 124 DISALLOW_COPY_AND_ASSIGN(URLEnumeratorBase);
126 }; 125 };
127 126
128 // A basic enumerator to enumerate urls 127 // A basic enumerator to enumerate urls
129 class URLEnumerator : public URLEnumeratorBase { 128 class URLEnumerator : public URLEnumeratorBase {
130 public: 129 public:
131 URLEnumerator(); 130 URLEnumerator();
132 131
133 // Retreives the next url. Returns false if no more urls are available 132 // Retreives the next url. Returns false if no more urls are available
134 bool GetNextURL(history::URLRow* r); 133 bool GetNextURL(URLRow* r);
135 134
136 private: 135 private:
137 DISALLOW_COPY_AND_ASSIGN(URLEnumerator); 136 DISALLOW_COPY_AND_ASSIGN(URLEnumerator);
138 }; 137 };
139 138
140 // A basic enumerator to enumerate icon mapping, it is only used for icon 139 // A basic enumerator to enumerate icon mapping, it is only used for icon
141 // mapping migration. 140 // mapping migration.
142 class IconMappingEnumerator : public URLEnumeratorBase { 141 class IconMappingEnumerator : public URLEnumeratorBase {
143 public: 142 public:
144 IconMappingEnumerator(); 143 IconMappingEnumerator();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Tries to find the shortest URL beginning with |base| that strictly 179 // Tries to find the shortest URL beginning with |base| that strictly
181 // prefixes |url|, and has minimum visit_ and typed_counts as specified. 180 // prefixes |url|, and has minimum visit_ and typed_counts as specified.
182 // If found, fills in |info| and returns true; otherwise returns false, 181 // If found, fills in |info| and returns true; otherwise returns false,
183 // leaving |info| unchanged. 182 // leaving |info| unchanged.
184 // We allow matches of exactly |base| iff |allow_base| is true. 183 // We allow matches of exactly |base| iff |allow_base| is true.
185 bool FindShortestURLFromBase(const std::string& base, 184 bool FindShortestURLFromBase(const std::string& base,
186 const std::string& url, 185 const std::string& url,
187 int min_visits, 186 int min_visits,
188 int min_typed, 187 int min_typed,
189 bool allow_base, 188 bool allow_base,
190 history::URLRow* info); 189 URLRow* info);
191 190
192 // Keyword Search Terms ------------------------------------------------------ 191 // Keyword Search Terms ------------------------------------------------------
193 192
194 // Sets the search terms for the specified url/keyword pair. 193 // Sets the search terms for the specified url/keyword pair.
195 bool SetKeywordSearchTermsForURL(URLID url_id, 194 bool SetKeywordSearchTermsForURL(URLID url_id,
196 TemplateURLID keyword_id, 195 TemplateURLID keyword_id,
197 const string16& term); 196 const string16& term);
198 197
199 // Looks up a keyword search term given a url id. Returns all the search terms 198 // Looks up a keyword search term given a url id. Returns all the search terms
200 // in |rows|. Returns true on success. 199 // in |rows|. Returns true on success.
(...skipping 14 matching lines...) Expand all
215 TemplateURLID keyword_id, 214 TemplateURLID keyword_id,
216 const string16& prefix, 215 const string16& prefix,
217 int max_count, 216 int max_count,
218 std::vector<KeywordSearchTermVisit>* matches); 217 std::vector<KeywordSearchTermVisit>* matches);
219 218
220 // Deletes all searches matching |term|. 219 // Deletes all searches matching |term|.
221 bool DeleteKeywordSearchTerm(const string16& term); 220 bool DeleteKeywordSearchTerm(const string16& term);
222 221
223 // Migration ----------------------------------------------------------------- 222 // Migration -----------------------------------------------------------------
224 223
225 // Do to a bug we were setting the favicon of about:blank. This forces 224 // Due to a bug we were setting the favicon of about:blank. This forces
226 // about:blank to have no icon or title. Returns true on success, false if 225 // about:blank to have no icon or title. Returns true on success, false if
227 // the favicon couldn't be updated. 226 // the favicon couldn't be updated.
228 bool MigrateFromVersion11ToVersion12(); 227 bool MigrateFromVersion11ToVersion12();
229 228
230 // Initializes the given enumerator to enumerator all URL and icon mappings 229 // Initializes the given enumerator to enumerator all URL and icon mappings
231 // in the database. Only used for icon mapping migration. 230 // in the database. Only used for icon mapping migration.
232 bool InitIconMappingEnumeratorForEverything( 231 bool InitIconMappingEnumeratorForEverything(
233 IconMappingEnumerator* enumerator); 232 IconMappingEnumerator* enumerator);
234 233
235 protected: 234 protected:
236 friend class VisitDatabase; 235 // See URL_DATABASE_ROW_FIELDS below.
237
238 // See HISTORY_URL_ROW_FIELDS below.
239 static const char kURLRowFields[]; 236 static const char kURLRowFields[];
240 237
241 // The number of fiends in kURLRowFields. If callers need additional 238 // The number of fiends in kURLRowFields. If callers need additional
242 // fields, they can add their 0-based index to this value to get the index of 239 // fields, they can add their 0-based index to this value to get the index of
243 // fields following kURLRowFields. 240 // fields following kURLRowFields.
244 static const int kNumURLRowFields; 241 static const int kNumURLRowFields;
245 242
246 // Drops the starred_id column from urls, returning true on success. This does 243 // Drops the starred_id column from urls, returning true on success. This does
247 // nothing (and returns true) if the urls doesn't contain the starred_id 244 // nothing (and returns true) if the urls doesn't contain the starred_id
248 // column. 245 // column.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 virtual sql::Connection& GetDB() = 0; 282 virtual sql::Connection& GetDB() = 0;
286 283
287 private: 284 private:
288 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses 285 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses
289 // have keyword search terms. 286 // have keyword search terms.
290 bool has_keyword_search_terms_; 287 bool has_keyword_search_terms_;
291 288
292 DISALLOW_COPY_AND_ASSIGN(URLDatabase); 289 DISALLOW_COPY_AND_ASSIGN(URLDatabase);
293 }; 290 };
294 291
292 } // namespace history
293
295 // The fields and order expected by FillURLRow(). ID is guaranteed to be first 294 // The fields and order expected by FillURLRow(). ID is guaranteed to be first
296 // so that DISTINCT can be prepended to get distinct URLs. 295 // so that DISTINCT can be prepended to get distinct URLs.
297 // 296 //
298 // This is available BOTH as a macro and a static string (kURLRowFields). Use 297 // This is available BOTH as a macro and a static string (kURLRowFields). Use
299 // the macro if you want to put this in the middle of an otherwise constant 298 // the macro if you want to put this in the middle of an otherwise constant
300 // string, it will save time doing string appends. If you have to build a SQL 299 // string, it will save time doing string appends. If you have to build a SQL
301 // string dynamically anyway, use the constant, it will save space. 300 // string dynamically anyway, use the constant, it will save space.
302 #define HISTORY_URL_ROW_FIELDS \ 301 #define URL_DATABASE_ROW_FIELDS \
303 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \ 302 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \
304 "urls.last_visit_time, urls.hidden " 303 "urls.last_visit_time, urls.hidden "
305 304
306 } // history 305 #endif // CHROME_BROWSER_COMMON_URL_DATABASE_URL_DATABASE_H_
307
308 #endif // CHROME_BROWSER_HISTORY_URL_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/common/url_database/template_url_id.h ('k') | chrome/browser/common/url_database/url_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698