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 #include "chrome/browser/autocomplete/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 // field on it will be read by the second pass -- see comments in | 529 // field on it will be read by the second pass -- see comments in |
530 // DoAutocomplete(). | 530 // DoAutocomplete(). |
531 } | 531 } |
532 | 532 |
533 // Pass 2: Ask the history service to call us back on the history thread, | 533 // Pass 2: Ask the history service to call us back on the history thread, |
534 // where we can read the full on-disk DB. | 534 // where we can read the full on-disk DB. |
535 if (input.want_asynchronous_matches()) { | 535 if (input.want_asynchronous_matches()) { |
536 done_ = false; | 536 done_ = false; |
537 params_ = params.release(); // This object will be destroyed in | 537 params_ = params.release(); // This object will be destroyed in |
538 // QueryComplete() once we're done with it. | 538 // QueryComplete() once we're done with it. |
539 history_service->ScheduleAutocomplete(this, params_); | 539 history_service->ScheduleAutocomplete( |
| 540 base::Bind(&HistoryURLProvider::ExecuteWithDB, this, params_)); |
540 } | 541 } |
541 } | 542 } |
542 | 543 |
543 void HistoryURLProvider::Stop(bool clear_cached_results) { | 544 void HistoryURLProvider::Stop(bool clear_cached_results) { |
544 done_ = true; | 545 done_ = true; |
545 | 546 |
546 if (params_) | 547 if (params_) |
547 params_->cancel_flag.Set(); | 548 params_->cancel_flag.Set(); |
548 } | 549 } |
549 | 550 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 match.contents.length(), ACMatchClassification::URL, | 602 match.contents.length(), ACMatchClassification::URL, |
602 &match.contents_class); | 603 &match.contents_class); |
603 } | 604 } |
604 | 605 |
605 match.is_history_what_you_typed_match = true; | 606 match.is_history_what_you_typed_match = true; |
606 } | 607 } |
607 | 608 |
608 return match; | 609 return match; |
609 } | 610 } |
610 | 611 |
611 void HistoryURLProvider::ExecuteWithDB(history::HistoryBackend* backend, | 612 void HistoryURLProvider::ExecuteWithDB(HistoryURLProviderParams* params, |
612 history::URLDatabase* db, | 613 history::HistoryBackend* backend, |
613 HistoryURLProviderParams* params) { | 614 history::URLDatabase* db) { |
614 // We may get called with a NULL database if it couldn't be properly | 615 // We may get called with a NULL database if it couldn't be properly |
615 // initialized. | 616 // initialized. |
616 if (!db) { | 617 if (!db) { |
617 params->failed = true; | 618 params->failed = true; |
618 } else if (!params->cancel_flag.IsSet()) { | 619 } else if (!params->cancel_flag.IsSet()) { |
619 base::TimeTicks beginning_time = base::TimeTicks::Now(); | 620 base::TimeTicks beginning_time = base::TimeTicks::Now(); |
620 | 621 |
621 DoAutocomplete(backend, db, params); | 622 DoAutocomplete(backend, db, params); |
622 | 623 |
623 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", | 624 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1146 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
1146 match.contents.length(), ACMatchClassification::URL, | 1147 match.contents.length(), ACMatchClassification::URL, |
1147 &match.contents_class); | 1148 &match.contents_class); |
1148 } | 1149 } |
1149 match.description = info.title(); | 1150 match.description = info.title(); |
1150 match.description_class = | 1151 match.description_class = |
1151 ClassifyDescription(params.input.text(), match.description); | 1152 ClassifyDescription(params.input.text(), match.description); |
1152 RecordAdditionalInfoFromUrlRow(info, &match); | 1153 RecordAdditionalInfoFromUrlRow(info, &match); |
1153 return match; | 1154 return match; |
1154 } | 1155 } |
OLD | NEW |