Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: net/dns/dns_config_service_win.cc

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: another compile nit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/dns/dns_config_service_win.cc
diff --git a/net/dns/dns_config_service_win.cc b/net/dns/dns_config_service_win.cc
index 14a157bc6216b8c3a81c9834bf6e273ba52048f3..2428a3a58b749cdc04813de7cb3e8ca80b48da43 100644
--- a/net/dns/dns_config_service_win.cc
+++ b/net/dns/dns_config_service_win.cc
@@ -18,12 +18,12 @@
#include "base/macros.h"
#include "base/memory/free_deleter.h"
#include "base/metrics/histogram_macros.h"
+#include "base/sequence_checker.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
-#include "base/threading/non_thread_safe.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -69,16 +69,18 @@ enum HostsParseWinResult {
};
// Convenience for reading values using RegKey.
-class RegistryReader : public base::NonThreadSafe {
+class RegistryReader {
public:
explicit RegistryReader(const wchar_t* key) {
// Ignoring the result. |key_.Valid()| will catch failures.
key_.Open(HKEY_LOCAL_MACHINE, key, KEY_QUERY_VALUE);
}
+ ~RegistryReader() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); }
+
bool ReadString(const wchar_t* name,
DnsSystemSettings::RegString* out) const {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
out->set = false;
if (!key_.Valid()) {
// Assume that if the |key_| is invalid then the key is missing.
@@ -94,7 +96,7 @@ class RegistryReader : public base::NonThreadSafe {
bool ReadDword(const wchar_t* name,
DnsSystemSettings::RegDword* out) const {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
out->set = false;
if (!key_.Valid()) {
// Assume that if the |key_| is invalid then the key is missing.
@@ -111,6 +113,8 @@ class RegistryReader : public base::NonThreadSafe {
private:
base::win::RegKey key_;
+ SEQUENCE_CHECKER(sequence_checker_);
+
DISALLOW_COPY_AND_ASSIGN(RegistryReader);
};
@@ -287,13 +291,15 @@ HostsParseWinResult AddLocalhostEntries(DnsHosts* hosts) {
}
// Watches a single registry key for changes.
-class RegistryWatcher : public base::NonThreadSafe {
+class RegistryWatcher {
public:
typedef base::Callback<void(bool succeeded)> CallbackType;
RegistryWatcher() {}
+ ~RegistryWatcher() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); }
+
bool Watch(const wchar_t* key, const CallbackType& callback) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!callback.is_null());
DCHECK(callback_.is_null());
callback_ = callback;
@@ -305,7 +311,7 @@ class RegistryWatcher : public base::NonThreadSafe {
}
void OnObjectSignaled() {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!callback_.is_null());
if (key_.StartWatching(base::Bind(&RegistryWatcher::OnObjectSignaled,
base::Unretained(this)))) {
@@ -320,6 +326,8 @@ class RegistryWatcher : public base::NonThreadSafe {
CallbackType callback_;
base::win::RegKey key_;
+ SEQUENCE_CHECKER(sequence_checker_);
+
DISALLOW_COPY_AND_ASSIGN(RegistryWatcher);
};

Powered by Google App Engine
This is Rietveld 408576698