| 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 #ifndef MOJO_EMBEDDER_PLATFORM_HANDLE_H_ | 5 #ifndef MOJO_EMBEDDER_PLATFORM_HANDLE_H_ |
| 6 #define MOJO_EMBEDDER_PLATFORM_HANDLE_H_ | 6 #define MOJO_EMBEDDER_PLATFORM_HANDLE_H_ |
| 7 | 7 |
| 8 #include "base/files/platform_file.h" |
| 8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 9 #include "mojo/system/system_impl_export.h" | 10 #include "mojo/system/system_impl_export.h" |
| 10 | 11 |
| 11 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 12 #include <windows.h> | 13 #include <windows.h> |
| 13 #endif | 14 #endif |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 namespace embedder { | 17 namespace embedder { |
| 17 | 18 |
| 18 #if defined(OS_POSIX) | 19 #if defined(OS_POSIX) |
| 19 struct MOJO_SYSTEM_IMPL_EXPORT PlatformHandle { | 20 struct MOJO_SYSTEM_IMPL_EXPORT PlatformHandle { |
| 20 PlatformHandle() : fd(-1) {} | 21 PlatformHandle() : fd(-1) {} |
| 21 explicit PlatformHandle(int fd) : fd(fd) {} | 22 explicit PlatformHandle(int fd) : fd(fd) {} |
| 22 | 23 |
| 23 void CloseIfNecessary(); | 24 void CloseIfNecessary(); |
| 25 base::PlatformFile ToPlaformFile() const { return fd; } |
| 24 | 26 |
| 25 bool is_valid() const { return fd != -1; } | 27 bool is_valid() const { return fd != -1; } |
| 26 | 28 |
| 27 int fd; | 29 int fd; |
| 28 }; | 30 }; |
| 29 #elif defined(OS_WIN) | 31 #elif defined(OS_WIN) |
| 30 struct MOJO_SYSTEM_IMPL_EXPORT PlatformHandle { | 32 struct MOJO_SYSTEM_IMPL_EXPORT PlatformHandle { |
| 31 PlatformHandle() : handle(INVALID_HANDLE_VALUE) {} | 33 PlatformHandle() : handle(INVALID_HANDLE_VALUE) {} |
| 32 explicit PlatformHandle(HANDLE handle) : handle(handle) {} | 34 explicit PlatformHandle(HANDLE handle) : handle(handle) {} |
| 33 | 35 |
| 34 void CloseIfNecessary(); | 36 void CloseIfNecessary(); |
| 37 base::PlatformFile ToPlaformFile() const { return handle; } |
| 35 | 38 |
| 36 bool is_valid() const { return handle != INVALID_HANDLE_VALUE; } | 39 bool is_valid() const { return handle != INVALID_HANDLE_VALUE; } |
| 37 | 40 |
| 38 HANDLE handle; | 41 HANDLE handle; |
| 39 }; | 42 }; |
| 40 #else | 43 #else |
| 41 #error "Platform not yet supported." | 44 #error "Platform not yet supported." |
| 42 #endif | 45 #endif |
| 43 | 46 |
| 44 } // namespace embedder | 47 } // namespace embedder |
| 45 } // namespace mojo | 48 } // namespace mojo |
| 46 | 49 |
| 47 #endif // MOJO_EMBEDDER_PLATFORM_HANDLE_H_ | 50 #endif // MOJO_EMBEDDER_PLATFORM_HANDLE_H_ |
| OLD | NEW |