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

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

Issue 16776004: Replace FTS in the history_service with a brute force text search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address scotts comments & fix unit tests. Created 7 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
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_HISTORY_URL_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_URL_DATABASE_H_ 6 #define CHROME_BROWSER_HISTORY_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/history/history_types.h"
10 #include "chrome/browser/history/query_parser.h"
10 #include "chrome/browser/search_engines/template_url_id.h" 11 #include "chrome/browser/search_engines/template_url_id.h"
11 #include "sql/statement.h" 12 #include "sql/statement.h"
12 13
13 class GURL; 14 class GURL;
14 15
15 namespace sql { 16 namespace sql {
16 class Connection; 17 class Connection;
17 } 18 }
18 19
19 namespace history { 20 namespace history {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // If found, fills in |info| and returns true; otherwise returns false, 183 // If found, fills in |info| and returns true; otherwise returns false,
183 // leaving |info| unchanged. 184 // leaving |info| unchanged.
184 // We allow matches of exactly |base| iff |allow_base| is true. 185 // We allow matches of exactly |base| iff |allow_base| is true.
185 bool FindShortestURLFromBase(const std::string& base, 186 bool FindShortestURLFromBase(const std::string& base,
186 const std::string& url, 187 const std::string& url,
187 int min_visits, 188 int min_visits,
188 int min_typed, 189 int min_typed,
189 bool allow_base, 190 bool allow_base,
190 history::URLRow* info); 191 history::URLRow* info);
191 192
193 // History search ------------------------------------------------------------
194
195 // Performs a brute force search over the database to find any URLs or titles
196 // which match the |query| string. Returns any matches in |results|.
197 bool GetTextMatches(const string16& query, URLRows* results);
198
192 // Keyword Search Terms ------------------------------------------------------ 199 // Keyword Search Terms ------------------------------------------------------
193 200
194 // Sets the search terms for the specified url/keyword pair. 201 // Sets the search terms for the specified url/keyword pair.
195 bool SetKeywordSearchTermsForURL(URLID url_id, 202 bool SetKeywordSearchTermsForURL(URLID url_id,
196 TemplateURLID keyword_id, 203 TemplateURLID keyword_id,
197 const string16& term); 204 const string16& term);
198 205
199 // Looks up a keyword search term given a url id. Returns all the search terms 206 // Looks up a keyword search term given a url id. Returns all the search terms
200 // in |rows|. Returns true on success. 207 // in |rows|. Returns true on success.
201 bool GetKeywordSearchTermRow(URLID url_id, KeywordSearchTermRow* row); 208 bool GetKeywordSearchTermRow(URLID url_id, KeywordSearchTermRow* row);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 289
283 // Returns the database for the functions in this interface. The decendent of 290 // Returns the database for the functions in this interface. The decendent of
284 // this class implements these functions to return its objects. 291 // this class implements these functions to return its objects.
285 virtual sql::Connection& GetDB() = 0; 292 virtual sql::Connection& GetDB() = 0;
286 293
287 private: 294 private:
288 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses 295 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses
289 // have keyword search terms. 296 // have keyword search terms.
290 bool has_keyword_search_terms_; 297 bool has_keyword_search_terms_;
291 298
299 QueryParser query_parser_;
300
292 DISALLOW_COPY_AND_ASSIGN(URLDatabase); 301 DISALLOW_COPY_AND_ASSIGN(URLDatabase);
293 }; 302 };
294 303
295 // The fields and order expected by FillURLRow(). ID is guaranteed to be first 304 // The fields and order expected by FillURLRow(). ID is guaranteed to be first
296 // so that DISTINCT can be prepended to get distinct URLs. 305 // so that DISTINCT can be prepended to get distinct URLs.
297 // 306 //
298 // This is available BOTH as a macro and a static string (kURLRowFields). Use 307 // 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 308 // 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 309 // 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. 310 // string dynamically anyway, use the constant, it will save space.
302 #define HISTORY_URL_ROW_FIELDS \ 311 #define HISTORY_URL_ROW_FIELDS \
303 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \ 312 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \
304 "urls.last_visit_time, urls.hidden " 313 "urls.last_visit_time, urls.hidden "
305 314
306 } // history 315 } // namespace history
307 316
308 #endif // CHROME_BROWSER_HISTORY_URL_DATABASE_H_ 317 #endif // CHROME_BROWSER_HISTORY_URL_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698