Commit 0408fed8 authored by Jun Cai's avatar Jun Cai Committed by Commit Bot

[omnibox] Convert base::Closure in //components/omnibox to Once or Repeating

This CL converts base::Closure in //components/omnibox to Once or
Repeating

Bug: 1007711
Change-Id: I6c1de227ecbf051841d43bd3eb85d88a9f23d564
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088294
Commit-Queue: Jun Cai <juncai@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746976}
parent 1d6f5141
...@@ -67,20 +67,22 @@ class TestingSchemeClassifier : public AutocompleteSchemeClassifier { ...@@ -67,20 +67,22 @@ class TestingSchemeClassifier : public AutocompleteSchemeClassifier {
class AutocompleteProviderClientWithClosure class AutocompleteProviderClientWithClosure
: public MockAutocompleteProviderClient { : public MockAutocompleteProviderClient {
public: public:
AutocompleteProviderClientWithClosure() {} AutocompleteProviderClientWithClosure() = default;
void set_closure(const base::Closure& closure) { closure_ = closure; } void set_closure(const base::RepeatingClosure& closure) {
closure_ = closure;
}
private: private:
void OnAutocompleteControllerResultReady( void OnAutocompleteControllerResultReady(
AutocompleteController* controller) override { AutocompleteController* controller) override {
if (!closure_.is_null()) if (closure_)
closure_.Run(); closure_.Run();
if (base::RunLoop::IsRunningOnCurrentThread()) if (base::RunLoop::IsRunningOnCurrentThread())
base::RunLoop::QuitCurrentWhenIdleDeprecated(); base::RunLoop::QuitCurrentWhenIdleDeprecated();
} }
base::Closure closure_; base::RepeatingClosure closure_;
DISALLOW_COPY_AND_ASSIGN(AutocompleteProviderClientWithClosure); DISALLOW_COPY_AND_ASSIGN(AutocompleteProviderClientWithClosure);
}; };
......
...@@ -79,7 +79,8 @@ class BaseSearchProviderTest : public testing::Test { ...@@ -79,7 +79,8 @@ class BaseSearchProviderTest : public testing::Test {
nullptr /* PrefService */, nullptr /* PrefService */,
std::unique_ptr<SearchTermsData>(new SearchTermsData), std::unique_ptr<SearchTermsData>(new SearchTermsData),
nullptr /* KeywordWebDataService */, nullptr /* KeywordWebDataService */,
std::unique_ptr<TemplateURLServiceClient>(), base::Closure())); std::unique_ptr<TemplateURLServiceClient>(),
base::RepeatingClosure()));
client_.reset(new MockAutocompleteProviderClient()); client_.reset(new MockAutocompleteProviderClient());
client_->set_template_url_service(std::move(template_url_service)); client_->set_template_url_service(std::move(template_url_service));
provider_ = new NiceMock<TestBaseSearchProvider>( provider_ = new NiceMock<TestBaseSearchProvider>(
......
...@@ -96,7 +96,7 @@ void StringToTerms(const char* search_string, ...@@ -96,7 +96,7 @@ void StringToTerms(const char* search_string,
// Observer class so the unit tests can wait while the cache is being saved. // Observer class so the unit tests can wait while the cache is being saved.
class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver { class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver {
public: public:
explicit CacheFileSaverObserver(const base::Closure& task); explicit CacheFileSaverObserver(const base::RepeatingClosure& task);
bool succeeded() { return succeeded_; } bool succeeded() { return succeeded_; }
...@@ -104,16 +104,15 @@ class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver { ...@@ -104,16 +104,15 @@ class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver {
// SaveCacheObserver implementation. // SaveCacheObserver implementation.
void OnCacheSaveFinished(bool succeeded) override; void OnCacheSaveFinished(bool succeeded) override;
base::Closure task_; base::RepeatingClosure task_;
bool succeeded_; bool succeeded_;
DISALLOW_COPY_AND_ASSIGN(CacheFileSaverObserver); DISALLOW_COPY_AND_ASSIGN(CacheFileSaverObserver);
}; };
CacheFileSaverObserver::CacheFileSaverObserver(const base::Closure& task) CacheFileSaverObserver::CacheFileSaverObserver(
: task_(task), const base::RepeatingClosure& task)
succeeded_(false) { : task_(task), succeeded_(false) {}
}
void CacheFileSaverObserver::OnCacheSaveFinished(bool succeeded) { void CacheFileSaverObserver::OnCacheSaveFinished(bool succeeded) {
succeeded_ = succeeded; succeeded_ = succeeded;
......
...@@ -48,7 +48,8 @@ TestOmniboxClient::CreateAutocompleteProviderClient() { ...@@ -48,7 +48,8 @@ TestOmniboxClient::CreateAutocompleteProviderClient() {
nullptr /* PrefService */, nullptr /* PrefService */,
std::unique_ptr<SearchTermsData>(new SearchTermsData), std::unique_ptr<SearchTermsData>(new SearchTermsData),
nullptr /* KeywordWebDataService */, nullptr /* KeywordWebDataService */,
std::unique_ptr<TemplateURLServiceClient>(), base::Closure())); std::unique_ptr<TemplateURLServiceClient>(),
base::RepeatingClosure()));
// Save a reference to the created TemplateURLService for test use. // Save a reference to the created TemplateURLService for test use.
template_url_service_ = template_url_service.get(); template_url_service_ = template_url_service.get();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment