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

Side by Side Diff: ppapi/cpp/dev/buffer_dev.cc

Issue 10909068: Fix resource leaks in CDM implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Same patchset as number 8, hopefully this one is viewable... Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/dev/buffer_dev.h" 5 #include "ppapi/cpp/dev/buffer_dev.h"
6 6
7 #include "ppapi/c/dev/ppb_buffer_dev.h" 7 #include "ppapi/c/dev/ppb_buffer_dev.h"
8 #include "ppapi/cpp/instance_handle.h" 8 #include "ppapi/cpp/instance_handle.h"
9 #include "ppapi/cpp/module.h" 9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h" 10 #include "ppapi/cpp/module_impl.h"
(...skipping 25 matching lines...) Expand all
36 : data_(NULL), 36 : data_(NULL),
37 size_(0) { 37 size_(0) {
38 if (!has_interface<PPB_Buffer_Dev>()) 38 if (!has_interface<PPB_Buffer_Dev>())
39 return; 39 return;
40 40
41 PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create( 41 PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create(
42 instance.pp_instance(), size)); 42 instance.pp_instance(), size));
43 Init(); 43 Init();
44 } 44 }
45 45
46 Buffer_Dev::Buffer_Dev(PassRef, PP_Resource resource)
47 : Resource(PassRef(), resource) {
48 Init();
49 }
50
46 Buffer_Dev::~Buffer_Dev() { 51 Buffer_Dev::~Buffer_Dev() {
47 get_interface<PPB_Buffer_Dev>()->Unmap(pp_resource()); 52 get_interface<PPB_Buffer_Dev>()->Unmap(pp_resource());
48 } 53 }
49 54
50 Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) { 55 Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& rhs) {
51 Resource::operator=(rhs); 56 Resource::operator=(rhs);
52 Init(); 57 Init();
53 return *this; 58 return *this;
54 } 59 }
55 60
56 void Buffer_Dev::Init() { 61 void Buffer_Dev::Init() {
57 if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || 62 if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) ||
58 !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) { 63 !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) {
59 data_ = NULL; 64 data_ = NULL;
60 size_ = 0; 65 size_ = 0;
61 } 66 }
62 } 67 }
63 68
64 } // namespace pp 69 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698