| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() { | 144 PluginImageData::~PluginImageData() { |
| 145 Unmap(); | 145 Unmap(); |
| 146 if (shm_fd_ != -1) { |
| 147 close(shm_fd_); |
| 148 shm_fd_ = -1; |
| 149 } |
| 146 } | 150 } |
| 147 | 151 |
| 148 bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { | 152 bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { |
| 149 nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); | 153 nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); |
| 150 int32_t success = PP_FALSE; | 154 int32_t success = PP_FALSE; |
| 151 | 155 |
| 152 NaClSrpcError result = | 156 NaClSrpcError result = |
| 153 PpbImageDataRpcClient::PPB_ImageData_Describe( | 157 PpbImageDataRpcClient::PPB_ImageData_Describe( |
| 154 GetMainSrpcChannel(), | 158 GetMainSrpcChannel(), |
| 155 resource, | 159 resource, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 } | 179 } |
| 176 | 180 |
| 177 void PluginImageData::Unmap() { | 181 void PluginImageData::Unmap() { |
| 178 if (addr_) { | 182 if (addr_) { |
| 179 munmap(addr_, ceil64k(shm_size_)); | 183 munmap(addr_, ceil64k(shm_size_)); |
| 180 addr_ = NULL; | 184 addr_ = NULL; |
| 181 } | 185 } |
| 182 } | 186 } |
| 183 | 187 |
| 184 } // namespace ppapi_proxy | 188 } // namespace ppapi_proxy |
| OLD | NEW |