Chromium Code Reviews| Index: components/metrics/leak_detector/leak_detector_value_type.h |
| diff --git a/components/metrics/leak_detector/leak_detector_value_type.h b/components/metrics/leak_detector/leak_detector_value_type.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5f72b09818769debf7b108bfd744915186942f74 |
| --- /dev/null |
| +++ b/components/metrics/leak_detector/leak_detector_value_type.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright 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 COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_VALUE_TYPE_ |
| +#define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_VALUE_TYPE_ |
| + |
| +#include <stddef.h> |
| +#include <stdint.h> |
| + |
| +namespace leak_detector { |
| + |
| +// Used for tracking unique call stacks. |
| +class CallStack; |
| + |
| +class LeakDetectorValueType { |
| + public: |
| + // Supported types. |
| + enum Type { |
| + kNone, |
| + kSize, |
| + kCallStack, |
| + }; |
| + |
| + // Print value type name as singular or plural. |
| + enum TypeNameNumber { |
| + kSingular, |
| + kPlural, |
| + }; |
| + |
| + LeakDetectorValueType() : type_(kNone) {} |
| + explicit LeakDetectorValueType(uint32_t size) |
| + : type_(kSize), size_(size) {} |
| + explicit LeakDetectorValueType(const CallStack* call_stack) |
| + : type_(kCallStack), call_stack_(call_stack) {} |
|
jar (doing other things)
2015/08/21 02:48:43
Please initialize all POD members, in both constru
Simon Que
2015/08/21 21:59:20
Done.
Simon Que
2015/08/23 23:30:53
I just saw that I hadn't done this completely in a
|
| + |
| + // Accessors. |
| + Type type() const { |
| + return type_; |
| + } |
| + uint32_t size() const { |
| + return size_; |
| + } |
| + const CallStack* call_stack() const { |
| + return call_stack_; |
| + } |
| + |
| + // Returns a string containing the word that describes the value type of the |
| + // current object. e.g. "size" or "call stack". |
| + const char* GetTypeName() const; |
| + |
| + // Writes the current value as a string to |buffer|. Will not write beyond the |
| + // buffer size given by |buffer_size|. Returns |buffer| as a const ptr. |
| + const char* ToString(char* buffer, size_t buffer_size) const; |
| + |
| + // Comparators. |
| + bool operator== (const LeakDetectorValueType& other) const; |
| + bool operator< (const LeakDetectorValueType& other) const; |
| + |
| + private: |
| + Type type_; |
| + |
| + uint32_t size_; |
| + const CallStack* call_stack_; |
| +}; |
| + |
| +} // namespace leak_detector |
| + |
| +#endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_VALUE_TYPE_ |