Commit 2261b1fb authored by jdoerrie's avatar jdoerrie Committed by Commit Bot

[Prefs] Add CHECKs to debug crbug.com/859477

This change adds CHECKs to help debug crashes originating in
MetricsLogStore.

Bug: 859477
Change-Id: Iab9c770840613cedffdeb24f8b48b0c7580dd825
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599611
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657635}
parent 873623cf
......@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/debug/alias.h"
#include "base/debug/dump_without_crashing.h"
#include "base/files/file_path.h"
#include "base/location.h"
#include "base/logging.h"
......@@ -564,13 +565,19 @@ base::Value* PrefService::GetMutableUserPref(const std::string& path,
// Look for an existing preference in the user store. If it doesn't
// exist, create a new user preference.
base::Value* value = nullptr;
if (user_pref_store_->GetMutableValue(path, &value))
if (user_pref_store_->GetMutableValue(path, &value)) {
// TODO(crbug.com/859477): Remove once root cause has been found.
if (value->type() != type)
base::debug::DumpWithoutCrashing();
return value;
}
// If no user preference exists, clone default value.
const base::Value* default_value = nullptr;
pref_registry_->defaults()->GetValue(path, &default_value);
DCHECK_EQ(default_value->type(), type);
// TODO(crbug.com/859477): Revert to DCHECK once root cause has been found.
if (default_value->type() != type)
base::debug::DumpWithoutCrashing();
user_pref_store_->SetValueSilently(path, default_value->CreateDeepCopy(),
GetWriteFlags(pref));
user_pref_store_->GetMutableValue(path, &value);
......
......@@ -25,6 +25,12 @@ base::Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!value_)
value_ = service_->GetMutableUserPref(path_, type);
// |value_| might be downcast to base::DictionaryValue or base::ListValue,
// side-stepping CHECKs built into base::Value. Thus we need to be certain
// that the type matches.
if (value_)
CHECK_EQ(value_->type(), type);
return value_;
}
......
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