summaryrefslogtreecommitdiffstats
path: root/base/values.h
diff options
context:
space:
mode:
authormitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-19 19:31:16 +0000
committermitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-19 19:31:16 +0000
commit00590b3d673c7b6bbe7bd96c29323794861a11f6 (patch)
treef7ada40e5edd1df6f4af01b45485840a12873ba6 /base/values.h
parent8c7b4a9e6e01e4a902b4ef08bc8380f600fc0a15 (diff)
downloadchromium_src-00590b3d673c7b6bbe7bd96c29323794861a11f6.zip
chromium_src-00590b3d673c7b6bbe7bd96c29323794861a11f6.tar.gz
chromium_src-00590b3d673c7b6bbe7bd96c29323794861a11f6.tar.bz2
Allowed BinaryValue to take a NULL buffer.
BUG=127630 Review URL: https://chromiumcodereview.appspot.com/10389088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values.h')
-rw-r--r--base/values.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/base/values.h b/base/values.h
index 1d35d63..adb795f 100644
--- a/base/values.h
+++ b/base/values.h
@@ -30,6 +30,7 @@
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
// This file declares "using base::Value", etc. at the bottom, so that
@@ -177,33 +178,32 @@ class BASE_EXPORT StringValue : public Value {
class BASE_EXPORT BinaryValue: public Value {
public:
- virtual ~BinaryValue();
+ // Creates a BinaryValue with a null buffer and size of 0.
+ BinaryValue();
+
+ // Creates a BinaryValue, taking ownership of the bytes pointed to by
+ // |buffer|.
+ BinaryValue(scoped_ptr<char> buffer, size_t size);
- // Creates a Value to represent a binary buffer. The new object takes
- // ownership of the pointer passed in, if successful.
- // Returns NULL if buffer is NULL.
- static BinaryValue* Create(char* buffer, size_t size);
+ virtual ~BinaryValue();
// For situations where you want to keep ownership of your buffer, this
// factory method creates a new BinaryValue by copying the contents of the
// buffer that's passed in.
- // Returns NULL if buffer is NULL.
static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size);
size_t GetSize() const { return size_; }
- char* GetBuffer() { return buffer_; }
- const char* GetBuffer() const { return buffer_; }
+
+ // May return NULL.
+ char* GetBuffer() { return buffer_.get(); }
+ const char* GetBuffer() const { return buffer_.get(); }
// Overridden from Value:
virtual BinaryValue* DeepCopy() const OVERRIDE;
virtual bool Equals(const Value* other) const OVERRIDE;
private:
- // Constructor is private so that only objects with valid buffer pointers
- // and size values can be created.
- BinaryValue(char* buffer, size_t size);
-
- char* buffer_;
+ scoped_ptr<char> buffer_;
size_t size_;
DISALLOW_COPY_AND_ASSIGN(BinaryValue);