| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "mojo/edk/embedder/platform_handle.h" | 5 #include "mojo/edk/embedder/platform_handle.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #if defined(OS_POSIX) | 8 #if defined(OS_POSIX) |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 #elif defined(OS_WIN) | 10 #elif defined(OS_WIN) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 if (!is_valid()) | 22 if (!is_valid()) |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
| 26 if (type == Type::POSIX) { | 26 if (type == Type::POSIX) { |
| 27 bool success = (close(handle) == 0); | 27 bool success = (close(handle) == 0); |
| 28 DPCHECK(success); | 28 DPCHECK(success); |
| 29 handle = -1; | 29 handle = -1; |
| 30 } | 30 } |
| 31 #if defined(OS_MACOSX) && !defined(OS_IOS) | 31 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 32 else { | 32 else if (type == Type::MACH) { |
| 33 kern_return_t rv = mach_port_deallocate(mach_task_self(), port); | 33 kern_return_t rv = mach_port_deallocate(mach_task_self(), port); |
| 34 DPCHECK(rv == KERN_SUCCESS); | 34 DPCHECK(rv == KERN_SUCCESS); |
| 35 port = MACH_PORT_NULL; | 35 port = MACH_PORT_NULL; |
| 36 } | 36 } |
| 37 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 37 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 38 #elif defined(OS_WIN) | 38 #elif defined(OS_WIN) |
| 39 bool success = !!CloseHandle(handle); | 39 bool success = !!CloseHandle(handle); |
| 40 DPCHECK(success); | 40 DPCHECK(success); |
| 41 handle = INVALID_HANDLE_VALUE; | 41 handle = INVALID_HANDLE_VALUE; |
| 42 #else | 42 #else |
| 43 #error "Platform not yet supported." | 43 #error "Platform not yet supported." |
| 44 #endif | 44 #endif |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace edk | 47 } // namespace edk |
| 48 } // namespace mojo | 48 } // namespace mojo |
| OLD | NEW |