| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SYSTEM_HANDLE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_HANDLE_H_ |
| 6 #define MOJO_EDK_SYSTEM_HANDLE_H_ | 6 #define MOJO_EDK_SYSTEM_HANDLE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/edk/util/ref_ptr.h" | 10 #include "mojo/edk/util/ref_ptr.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 explicit operator bool() const { return !!dispatcher; } | 41 explicit operator bool() const { return !!dispatcher; } |
| 42 | 42 |
| 43 bool operator==(const Handle& rhs) const { | 43 bool operator==(const Handle& rhs) const { |
| 44 return dispatcher == rhs.dispatcher && rights == rhs.rights; | 44 return dispatcher == rhs.dispatcher && rights == rhs.rights; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool operator!=(const Handle& rhs) const { return !operator==(rhs); } | 47 bool operator!=(const Handle& rhs) const { return !operator==(rhs); } |
| 48 | 48 |
| 49 void reset() { *this = Handle(); } | 49 void reset() { *this = Handle(); } |
| 50 | 50 |
| 51 bool has_all_rights(MojoHandleRights required_rights) const { |
| 52 return (rights & required_rights) == required_rights; |
| 53 } |
| 54 |
| 51 // Note: |dispatcher| is guaranteed to be null if default-constructed or | 55 // Note: |dispatcher| is guaranteed to be null if default-constructed or |
| 52 // moved-from, but we make no guarantees about the value of |rights| in either | 56 // moved-from, but we make no guarantees about the value of |rights| in either |
| 53 // case. | 57 // case. |
| 54 util::RefPtr<Dispatcher> dispatcher; | 58 util::RefPtr<Dispatcher> dispatcher; |
| 55 MojoHandleRights rights; | 59 MojoHandleRights rights; |
| 56 }; | 60 }; |
| 57 | 61 |
| 58 using HandleVector = std::vector<Handle>; | 62 using HandleVector = std::vector<Handle>; |
| 59 | 63 |
| 60 } // namespace system | 64 } // namespace system |
| 61 } // namespace mojo | 65 } // namespace mojo |
| 62 | 66 |
| 63 #endif // MOJO_EDK_SYSTEM_HANDLE_H_ | 67 #endif // MOJO_EDK_SYSTEM_HANDLE_H_ |
| OLD | NEW |