summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 01:27:06 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 01:27:06 +0000
commit1e61ca1a183cbdf99cd90bddeb3ec539eb214743 (patch)
tree5233d88546ad2f85aa8d50a7db807ed49487a27e
parent7624db8ec35fbfe5ed12a876957bd53c37860fbf (diff)
downloadchromium_src-1e61ca1a183cbdf99cd90bddeb3ec539eb214743.zip
chromium_src-1e61ca1a183cbdf99cd90bddeb3ec539eb214743.tar.gz
chromium_src-1e61ca1a183cbdf99cd90bddeb3ec539eb214743.tar.bz2
These files were meant to be checked in with
http://codereview.chromium.org/149236 The change SourceBuffer to use scoped_array and they add a test for Class::unqualified_name. Review URL: http://codereview.chromium.org/149300 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20115 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--o3d/core/cross/buffer.cc15
-rw-r--r--o3d/core/cross/buffer.h2
-rw-r--r--o3d/core/cross/object_base_test.cc10
3 files changed, 17 insertions, 10 deletions
diff --git a/o3d/core/cross/buffer.cc b/o3d/core/cross/buffer.cc
index d467d987..cd1f8d6 100644
--- a/o3d/core/cross/buffer.cc
+++ b/o3d/core/cross/buffer.cc
@@ -491,7 +491,7 @@ ObjectBase::Ref VertexBuffer::Create(ServiceLocator* service_locator) {
SourceBuffer::SourceBuffer(ServiceLocator* service_locator)
: VertexBufferBase(service_locator),
- buffer_(NULL) {
+ buffer_() {
}
SourceBuffer::~SourceBuffer() {
@@ -499,31 +499,28 @@ SourceBuffer::~SourceBuffer() {
}
void SourceBuffer::ConcreteFree() {
- if (buffer_) {
- delete [] buffer_;
- buffer_ = NULL;
- }
+ buffer_.reset();
}
bool SourceBuffer::ConcreteAllocate(size_t size_in_bytes) {
ConcreteFree();
- buffer_ = new char[size_in_bytes];
+ buffer_.reset(new char[size_in_bytes]);
return true;
}
bool SourceBuffer::ConcreteLock(AccessMode access_mode, void **buffer_data) {
- if (!buffer_) {
+ if (!buffer_.get()) {
return false;
}
- *buffer_data = reinterpret_cast<void*>(buffer_);
+ *buffer_data = reinterpret_cast<void*>(buffer_.get());
return true;
}
bool SourceBuffer::ConcreteUnlock() {
- return buffer_ != NULL;
+ return buffer_.get() != NULL;
}
ObjectBase::Ref SourceBuffer::Create(ServiceLocator* service_locator) {
diff --git a/o3d/core/cross/buffer.h b/o3d/core/cross/buffer.h
index 962b6ed..fc9c1bc 100644
--- a/o3d/core/cross/buffer.h
+++ b/o3d/core/cross/buffer.h
@@ -306,7 +306,7 @@ class SourceBuffer : public VertexBufferBase {
friend class IClassManager;
static ObjectBase::Ref Create(ServiceLocator* service_locator);
- char* buffer_; // The actual data for this buffer.
+ scoped_array<char> buffer_; // The actual data for this buffer.
O3D_DECL_CLASS(SourceBuffer, VertexBufferBase);
DISALLOW_COPY_AND_ASSIGN(SourceBuffer);
diff --git a/o3d/core/cross/object_base_test.cc b/o3d/core/cross/object_base_test.cc
index fe65fa6..eb4cc59 100644
--- a/o3d/core/cross/object_base_test.cc
+++ b/o3d/core/cross/object_base_test.cc
@@ -70,4 +70,14 @@ TEST_F(ObjectBaseTest, ObjectIdOfNullIsZero) {
TEST_F(ObjectBaseTest, ObjectIdOfObjectIsReturned) {
ASSERT_EQ(pack_->id(), GetObjectId(pack_));
}
+
+TEST_F(ObjectBaseTest, ObjectClassName) {
+ ASSERT_EQ(0,
+ strcmp(ObjectBase::GetApparentClass()->name(),
+ "o3d.ObjectBase"));
+ ASSERT_EQ(0,
+ strcmp(ObjectBase::GetApparentClass()->unqualified_name(),
+ "ObjectBase"));
+}
+
} // namespace o3d