OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_EDK_EMBEDDER_SCOPED_PLATFORM_HANDLE_H_ | 5 #ifndef MOJO_EDK_PLATFORM_SCOPED_PLATFORM_HANDLE_H_ |
6 #define MOJO_EDK_EMBEDDER_SCOPED_PLATFORM_HANDLE_H_ | 6 #define MOJO_EDK_PLATFORM_SCOPED_PLATFORM_HANDLE_H_ |
7 | 7 |
8 #include "mojo/edk/embedder/platform_handle.h" | 8 #include "mojo/edk/platform/platform_handle.h" |
9 #include "mojo/public/c/system/macros.h" | 9 #include "mojo/public/c/system/macros.h" |
10 #include "mojo/public/cpp/system/macros.h" | 10 #include "mojo/public/cpp/system/macros.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 namespace embedder { | 13 namespace platform { |
14 | 14 |
15 // Scoper for |PlatformHandle|s, which are just file descriptors. | 15 // Scoper for |PlatformHandle|s, which are just file descriptors. |
16 class ScopedPlatformHandle { | 16 class ScopedPlatformHandle { |
17 public: | 17 public: |
18 ScopedPlatformHandle() {} | 18 ScopedPlatformHandle() {} |
19 explicit ScopedPlatformHandle(PlatformHandle handle) : handle_(handle) {} | 19 explicit ScopedPlatformHandle(PlatformHandle handle) : handle_(handle) {} |
20 ~ScopedPlatformHandle() { handle_.CloseIfNecessary(); } | 20 ~ScopedPlatformHandle() { handle_.CloseIfNecessary(); } |
21 | 21 |
22 // Move-only constructor and operator=. | 22 // Move-only constructor and operator=. |
23 ScopedPlatformHandle(ScopedPlatformHandle&& other) | 23 ScopedPlatformHandle(ScopedPlatformHandle&& other) |
(...skipping 25 matching lines...) Expand all Loading... |
49 } | 49 } |
50 | 50 |
51 bool is_valid() const { return handle_.is_valid(); } | 51 bool is_valid() const { return handle_.is_valid(); } |
52 | 52 |
53 private: | 53 private: |
54 PlatformHandle handle_; | 54 PlatformHandle handle_; |
55 | 55 |
56 MOJO_MOVE_ONLY_TYPE(ScopedPlatformHandle); | 56 MOJO_MOVE_ONLY_TYPE(ScopedPlatformHandle); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace embedder | 59 } // namespace platform |
60 } // namespace mojo | 60 } // namespace mojo |
61 | 61 |
62 #endif // MOJO_EDK_EMBEDDER_SCOPED_PLATFORM_HANDLE_H_ | 62 #endif // MOJO_EDK_PLATFORM_SCOPED_PLATFORM_HANDLE_H_ |
OLD | NEW |