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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 // field on it will be read by the second pass -- see comments in | 581 // field on it will be read by the second pass -- see comments in |
582 // DoAutocomplete(). | 582 // DoAutocomplete(). |
583 } | 583 } |
584 | 584 |
585 // Pass 2: Ask the history service to call us back on the history thread, | 585 // Pass 2: Ask the history service to call us back on the history thread, |
586 // where we can read the full on-disk DB. | 586 // where we can read the full on-disk DB. |
587 if (input.want_asynchronous_matches()) { | 587 if (input.want_asynchronous_matches()) { |
588 done_ = false; | 588 done_ = false; |
589 params_ = params.release(); // This object will be destroyed in | 589 params_ = params.release(); // This object will be destroyed in |
590 // QueryComplete() once we're done with it. | 590 // QueryComplete() once we're done with it. |
591 history_service->ScheduleAutocomplete(this, params_); | 591 history_service->ScheduleAutocomplete( |
| 592 base::Bind(&HistoryURLProvider::ExecuteWithDB, this, params_)); |
592 } | 593 } |
593 } | 594 } |
594 | 595 |
595 void HistoryURLProvider::Stop(bool clear_cached_results) { | 596 void HistoryURLProvider::Stop(bool clear_cached_results) { |
596 done_ = true; | 597 done_ = true; |
597 | 598 |
598 if (params_) | 599 if (params_) |
599 params_->cancel_flag.Set(); | 600 params_->cancel_flag.Set(); |
600 } | 601 } |
601 | 602 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 match.contents.length(), ACMatchClassification::URL, | 655 match.contents.length(), ACMatchClassification::URL, |
655 &match.contents_class); | 656 &match.contents_class); |
656 } | 657 } |
657 | 658 |
658 match.is_history_what_you_typed_match = true; | 659 match.is_history_what_you_typed_match = true; |
659 } | 660 } |
660 | 661 |
661 return match; | 662 return match; |
662 } | 663 } |
663 | 664 |
664 void HistoryURLProvider::ExecuteWithDB(history::HistoryBackend* backend, | 665 void HistoryURLProvider::ExecuteWithDB(HistoryURLProviderParams* params, |
665 history::URLDatabase* db, | 666 history::HistoryBackend* backend, |
666 HistoryURLProviderParams* params) { | 667 history::URLDatabase* db) { |
667 // We may get called with a NULL database if it couldn't be properly | 668 // We may get called with a NULL database if it couldn't be properly |
668 // initialized. | 669 // initialized. |
669 if (!db) { | 670 if (!db) { |
670 params->failed = true; | 671 params->failed = true; |
671 } else if (!params->cancel_flag.IsSet()) { | 672 } else if (!params->cancel_flag.IsSet()) { |
672 base::TimeTicks beginning_time = base::TimeTicks::Now(); | 673 base::TimeTicks beginning_time = base::TimeTicks::Now(); |
673 | 674 |
674 DoAutocomplete(backend, db, params); | 675 DoAutocomplete(backend, db, params); |
675 | 676 |
676 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", | 677 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1199 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
1199 match.contents.length(), ACMatchClassification::URL, | 1200 match.contents.length(), ACMatchClassification::URL, |
1200 &match.contents_class); | 1201 &match.contents_class); |
1201 } | 1202 } |
1202 match.description = info.title(); | 1203 match.description = info.title(); |
1203 match.description_class = | 1204 match.description_class = |
1204 ClassifyDescription(params.input.text(), match.description); | 1205 ClassifyDescription(params.input.text(), match.description); |
1205 RecordAdditionalInfoFromUrlRow(info, &match); | 1206 RecordAdditionalInfoFromUrlRow(info, &match); |
1206 return match; | 1207 return match; |
1207 } | 1208 } |
OLD | NEW |