| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return &image_data_interface; | 134 return &image_data_interface; |
| 135 } | 135 } |
| 136 | 136 |
| 137 PluginImageData::PluginImageData() | 137 PluginImageData::PluginImageData() |
| 138 : shm_fd_(-1), | 138 : shm_fd_(-1), |
| 139 shm_size_(0), | 139 shm_size_(0), |
| 140 addr_(NULL) { | 140 addr_(NULL) { |
| 141 memset(&desc_, 0, sizeof(desc_)); | 141 memset(&desc_, 0, sizeof(desc_)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 PluginImageData::~PluginImageData() { | |
| 145 Unmap(); | |
| 146 if (shm_fd_ != -1) { | |
| 147 close(shm_fd_); | |
| 148 shm_fd_ = -1; | |
| 149 } | |
| 150 } | |
| 151 | |
| 152 bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { | 144 bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { |
| 153 nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); | 145 nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); |
| 154 int32_t success = PP_FALSE; | 146 int32_t success = PP_FALSE; |
| 155 | 147 |
| 156 NaClSrpcError result = | 148 NaClSrpcError result = |
| 157 PpbImageDataRpcClient::PPB_ImageData_Describe( | 149 PpbImageDataRpcClient::PPB_ImageData_Describe( |
| 158 GetMainSrpcChannel(), | 150 GetMainSrpcChannel(), |
| 159 resource, | 151 resource, |
| 160 &desc_size, | 152 &desc_size, |
| 161 reinterpret_cast<char*>(&desc_), | 153 reinterpret_cast<char*>(&desc_), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 178 return addr_; | 170 return addr_; |
| 179 } | 171 } |
| 180 | 172 |
| 181 void PluginImageData::Unmap() { | 173 void PluginImageData::Unmap() { |
| 182 if (addr_) { | 174 if (addr_) { |
| 183 munmap(addr_, ceil64k(shm_size_)); | 175 munmap(addr_, ceil64k(shm_size_)); |
| 184 addr_ = NULL; | 176 addr_ = NULL; |
| 185 } | 177 } |
| 186 } | 178 } |
| 187 | 179 |
| 180 PluginImageData::~PluginImageData() { |
| 181 Unmap(); |
| 182 if (shm_fd_ != -1) { |
| 183 close(shm_fd_); |
| 184 shm_fd_ = -1; |
| 185 } |
| 186 } |
| 187 |
| 188 } // namespace ppapi_proxy | 188 } // namespace ppapi_proxy |
| OLD | NEW |