Commit ee3ab988 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Execute CommitQueuedOperations immediately on Android/iOS

When an Android app is killed, C++ destructors aren't guaranteed to be
called. When an app is killed within the 5 second delay for
CommitQueuedOperations, the operation is skipped completely. The end
result is non-Google search engines missing from the settings screen.

Bug: 1007070
Change-Id: Icd178a067a2b440ce538b03c4da82e0449306b52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837074Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703385}
parent 104cb383
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/search_engines/keyword_table.h" #include "components/search_engines/keyword_table.h"
#include "components/search_engines/template_url_data.h" #include "components/search_engines/template_url_data.h"
#include "components/webdata/common/web_data_results.h" #include "components/webdata/common/web_data_results.h"
...@@ -152,8 +153,16 @@ void KeywordWebDataService::AdjustBatchModeLevel(bool entering_batch_mode) { ...@@ -152,8 +153,16 @@ void KeywordWebDataService::AdjustBatchModeLevel(bool entering_batch_mode) {
DCHECK(batch_mode_level_); DCHECK(batch_mode_level_);
--batch_mode_level_; --batch_mode_level_;
if (!batch_mode_level_ && !queued_keyword_operations_.empty() && if (!batch_mode_level_ && !queued_keyword_operations_.empty() &&
!timer_.IsRunning()) !timer_.IsRunning()) {
// When killing an app on Android/iOS, shutdown isn't guaranteed to be
// called. Finishing this task immediately ensures the table is fully
// populated even if the app is killed before the timer expires.
#if defined(OS_ANDROID) || defined(OS_IOS)
CommitQueuedOperations();
#else
timer_.Reset(); timer_.Reset();
#endif
}
} }
} }
......
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