OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace ppapi { |
| 10 |
| 11 PpapiPermissions::PpapiPermissions() : permissions_(0) { |
| 12 } |
| 13 |
| 14 PpapiPermissions::PpapiPermissions(uint32 perms) : permissions_(perms) { |
| 15 } |
| 16 |
| 17 PpapiPermissions::~PpapiPermissions() { |
| 18 } |
| 19 |
| 20 bool PpapiPermissions::HasPermission(Permission perm) const { |
| 21 // Check that "perm" is a power of two to make sure the caller didn't set |
| 22 // more than one permission bit. We may want to change how permissions are |
| 23 // represented in the future so don't want callers making assumptions about |
| 24 // bits. |
| 25 uint32 perm_int = static_cast<uint32>(perm); |
| 26 DCHECK((perm_int & (perm_int - 1)) == 0); |
| 27 return !!(permissions_ & perm_int); |
| 28 } |
| 29 |
| 30 } // namespace ppapi |
OLD | NEW |