| 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" | |
| 8 #if defined(OS_POSIX) | |
| 9 #include <unistd.h> | 7 #include <unistd.h> |
| 10 #elif defined(OS_WIN) | |
| 11 #include <windows.h> | |
| 12 #else | |
| 13 #error "Platform not yet supported." | |
| 14 #endif | |
| 15 | 8 |
| 16 #include "base/logging.h" | 9 #include "base/logging.h" |
| 17 | 10 |
| 18 namespace mojo { | 11 namespace mojo { |
| 19 namespace embedder { | 12 namespace embedder { |
| 20 | 13 |
| 21 void PlatformHandle::CloseIfNecessary() { | 14 void PlatformHandle::CloseIfNecessary() { |
| 22 if (!is_valid()) | 15 if (!is_valid()) |
| 23 return; | 16 return; |
| 24 | 17 |
| 25 #if defined(OS_POSIX) | |
| 26 bool success = (close(fd) == 0); | 18 bool success = (close(fd) == 0); |
| 27 DPCHECK(success); | 19 DPCHECK(success); |
| 28 fd = -1; | 20 fd = -1; |
| 29 #elif defined(OS_WIN) | |
| 30 bool success = !!CloseHandle(handle); | |
| 31 DPCHECK(success); | |
| 32 handle = INVALID_HANDLE_VALUE; | |
| 33 #else | |
| 34 #error "Platform not yet supported." | |
| 35 #endif | |
| 36 } | 21 } |
| 37 | 22 |
| 38 } // namespace embedder | 23 } // namespace embedder |
| 39 } // namespace mojo | 24 } // namespace mojo |
| OLD | NEW |