Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h

Issue 1676913002: [mojo] Delete third_party/mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: let's try that again Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef THIRD_PARTY_MOJO_SRC_MOJO_EDK_EMBEDDER_SCOPED_PLATFORM_HANDLE_H_
6 #define THIRD_PARTY_MOJO_SRC_MOJO_EDK_EMBEDDER_SCOPED_PLATFORM_HANDLE_H_
7
8 #include "base/move.h"
9 #include "mojo/public/c/system/macros.h"
10 #include "third_party/mojo/src/mojo/edk/embedder/platform_handle.h"
11 #include "third_party/mojo/src/mojo/edk/system/system_impl_export.h"
12
13 namespace mojo {
14 namespace embedder {
15
16 class MOJO_SYSTEM_IMPL_EXPORT ScopedPlatformHandle {
17 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(ScopedPlatformHandle)
18
19 public:
20 ScopedPlatformHandle() {}
21 explicit ScopedPlatformHandle(PlatformHandle handle) : handle_(handle) {}
22 ~ScopedPlatformHandle() { handle_.CloseIfNecessary(); }
23
24 // Move-only constructor and operator=.
25 ScopedPlatformHandle(ScopedPlatformHandle&& other)
26 : handle_(other.release()) {}
27
28 ScopedPlatformHandle& operator=(ScopedPlatformHandle&& other) {
29 if (this != &other)
30 handle_ = other.release();
31 return *this;
32 }
33
34 const PlatformHandle& get() const { return handle_; }
35
36 void swap(ScopedPlatformHandle& other) {
37 PlatformHandle temp = handle_;
38 handle_ = other.handle_;
39 other.handle_ = temp;
40 }
41
42 PlatformHandle release() MOJO_WARN_UNUSED_RESULT {
43 PlatformHandle rv = handle_;
44 handle_ = PlatformHandle();
45 return rv;
46 }
47
48 void reset(PlatformHandle handle = PlatformHandle()) {
49 handle_.CloseIfNecessary();
50 handle_ = handle;
51 }
52
53 bool is_valid() const { return handle_.is_valid(); }
54
55 private:
56 PlatformHandle handle_;
57 };
58
59 } // namespace embedder
60 } // namespace mojo
61
62 #endif // THIRD_PARTY_MOJO_SRC_MOJO_EDK_EMBEDDER_SCOPED_PLATFORM_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698