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 "components/omnibox/browser/history_url_provider.h" | 5 #include "components/omnibox/browser/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 type_ = UNVISITED_INTRANET; | 419 type_ = UNVISITED_INTRANET; |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 HistoryURLProviderParams::HistoryURLProviderParams( | 423 HistoryURLProviderParams::HistoryURLProviderParams( |
424 const AutocompleteInput& input, | 424 const AutocompleteInput& input, |
425 bool trim_http, | 425 bool trim_http, |
426 const AutocompleteMatch& what_you_typed_match, | 426 const AutocompleteMatch& what_you_typed_match, |
427 TemplateURL* default_search_provider, | 427 TemplateURL* default_search_provider, |
428 const SearchTermsData& search_terms_data) | 428 const SearchTermsData& search_terms_data) |
429 : message_loop(base::MessageLoop::current()), | 429 : input(input), |
430 input(input), | |
431 prevent_inline_autocomplete(input.prevent_inline_autocomplete()), | 430 prevent_inline_autocomplete(input.prevent_inline_autocomplete()), |
432 trim_http(trim_http), | 431 trim_http(trim_http), |
433 what_you_typed_match(what_you_typed_match), | 432 what_you_typed_match(what_you_typed_match), |
434 failed(false), | 433 failed(false), |
435 exact_suggestion_is_in_history(false), | 434 exact_suggestion_is_in_history(false), |
436 promote_type(NEITHER), | 435 promote_type(NEITHER), |
437 default_search_provider(default_search_provider ? | 436 default_search_provider( |
438 new TemplateURL(default_search_provider->data()) : nullptr), | 437 default_search_provider |
439 search_terms_data(new SearchTermsDataSnapshot(search_terms_data)) { | 438 ? new TemplateURL(default_search_provider->data()) |
440 } | 439 : nullptr), |
| 440 search_terms_data(new SearchTermsDataSnapshot(search_terms_data)) {} |
441 | 441 |
442 HistoryURLProviderParams::~HistoryURLProviderParams() { | 442 HistoryURLProviderParams::~HistoryURLProviderParams() { |
443 } | 443 } |
444 | 444 |
445 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderClient* client, | 445 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderClient* client, |
446 AutocompleteProviderListener* listener) | 446 AutocompleteProviderListener* listener) |
447 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_URL, client), | 447 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_URL, client), |
448 listener_(listener), | 448 listener_(listener), |
449 params_(nullptr), | 449 params_(nullptr), |
450 search_url_database_(OmniboxFieldTrial::HUPSearchDatabase()) { | 450 search_url_database_(OmniboxFieldTrial::HUPSearchDatabase()) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 params->failed = true; | 633 params->failed = true; |
634 } else if (!params->cancel_flag.IsSet()) { | 634 } else if (!params->cancel_flag.IsSet()) { |
635 base::TimeTicks beginning_time = base::TimeTicks::Now(); | 635 base::TimeTicks beginning_time = base::TimeTicks::Now(); |
636 | 636 |
637 DoAutocomplete(backend, db, params); | 637 DoAutocomplete(backend, db, params); |
638 | 638 |
639 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", | 639 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", |
640 base::TimeTicks::Now() - beginning_time); | 640 base::TimeTicks::Now() - beginning_time); |
641 } | 641 } |
642 | 642 |
643 // Return the results (if any) to the main thread. | 643 // Return the results (if any) to the originating sequence. |
644 params->message_loop->task_runner()->PostTask( | 644 params->origin_task_runner->PostTask( |
645 FROM_HERE, base::Bind(&HistoryURLProvider::QueryComplete, this, params)); | 645 FROM_HERE, base::Bind(&HistoryURLProvider::QueryComplete, this, params)); |
646 } | 646 } |
647 | 647 |
648 HistoryURLProvider::~HistoryURLProvider() { | 648 HistoryURLProvider::~HistoryURLProvider() { |
649 // Note: This object can get leaked on shutdown if there are pending | 649 // Note: This object can get leaked on shutdown if there are pending |
650 // requests on the database (which hold a reference to us). Normally, these | 650 // requests on the database (which hold a reference to us). Normally, these |
651 // messages get flushed for each thread. We do a round trip from main, to | 651 // messages get flushed for each thread. We do a round trip from main, to |
652 // history, back to main while holding a reference. If the main thread | 652 // history, back to main while holding a reference. If the main thread |
653 // completes before the history thread, the message to delegate back to the | 653 // completes before the history thread, the message to delegate back to the |
654 // main thread will not run and the reference will leak. Therefore, don't do | 654 // main thread will not run and the reference will leak. Therefore, don't do |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1192 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
1193 match.contents.length(), ACMatchClassification::URL, | 1193 match.contents.length(), ACMatchClassification::URL, |
1194 &match.contents_class); | 1194 &match.contents_class); |
1195 } | 1195 } |
1196 match.description = info.title(); | 1196 match.description = info.title(); |
1197 match.description_class = | 1197 match.description_class = |
1198 ClassifyDescription(params.input.text(), match.description); | 1198 ClassifyDescription(params.input.text(), match.description); |
1199 RecordAdditionalInfoFromUrlRow(info, &match); | 1199 RecordAdditionalInfoFromUrlRow(info, &match); |
1200 return match; | 1200 return match; |
1201 } | 1201 } |
OLD | NEW |