OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/omnibox/browser/fake_autocomplete_provider_client.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "components/bookmarks/browser/bookmark_model.h" |
| 9 #include "components/bookmarks/test/test_bookmark_client.h" |
| 10 #include "components/history/core/browser/history_service.h" |
| 11 #include "components/history/core/test/history_service_test_util.h" |
| 12 #include "components/omnibox/browser/in_memory_url_index.h" |
| 13 #include "components/omnibox/browser/in_memory_url_index_test_util.h" |
| 14 |
| 15 namespace { |
| 16 |
| 17 // Arbitrary number > 1 so that tasks don't run sequentially. |
| 18 constexpr int kWorkerThreadCount = 3; |
| 19 |
| 20 } // namespace |
| 21 |
| 22 FakeAutocompleteProviderClient::FakeAutocompleteProviderClient() |
| 23 : pool_owner_(kWorkerThreadCount, "Background Pool") { |
| 24 bookmark_model_ = bookmarks::TestBookmarkClient::CreateModel(); |
| 25 |
| 26 CHECK(history_dir_.CreateUniqueTempDir()); |
| 27 history_service_ = |
| 28 history::CreateHistoryService(history_dir_.GetPath(), true); |
| 29 |
| 30 in_memory_url_index_.reset(new InMemoryURLIndex( |
| 31 bookmark_model_.get(), history_service_.get(), nullptr, |
| 32 pool_owner_.pool().get(), history_dir_.GetPath(), SchemeSet())); |
| 33 in_memory_url_index_->Init(); |
| 34 } |
| 35 |
| 36 FakeAutocompleteProviderClient::~FakeAutocompleteProviderClient() = default; |
| 37 |
| 38 const AutocompleteSchemeClassifier& |
| 39 FakeAutocompleteProviderClient::GetSchemeClassifier() const { |
| 40 return scheme_classifier_; |
| 41 } |
| 42 |
| 43 const SearchTermsData& FakeAutocompleteProviderClient::GetSearchTermsData() |
| 44 const { |
| 45 return search_terms_data_; |
| 46 } |
| 47 |
| 48 history::HistoryService* FakeAutocompleteProviderClient::GetHistoryService() { |
| 49 return history_service_.get(); |
| 50 } |
| 51 |
| 52 bookmarks::BookmarkModel* FakeAutocompleteProviderClient::GetBookmarkModel() { |
| 53 return bookmark_model_.get(); |
| 54 } |
| 55 |
| 56 InMemoryURLIndex* FakeAutocompleteProviderClient::GetInMemoryURLIndex() { |
| 57 return in_memory_url_index_.get(); |
| 58 } |
OLD | NEW |