Simplified destructor.

See the discussion in r894962. It was agreed that the removed code is not
necessary anymore.

Change-Id: I6e79b0729efe2ed0f28842041383d2c3f35895d4
Reviewed-on: https://chromium-review.googlesource.com/905722
Reviewed-by: Bernhard Bauer <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Commit-Queue: François Degros <[email protected]>
Cr-Commit-Position: refs/heads/master@{#535168}
diff --git a/components/prefs/pref_service.cc b/components/prefs/pref_service.cc
index a82849d..ab9b9e5 100644
--- a/components/prefs/pref_service.cc
+++ b/components/prefs/pref_service.cc
@@ -73,23 +73,14 @@
       read_error_callback_(std::move(read_error_callback)) {
   pref_notifier_->SetPrefService(this);
 
-  // TODO(battre): This is a check for crbug.com/435208 to make sure that
-  // access violations are caused by a use-after-free bug and not by an
-  // initialization bug.
-  CHECK(pref_registry_);
-  CHECK(pref_value_store_);
+  DCHECK(pref_registry_);
+  DCHECK(pref_value_store_);
 
   InitFromStorage(async);
 }
 
 PrefService::~PrefService() {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-
-  // Reset pointers so accesses after destruction reliably crash.
-  pref_value_store_.reset();
-  pref_registry_ = nullptr;
-  user_pref_store_ = nullptr;
-  pref_notifier_.reset();
 }
 
 void PrefService::InitFromStorage(bool async) {
diff --git a/components/prefs/pref_service.h b/components/prefs/pref_service.h
index 00cebae..7b4b8ff 100644
--- a/components/prefs/pref_service.h
+++ b/components/prefs/pref_service.h
@@ -347,16 +347,16 @@
   // The PrefNotifier handles registering and notifying preference observers.
   // It is created and owned by this PrefService. Subclasses may access it for
   // unit testing.
-  std::unique_ptr<PrefNotifierImpl> pref_notifier_;
+  const std::unique_ptr<PrefNotifierImpl> pref_notifier_;
 
   // The PrefValueStore provides prioritized preference values. It is owned by
   // this PrefService. Subclasses may access it for unit testing.
-  std::unique_ptr<PrefValueStore> pref_value_store_;
+  const std::unique_ptr<PrefValueStore> pref_value_store_;
 
-  scoped_refptr<PrefRegistry> pref_registry_;
+  const scoped_refptr<PrefRegistry> pref_registry_;
 
   // Pref Stores and profile that we passed to the PrefValueStore.
-  scoped_refptr<PersistentPrefStore> user_pref_store_;
+  const scoped_refptr<PersistentPrefStore> user_pref_store_;
 
   // Callback to call when a read error occurs.
   const base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>