diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 12:16:26 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 12:16:26 +0000 |
commit | c42bef0b1e7ec7e3d4aca4f0b27074a8c88c1c9d (patch) | |
tree | b40495f7d4341f02c23284e280632ebe641f83a6 | |
parent | cef165e59f68c86ef1f21d7fd86dafca7453c6cc (diff) | |
download | chromium_src-c42bef0b1e7ec7e3d4aca4f0b27074a8c88c1c9d.zip chromium_src-c42bef0b1e7ec7e3d4aca4f0b27074a8c88c1c9d.tar.gz chromium_src-c42bef0b1e7ec7e3d4aca4f0b27074a8c88c1c9d.tar.bz2 |
ppapi: Fix the copy constructor for pp::Buffer_Dev.
BUG=85629
TEST=Printing from the PDF plugin works.
Review URL: http://codereview.chromium.org/7171010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89166 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ppapi/cpp/dev/buffer_dev.cc | 24 | ||||
-rw-r--r-- | ppapi/cpp/dev/buffer_dev.h | 4 |
2 files changed, 20 insertions, 8 deletions
diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc index 38a1b1f..d2be1d0 100644 --- a/ppapi/cpp/dev/buffer_dev.cc +++ b/ppapi/cpp/dev/buffer_dev.cc @@ -24,10 +24,7 @@ Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) { Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) : Resource(other) { - if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || - !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { - *this = Buffer_Dev(); - } + Init(); } Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size) @@ -38,14 +35,25 @@ Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size) PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create( instance->pp_instance(), size)); - if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || - !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { - *this = Buffer_Dev(); - } + Init(); } Buffer_Dev::~Buffer_Dev() { get_interface<PPB_Buffer_Dev>()->Unmap(pp_resource()); } +Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) { + Resource::operator=(rhs); + Init(); + return *this; +} + +void Buffer_Dev::Init() { + if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || + !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { + data_ = NULL; + size_ = 0; + } +} + } // namespace pp diff --git a/ppapi/cpp/dev/buffer_dev.h b/ppapi/cpp/dev/buffer_dev.h index b34a2f8..a8780e0 100644 --- a/ppapi/cpp/dev/buffer_dev.h +++ b/ppapi/cpp/dev/buffer_dev.h @@ -24,10 +24,14 @@ class Buffer_Dev : public Resource { // Unmap the underlying shared memory. virtual ~Buffer_Dev(); + Buffer_Dev& operator=(const Buffer_Dev& rhs); + uint32_t size() const { return size_; } void* data() const { return data_; } private: + void Init(); + void* data_; uint32_t size_; }; |