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

Unified Diff: base/values.cc

Issue 7714004: base: Add AsList() function to Value API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OVERRIDE Created 9 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
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index d3f0f922db51ad6ec38e11830a6237a62f373da5..f17431fce1f3c851d6375543f1bffa238a5ddf57 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -97,6 +97,10 @@ StringValue* Value::CreateStringValue(const string16& in_value) {
return new StringValue(in_value);
}
+ListValue* Value::AsList() {
+ return NULL;
+}
+
bool Value::GetAsBoolean(bool* out_value) const {
return false;
}
@@ -508,7 +512,7 @@ bool DictionaryValue::GetList(const std::string& path,
ListValue** out_value) const {
Value* value;
bool result = Get(path, &value);
- if (!result || !value->IsType(TYPE_LIST))
+ if (!result || !value->AsList())
return false;
if (out_value)
@@ -586,7 +590,7 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::string& key,
ListValue** out_value) const {
Value* value;
bool result = GetWithoutPathExpansion(key, &value);
- if (!result || !value->IsType(TYPE_LIST))
+ if (!result || !value->AsList())
return false;
if (out_value)
@@ -799,7 +803,7 @@ bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) const {
bool ListValue::GetList(size_t index, ListValue** out_value) const {
Value* value;
bool result = Get(index, &value);
- if (!result || !value->IsType(TYPE_LIST))
+ if (!result || !value->AsList())
return false;
if (out_value)
@@ -862,6 +866,10 @@ bool ListValue::Insert(size_t index, Value* in_value) {
return true;
}
+ListValue* ListValue::AsList() {
+ return this;
+}
+
bool ListValue::GetAsList(ListValue** out_value) {
if (out_value)
*out_value = this;

Powered by Google App Engine
This is Rietveld 408576698