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

Unified Diff: base/values.cc

Issue 3081018: Add UTF-8 DCHECK()s in values.cc (since keys/paths are expected to be UTF-8). (Closed)
Patch Set: oops Created 10 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 78547a44991db0aef059a16eaed3e8bd1e24effb..2cb1a1d86da6c148f862b4a4f1d1c549db0d5d94 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -378,6 +378,7 @@ bool DictionaryValue::Equals(const Value* other) const {
}
bool DictionaryValue::HasKey(const std::string& key) const {
+ DCHECK(IsStringUTF8(key));
ValueMap::const_iterator current_entry = dictionary_.find(key);
DCHECK((current_entry == dictionary_.end()) || current_entry->second);
return current_entry != dictionary_.end();
@@ -404,6 +405,7 @@ void DictionaryValue::Clear() {
}
void DictionaryValue::Set(const std::string& path, Value* in_value) {
+ DCHECK(IsStringUTF8(path));
DCHECK(in_value);
std::string current_path(path);
@@ -507,6 +509,7 @@ void DictionaryValue::SetWithoutPathExpansion(const std::wstring& key,
}
bool DictionaryValue::Get(const std::string& path, Value** out_value) const {
+ DCHECK(IsStringUTF8(path));
std::string current_path(path);
const DictionaryValue* current_dictionary = this;
for (size_t delimiter_position = current_path.find('.');
@@ -682,6 +685,7 @@ bool DictionaryValue::GetList(const std::wstring& path,
bool DictionaryValue::GetWithoutPathExpansion(const std::string& key,
Value** out_value) const {
+ DCHECK(IsStringUTF8(key));
ValueMap::const_iterator entry_iterator = dictionary_.find(key);
if (entry_iterator == dictionary_.end())
return false;
@@ -792,6 +796,7 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::wstring& key,
}
bool DictionaryValue::Remove(const std::string& path, Value** out_value) {
+ DCHECK(IsStringUTF8(path));
std::string current_path(path);
DictionaryValue* current_dictionary = this;
size_t delimiter_position = current_path.rfind('.');
@@ -813,6 +818,7 @@ bool DictionaryValue::Remove(const std::wstring& path, Value** out_value) {
bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key,
Value** out_value) {
+ DCHECK(IsStringUTF8(key));
ValueMap::iterator entry_iterator = dictionary_.find(key);
if (entry_iterator == dictionary_.end())
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698