| Index: third_party/tcmalloc/chromium/src/leak_detector_value_type.h
|
| diff --git a/third_party/tcmalloc/chromium/src/leak_detector_value_type.h b/third_party/tcmalloc/chromium/src/leak_detector_value_type.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..05d057deba3f16ce51ccad0e85540e2a4b330c1c
|
| --- /dev/null
|
| +++ b/third_party/tcmalloc/chromium/src/leak_detector_value_type.h
|
| @@ -0,0 +1,80 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef LEAK_DETECTOR_VALUE_TYPE_
|
| +#define LEAK_DETECTOR_VALUE_TYPE_
|
| +
|
| +#include "base/basictypes.h"
|
| +
|
| +struct HeapProfileBucket;
|
| +
|
| +namespace leak_detector {
|
| +
|
| +// Used for tracking unique call stacks.
|
| +using CallStack = HeapProfileBucket;
|
| +
|
| +class LeakDetectorValueType {
|
| + public:
|
| + // Supported types.
|
| + enum Type {
|
| + kNone,
|
| + kSize,
|
| + kCallStack,
|
| + };
|
| +
|
| + LeakDetectorValueType() : type_(kNone) {}
|
| + explicit LeakDetectorValueType(uint32_t size)
|
| + : type_(kSize), size_(size) {}
|
| + explicit LeakDetectorValueType(const CallStack* call_stack)
|
| + : type_(kCallStack), call_stack_(call_stack) {}
|
| +
|
| + // Accessors.
|
| + Type type() const {
|
| + return type_;
|
| + }
|
| + uint32_t size() const {
|
| + return size_;
|
| + }
|
| + const CallStack* call_stack() const {
|
| + return call_stack_;
|
| + }
|
| +
|
| + // Comparators.
|
| + bool operator == (const LeakDetectorValueType& other) const {
|
| + if (type_ != other.type_)
|
| + return false;
|
| +
|
| + switch(type_) {
|
| + case kSize:
|
| + return size_ == other.size_;
|
| + case kCallStack:
|
| + return call_stack_ == other.call_stack_;
|
| + default:
|
| + return false;
|
| + }
|
| + };
|
| + bool operator < (const LeakDetectorValueType& other) const {
|
| + if (type_ < other.type_)
|
| + return true;
|
| +
|
| + switch(type_) {
|
| + case kSize:
|
| + return size_ < other.size_;
|
| + case kCallStack:
|
| + return call_stack_ < other.call_stack_;
|
| + default:
|
| + return false;
|
| + }
|
| + };
|
| +
|
| + private:
|
| + Type type_;
|
| +
|
| + uint32_t size_;
|
| + const CallStack* call_stack_;
|
| +};
|
| +
|
| +} // namespace leak_detector
|
| +
|
| +#endif // LEAK_DETECTOR_VALUE_TYPE_
|
|
|