| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/proxy/serialized_handle.h" | 5 #include "ppapi/proxy/serialized_handle.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" |
| 7 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 8 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 9 #include "base/platform_file.h" | |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "ipc/ipc_platform_file.h" | 11 #include "ipc/ipc_platform_file.h" |
| 12 | 12 |
| 13 #if defined(OS_NACL) | 13 #if defined(OS_NACL) |
| 14 #include <unistd.h> | 14 #include <unistd.h> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 namespace ppapi { | 17 namespace ppapi { |
| 18 namespace proxy { | 18 namespace proxy { |
| 19 | 19 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (IsHandleValid()) { | 74 if (IsHandleValid()) { |
| 75 switch (type_) { | 75 switch (type_) { |
| 76 case INVALID: | 76 case INVALID: |
| 77 NOTREACHED(); | 77 NOTREACHED(); |
| 78 break; | 78 break; |
| 79 case SHARED_MEMORY: | 79 case SHARED_MEMORY: |
| 80 base::SharedMemory::CloseHandle(shm_handle_); | 80 base::SharedMemory::CloseHandle(shm_handle_); |
| 81 break; | 81 break; |
| 82 case SOCKET: | 82 case SOCKET: |
| 83 case FILE: | 83 case FILE: |
| 84 base::PlatformFile file = | 84 base::File file_closer = IPC::PlatformFileForTransitToFile(descriptor_); |
| 85 IPC::PlatformFileForTransitToPlatformFile(descriptor_); | |
| 86 #if !defined(OS_NACL) | |
| 87 base::ClosePlatformFile(file); | |
| 88 #else | |
| 89 close(file); | |
| 90 #endif | |
| 91 break; | 85 break; |
| 92 // No default so the compiler will warn us if a new type is added. | 86 // No default so the compiler will warn us if a new type is added. |
| 93 } | 87 } |
| 94 } | 88 } |
| 95 *this = SerializedHandle(); | 89 *this = SerializedHandle(); |
| 96 } | 90 } |
| 97 | 91 |
| 98 // static | 92 // static |
| 99 bool SerializedHandle::WriteHeader(const Header& hdr, Pickle* pickle) { | 93 bool SerializedHandle::WriteHeader(const Header& hdr, Pickle* pickle) { |
| 100 if (!pickle->WriteInt(hdr.type)) | 94 if (!pickle->WriteInt(hdr.type)) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 break; | 135 break; |
| 142 // No default so the compiler will warn us if a new type is added. | 136 // No default so the compiler will warn us if a new type is added. |
| 143 } | 137 } |
| 144 if (valid_type) | 138 if (valid_type) |
| 145 hdr->type = Type(type); | 139 hdr->type = Type(type); |
| 146 return valid_type; | 140 return valid_type; |
| 147 } | 141 } |
| 148 | 142 |
| 149 } // namespace proxy | 143 } // namespace proxy |
| 150 } // namespace ppapi | 144 } // namespace ppapi |
| OLD | NEW |