Replace deprecated base::NonThreadSafe in extensions in favor of SequenceChecker.
Note to crash team: This CL is a refactor and has no intended behavior change.
This change was scripted by https://crbug.com/676387#c8.
Note-worthy for the reviewer:
* SequenceChecker enforces thread-safety but not thread-affinity!
If the classes that were updated are thread-affine (use thread local
storage or a third-party API that does) they should be migrated to
ThreadChecker instead.
* ~NonThreadSafe() used to implicitly check in its destructor
~Sequence/ThreadChecker() doesn't by design. To keep this CL a
no-op, an explicit check was added to the destructor of migrated
classes.
* NonThreadSafe used to provide access to subclasses, as such
the |sequence_checker_| member was made protected rather than
private where necessary.
BUG=676387
This CL was uploaded by git cl split.
[email protected]
Review-Url: https://codereview.chromium.org/2915523002
Cr-Commit-Position: refs/heads/master@{#476280}
diff --git a/extensions/browser/warning_service.cc b/extensions/browser/warning_service.cc
index c6f643b..1f5cf12 100644
--- a/extensions/browser/warning_service.cc
+++ b/extensions/browser/warning_service.cc
@@ -16,14 +16,16 @@
WarningService::WarningService(content::BrowserContext* browser_context)
: browser_context_(browser_context), extension_registry_observer_(this) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (browser_context_) {
extension_registry_observer_.Add(ExtensionRegistry::Get(
ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context_)));
}
}
-WarningService::~WarningService() {}
+WarningService::~WarningService() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
// static
WarningService* WarningService::Get(content::BrowserContext* browser_context) {
@@ -32,7 +34,7 @@
void WarningService::ClearWarnings(
const std::set<Warning::WarningType>& types) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
ExtensionIdSet affected_extensions;
for (WarningSet::iterator i = warnings_.begin();
i != warnings_.end();) {
@@ -50,7 +52,7 @@
std::set<Warning::WarningType> WarningService::
GetWarningTypesAffectingExtension(const std::string& extension_id) const {
- DCHECK(CalledOnValidThread());
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::set<Warning::WarningType> result;
for (WarningSet::const_iterator i = warnings_.begin();
i != warnings_.end(); ++i) {
@@ -62,7 +64,7 @@
std::vector<std::string> WarningService::GetWarningMessagesForExtension(
const std::string& extension_id) const {
- DCHECK(CalledOnValidThread());
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::vector<std::string> result;
const ExtensionSet& extension_set =
@@ -77,7 +79,7 @@
}
void WarningService::AddWarnings(const WarningSet& warnings) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
ExtensionIdSet affected_extensions;
for (const Warning& warning : warnings) {