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

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

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: Fix kSafeRegexWordBoundary for Korean. 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
« no previous file with comments | « chrome/browser/history/url_database.h ('k') | chrome/browser/history/visit_database.h » ('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) 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 #include "chrome/browser/history/url_database.h" 5 #include "chrome/browser/history/url_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 statement.BindInt(3, min_typed); 351 statement.BindInt(3, min_typed);
352 352
353 if (!statement.Step()) 353 if (!statement.Step())
354 return false; 354 return false;
355 355
356 DCHECK(info); 356 DCHECK(info);
357 FillURLRow(statement, info); 357 FillURLRow(statement, info);
358 return true; 358 return true;
359 } 359 }
360 360
361 bool URLDatabase::GetTextMatches(const string16& query, URLRows* results) {
362 std::vector<string16> regexp_queries;
363 query_parser_.ParseQueryAsRegexps(query, &regexp_queries);
364
365 std::string sql("SELECT ");
366 sql.append(kURLRowFields);
367 sql.append(" FROM urls WHERE ");
368 for (size_t i = 0; i < regexp_queries.size(); ++i) {
369 sql.append(" (url REGEXP ? OR title REGEXP ?) AND ");
370 }
371 sql.append(" hidden = 0");
372 sql::Statement statement(GetDB().GetUniqueStatement(sql.c_str()));
Scott Hess - ex-Googler 2013/06/12 17:38:34 You may want to reference http://crbug.com/248608
rmcilroy 2013/06/13 15:32:05 Ack (no longer required).
373 for (size_t i = 0; i < regexp_queries.size(); ++i) {
374 statement.BindString16(2 * i, regexp_queries[i]);
375 statement.BindString16((2 * i) + 1, regexp_queries[i]);
376 }
377
378 while (statement.Step()) {
379 history::URLRow info;
380 FillURLRow(statement, &info);
381 if (info.url().is_valid())
382 results->push_back(info);
383 }
384 return !results->empty();
385 }
386
361 bool URLDatabase::InitKeywordSearchTermsTable() { 387 bool URLDatabase::InitKeywordSearchTermsTable() {
362 has_keyword_search_terms_ = true; 388 has_keyword_search_terms_ = true;
363 if (!GetDB().DoesTableExist("keyword_search_terms")) { 389 if (!GetDB().DoesTableExist("keyword_search_terms")) {
364 if (!GetDB().Execute("CREATE TABLE keyword_search_terms (" 390 if (!GetDB().Execute("CREATE TABLE keyword_search_terms ("
365 "keyword_id INTEGER NOT NULL," // ID of the TemplateURL. 391 "keyword_id INTEGER NOT NULL," // ID of the TemplateURL.
366 "url_id INTEGER NOT NULL," // ID of the url. 392 "url_id INTEGER NOT NULL," // ID of the url.
367 "lower_term LONGVARCHAR NOT NULL," // The search term, in lower case. 393 "lower_term LONGVARCHAR NOT NULL," // The search term, in lower case.
368 "term LONGVARCHAR NOT NULL)")) // The actual search term. 394 "term LONGVARCHAR NOT NULL)")) // The actual search term.
369 return false; 395 return false;
370 } 396 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return GetDB().Execute(sql.c_str()); 595 return GetDB().Execute(sql.c_str());
570 } 596 }
571 597
572 bool URLDatabase::CreateMainURLIndex() { 598 bool URLDatabase::CreateMainURLIndex() {
573 // Index over URLs so we can quickly look up based on URL. 599 // Index over URLs so we can quickly look up based on URL.
574 return GetDB().Execute( 600 return GetDB().Execute(
575 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); 601 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)");
576 } 602 }
577 603
578 } // namespace history 604 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/url_database.h ('k') | chrome/browser/history/visit_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698