Commit 3842d5d5 authored by Vitaliy Rebrov's avatar Vitaliy Rebrov Committed by Commit Bot

Fixed memory leak in autocomplete tests because of history service

It's important to explicitly shutdown history service if it's using own
thread. Otherwise thread will keep working after calling RunUntilIdle()
and will be able to post tasks to UI thread. This tasks will not be
processed which will lead to leaking of HistoryDBTask (which is
destroyed in this tasks).

Change-Id: I63495794c257983dfdae3f3c7671d89e96eea8f8
Reviewed-on: https://chromium-review.googlesource.com/c/1280545Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Commit-Queue: Alexander Yashkin <a-v-y@yandex-team.ru>
Cr-Commit-Position: refs/heads/master@{#599930}
parent 48c7a842
...@@ -44,6 +44,9 @@ FakeAutocompleteProviderClient::~FakeAutocompleteProviderClient() { ...@@ -44,6 +44,9 @@ FakeAutocompleteProviderClient::~FakeAutocompleteProviderClient() {
// its destructor. // its destructor.
GetInMemoryURLIndex()->Shutdown(); GetInMemoryURLIndex()->Shutdown();
set_in_memory_url_index(nullptr); set_in_memory_url_index(nullptr);
// History service can have its own thread. So we need to explicitly shut down
// it to prevent memory leaks.
GetHistoryService()->Shutdown();
// Note that RunUntilIdle() must still be called after this, from // Note that RunUntilIdle() must still be called after this, from
// whichever task model is being used, probably ScopedTaskEnvironment, // whichever task model is being used, probably ScopedTaskEnvironment,
// or there will be memory leaks. // or there will be memory leaks.
......
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