| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_buffer.h" | 5 #include "webkit/glue/plugins/pepper_buffer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "third_party/ppapi/c/dev/ppb_buffer_dev.h" |
| 11 #include "third_party/ppapi/c/pp_instance.h" | 12 #include "third_party/ppapi/c/pp_instance.h" |
| 12 #include "third_party/ppapi/c/pp_module.h" | 13 #include "third_party/ppapi/c/pp_module.h" |
| 13 #include "third_party/ppapi/c/pp_resource.h" | 14 #include "third_party/ppapi/c/pp_resource.h" |
| 14 #include "third_party/ppapi/c/ppb_buffer.h" | |
| 15 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 15 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 16 #include "webkit/glue/plugins/pepper_plugin_module.h" | 16 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 17 | 17 |
| 18 namespace pepper { | 18 namespace pepper { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 PP_Resource Create(PP_Module module_id, int32_t size) { | 22 PP_Resource Create(PP_Module module_id, int32_t size) { |
| 23 PluginModule* module = PluginModule::FromPPModule(module_id); | 23 PluginModule* module = PluginModule::FromPPModule(module_id); |
| 24 if (!module) | 24 if (!module) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 50 return buffer->Map(); | 50 return buffer->Map(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void Unmap(PP_Resource resource) { | 53 void Unmap(PP_Resource resource) { |
| 54 scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource)); | 54 scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource)); |
| 55 if (!buffer) | 55 if (!buffer) |
| 56 return; | 56 return; |
| 57 return buffer->Unmap(); | 57 return buffer->Unmap(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 const PPB_Buffer ppb_buffer = { | 60 const PPB_Buffer_Dev ppb_buffer = { |
| 61 &Create, | 61 &Create, |
| 62 &IsBuffer, | 62 &IsBuffer, |
| 63 &Describe, | 63 &Describe, |
| 64 &Map, | 64 &Map, |
| 65 &Unmap, | 65 &Unmap, |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 Buffer::Buffer(PluginModule* module) | 70 Buffer::Buffer(PluginModule* module) |
| 71 : Resource(module), | 71 : Resource(module), |
| 72 size_(0) { | 72 size_(0) { |
| 73 } | 73 } |
| 74 | 74 |
| 75 Buffer::~Buffer() { | 75 Buffer::~Buffer() { |
| 76 } | 76 } |
| 77 | 77 |
| 78 // static | 78 // static |
| 79 const PPB_Buffer* Buffer::GetInterface() { | 79 const PPB_Buffer_Dev* Buffer::GetInterface() { |
| 80 return &ppb_buffer; | 80 return &ppb_buffer; |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool Buffer::Init(int size) { | 83 bool Buffer::Init(int size) { |
| 84 if (size == 0) | 84 if (size == 0) |
| 85 return false; | 85 return false; |
| 86 Unmap(); | 86 Unmap(); |
| 87 size_ = size; | 87 size_ = size; |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 107 mem_buffer_.reset(); | 107 mem_buffer_.reset(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void Buffer::Swap(Buffer* other) { | 110 void Buffer::Swap(Buffer* other) { |
| 111 swap(other->mem_buffer_, mem_buffer_); | 111 swap(other->mem_buffer_, mem_buffer_); |
| 112 std::swap(other->size_, size_); | 112 std::swap(other->size_, size_); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace pepper | 115 } // namespace pepper |
| 116 | 116 |
| OLD | NEW |