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 // NeedsTracing is a three-point value ordered by unneeded < unknown < needed.
6 // Unneeded means that the point definitively does not need to be traced.
7 
8 #ifndef TOOLS_BLINK_GC_PLUGIN_NEEDS_TRACING_H_
9 #define TOOLS_BLINK_GC_PLUGIN_NEEDS_TRACING_H_
10 
11 class NeedsTracing {
12  public:
Unneeded()13   static NeedsTracing Unneeded() { return kUnneeded; }
Unknown()14   static NeedsTracing Unknown() { return kUnknown; }
Needed()15   static NeedsTracing Needed() { return kNeeded; }
IsUnneeded()16   bool IsUnneeded() { return value_ == kUnneeded; }
IsUnknown()17   bool IsUnknown() { return value_ == kUnknown; }
IsNeeded()18   bool IsNeeded() { return value_ == kNeeded; }
LUB(const NeedsTracing & other)19   NeedsTracing LUB(const NeedsTracing& other) {
20     return value_ > other.value_ ? value_ : other.value_;
21   }
22   bool operator==(const NeedsTracing& other) {
23     return value_ == other.value_;
24   }
25  private:
26   enum Value { kUnneeded, kUnknown, kNeeded };
NeedsTracing(Value value)27   NeedsTracing(Value value) : value_(value) {}
28   Value value_;
29 };
30 
31 #endif // TOOLS_BLINK_GC_PLUGIN_NEEDS_TRACING_H_
32