OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can | 2 // Use of this source code is governed by a BSD-style license that can |
3 // be found in the LICENSE file. | 3 // be found in the LICENSE file. |
4 | 4 |
5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <sys/mman.h> | 9 #include <sys/mman.h> |
10 #include "srpcgen/ppb_rpc.h" | 10 #include "srpcgen/ppb_rpc.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 &DoUnmap, | 133 &DoUnmap, |
134 }; | 134 }; |
135 return &image_data_interface; | 135 return &image_data_interface; |
136 } | 136 } |
137 | 137 |
138 PluginImageData::PluginImageData() | 138 PluginImageData::PluginImageData() |
139 : shm_size_(0), | 139 : shm_size_(0), |
140 addr_(NULL) { | 140 addr_(NULL) { |
141 } | 141 } |
142 | 142 |
| 143 PluginImageData::~PluginImageData() { |
| 144 Unmap(); |
| 145 } |
| 146 |
143 bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { | 147 bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { |
144 nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); | 148 nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); |
145 int32_t success = PP_FALSE; | 149 int32_t success = PP_FALSE; |
146 | 150 |
147 NaClSrpcError result = | 151 NaClSrpcError result = |
148 PpbImageDataRpcClient::PPB_ImageData_Describe( | 152 PpbImageDataRpcClient::PPB_ImageData_Describe( |
149 GetMainSrpcChannel(), | 153 GetMainSrpcChannel(), |
150 resource, | 154 resource, |
151 &desc_size, | 155 &desc_size, |
152 reinterpret_cast<char*>(&desc_), | 156 reinterpret_cast<char*>(&desc_), |
(...skipping 17 matching lines...) Expand all Loading... |
170 } | 174 } |
171 | 175 |
172 void PluginImageData::Unmap() { | 176 void PluginImageData::Unmap() { |
173 if (addr_) { | 177 if (addr_) { |
174 munmap(addr_, ceil64k(shm_size_)); | 178 munmap(addr_, ceil64k(shm_size_)); |
175 addr_ = NULL; | 179 addr_ = NULL; |
176 } | 180 } |
177 } | 181 } |
178 | 182 |
179 } // namespace ppapi_proxy | 183 } // namespace ppapi_proxy |
OLD | NEW |