summaryrefslogtreecommitdiffstats
path: root/base/values.h
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 17:41:10 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 17:41:10 +0000
commit053430d6e7e91fa67a5d371bf881534b3ba07a07 (patch)
tree0314b9fb4cab72d05a9037af3dfe1cdff1dc93d5 /base/values.h
parent59c9f17a96e85f4589483a0133715ab373700930 (diff)
downloadchromium_src-053430d6e7e91fa67a5d371bf881534b3ba07a07.zip
chromium_src-053430d6e7e91fa67a5d371bf881534b3ba07a07.tar.gz
chromium_src-053430d6e7e91fa67a5d371bf881534b3ba07a07.tar.bz2
base: Add AsBinary() function to Value API.
This function should simplify some constructions. Instead of: if (!value->IsType(Value::TYPE_BINARY)) return false; BinaryValue* binary_value = static_cast<BinaryValue*>(value); You can do: BinaryValue* binary_value = value->AsBinary(); if (!binary_value) return false; BUG=None TEST=base_unittests --gtest_filter=Values* R=evan@chromium.org Review URL: http://codereview.chromium.org/7748017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.h')
-rw-r--r--base/values.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/base/values.h b/base/values.h
index 2f41215..185729d 100644
--- a/base/values.h
+++ b/base/values.h
@@ -87,6 +87,7 @@ class BASE_EXPORT Value {
// Returns true if the current object represents a given type.
bool IsType(Type type) const { return type == type_; }
+ virtual BinaryValue* AsBinary();
virtual ListValue* AsList();
// These methods allow the convenient retrieval of settings.
@@ -195,6 +196,7 @@ class BASE_EXPORT BinaryValue: public Value {
const char* GetBuffer() const { return buffer_; }
// Overridden from Value:
+ virtual BinaryValue* AsBinary() OVERRIDE;
virtual BinaryValue* DeepCopy() const OVERRIDE;
virtual bool Equals(const Value* other) const OVERRIDE;