Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: components/metrics/leak_detector/leak_detector_value_type.h

Issue 986503002: components/metrics: Add runtime memory leak detector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac build fixes: const arg in comparator, rm const in func return type Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..40f61081e9ae61b4dcd9b04a7ce41438062f0062
--- /dev/null
+++ b/components/metrics/leak_detector/leak_detector_value_type.h
@@ -0,0 +1,52 @@
+// 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 metrics {
+namespace leak_detector {
+
+// Used for tracking unique call stacks.
+// Not thread-safe.
+struct CallStack;
+
+class LeakDetectorValueType {
+ public:
+ // Supported types.
+ enum Type {
+ TYPE_NONE,
+ TYPE_SIZE,
+ TYPE_CALL_STACK,
+ };
+
+ LeakDetectorValueType() : type_(TYPE_NONE), size_(0), call_stack_(nullptr) {}
+ explicit LeakDetectorValueType(size_t size)
+ : type_(TYPE_SIZE), size_(size), call_stack_(nullptr) {}
+ explicit LeakDetectorValueType(const CallStack* call_stack)
+ : type_(TYPE_CALL_STACK), size_(0), call_stack_(call_stack) {}
+
+ // Accessors.
+ Type type() const { return type_; }
+ size_t size() const { return size_; }
+ const CallStack* call_stack() const { return call_stack_; }
+
+ // Comparators.
+ bool operator==(const LeakDetectorValueType& other) const;
+ bool operator<(const LeakDetectorValueType& other) const;
+
+ private:
+ Type type_;
+
+ size_t size_;
+ const CallStack* call_stack_;
+};
+
+} // namespace leak_detector
+} // namespace metrics
+
+#endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_VALUE_TYPE_

Powered by Google App Engine
This is Rietveld 408576698