1 // Copyright 2019 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 COMPONENTS_EXO_PERMISSION_H_
6 #define COMPONENTS_EXO_PERMISSION_H_
7 
8 #include "base/time/time.h"
9 
10 namespace exo {
11 
12 class Permission {
13  public:
14   enum class Capability {
15     kActivate,
16   };
17 
18   // Create a permission with the given |capability| until |timeout| elapses.
19   Permission(Capability capability, base::TimeDelta timeout);
20 
21   // Delete copy and move.
22   Permission(const Permission& other) = delete;
23   Permission(Permission&& other) = delete;
24   Permission& operator=(const Permission& other) = delete;
25   Permission& operator=(Permission&& other) = delete;
26 
27   virtual ~Permission() = default;
28 
29   // Prevent this permission from returning true on subsequent Check()s.
30   void Revoke();
31 
32   // Returns true iff this permission was created with the given |capability|
33   // and is not expired.
34   bool Check(Capability capability) const;
35 
36  private:
37   Capability capability_;
38 
39   base::Time expiry_;
40 };
41 
42 }  // namespace exo
43 
44 #endif  // COMPONENTS_EXO_PERMISSION_H_
45