NeedsTracing.h 1.1 KB

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