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

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: fix chromeos 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
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | 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 799e100ea87b2f4015d9e5eb51dea14c2f04f327..b61e86892e1251285ca8132b3eabe7f722f475b4 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -100,6 +100,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;
}
@@ -519,7 +523,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)
@@ -597,7 +601,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)
@@ -810,7 +814,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)
@@ -873,6 +877,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;
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698