Commit 16f13bff authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Don't block shutdown in chrome/browser/win/conflicts/

This CL ensures that the ModuleDatabase task runner, the inspection
results cache task runner and the module blacklist cache task runner
don't block shutdown.

Also, this CL changes the inspection results cache so that it is updated
atomically.

Bug: 1021904, 1022041
Change-Id: Ia87e13f60e00725583f95c55e231edfd4d7648b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899750Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713191}
parent 7f163a4b
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/important_file_writer.h"
#include "base/hash/md5.h" #include "base/hash/md5.h"
#include "base/pickle.h" #include "base/pickle.h"
#include "base/strings/string_piece.h"
namespace { namespace {
...@@ -232,6 +234,10 @@ bool WriteInspectionResultsCache( ...@@ -232,6 +234,10 @@ bool WriteInspectionResultsCache(
base::Pickle pickle = base::Pickle pickle =
SerializeInspectionResultsCache(inspection_results_cache); SerializeInspectionResultsCache(inspection_results_cache);
return base::WriteFile(file_path, static_cast<const char*>(pickle.data()),
pickle.size()) == static_cast<int>(pickle.size()); // TODO(1022041): Investigate if using WriteFileAtomically() in a
// CONTINUE_ON_SHUTDOWN sequence can cause too many corrupted caches.
return base::ImportantFileWriter::WriteFileAtomically(
file_path, base::StringPiece(static_cast<const char*>(pickle.data()),
pickle.size()));
} }
...@@ -161,6 +161,8 @@ bool WriteModuleBlacklistCache( ...@@ -161,6 +161,8 @@ bool WriteModuleBlacklistCache(
sizeof(third_party_dlls::PackedListModule) * blacklisted_modules.size()); sizeof(third_party_dlls::PackedListModule) * blacklisted_modules.size());
file_contents.append(std::begin(md5_digest->a), std::end(md5_digest->a)); file_contents.append(std::begin(md5_digest->a), std::end(md5_digest->a));
// TODO(1022041): Investigate if using WriteFileAtomically() in a
// CONTINUE_ON_SHUTDOWN sequence doesn't cause too many corrupted caches.
return base::ImportantFileWriter::WriteFileAtomically( return base::ImportantFileWriter::WriteFileAtomically(
module_blacklist_cache_path, file_contents); module_blacklist_cache_path, file_contents);
} }
......
...@@ -132,7 +132,7 @@ scoped_refptr<base::SequencedTaskRunner> ModuleDatabase::GetTaskRunner() { ...@@ -132,7 +132,7 @@ scoped_refptr<base::SequencedTaskRunner> ModuleDatabase::GetTaskRunner() {
static base::LazySequencedTaskRunner g_distinct_task_runner = static base::LazySequencedTaskRunner g_distinct_task_runner =
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER( LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
base::TaskTraits(base::ThreadPool(), base::TaskPriority::BEST_EFFORT, base::TaskTraits(base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN)); base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
return base::FeatureList::IsEnabled(kDistinctModuleDatabaseSequence) return base::FeatureList::IsEnabled(kDistinctModuleDatabaseSequence)
? g_distinct_task_runner.Get() ? g_distinct_task_runner.Get()
......
...@@ -91,7 +91,7 @@ ModuleInspector::ModuleInspector( ...@@ -91,7 +91,7 @@ ModuleInspector::ModuleInspector(
cache_task_runner_(base::CreateSequencedTaskRunner( cache_task_runner_(base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock(), {base::ThreadPool(), base::MayBlock(),
base::TaskPriority::BEST_EFFORT, base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN})), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN})),
inspection_results_cache_read_(false), inspection_results_cache_read_(false),
flush_inspection_results_timer_( flush_inspection_results_timer_(
FROM_HERE, FROM_HERE,
......
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