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

Side by Side Diff: components/metrics/leak_detector/leak_detector.h

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_H_ 5 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_H_
6 #define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_H_ 6 #define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <list> 11 #include <list>
12 #include <memory> 12 #include <memory>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/feature_list.h" 15 #include "base/feature_list.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/task_runner.h" 21 #include "base/task_runner.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
23 23
24 namespace base { 24 namespace base {
25 template <typename T> 25 template <typename T>
26 struct DefaultLazyInstanceTraits; 26 struct LazyInstanceTraitsBase;
27 } 27 }
28 28
29 namespace metrics { 29 namespace metrics {
30 30
31 class MemoryLeakReportProto; 31 class MemoryLeakReportProto;
32 class MemoryLeakReportProto_Params; 32 class MemoryLeakReportProto_Params;
33 33
34 namespace leak_detector { 34 namespace leak_detector {
35 class LeakDetectorImpl; 35 class LeakDetectorImpl;
36 } 36 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 static void InitTLSSlot(); 79 static void InitTLSSlot();
80 80
81 // Add |observer| to the list of stored Observers, i.e. |observers_|, to which 81 // Add |observer| to the list of stored Observers, i.e. |observers_|, to which
82 // the leak detector will report leaks. 82 // the leak detector will report leaks.
83 void AddObserver(Observer* observer); 83 void AddObserver(Observer* observer);
84 84
85 // Remove |observer| from |observers_|. 85 // Remove |observer| from |observers_|.
86 void RemoveObserver(Observer* observer); 86 void RemoveObserver(Observer* observer);
87 87
88 private: 88 private:
89 friend base::DefaultLazyInstanceTraits<LeakDetector>; 89 friend base::LazyInstanceTraitsBase<LeakDetector>;
90 FRIEND_TEST_ALL_PREFIXES(LeakDetectorTest, NotifyObservers); 90 FRIEND_TEST_ALL_PREFIXES(LeakDetectorTest, NotifyObservers);
91 91
92 // Keep these private, as this class is meant to be initialized only through 92 // Keep these private, as this class is meant to be initialized only through
93 // the lazy instance, and never destroyed. 93 // the lazy instance, and never destroyed.
94 LeakDetector(); 94 LeakDetector();
95 ~LeakDetector(); 95 ~LeakDetector();
96 96
97 // Allocator hook function that processes each alloc. Performs sampling and 97 // Allocator hook function that processes each alloc. Performs sampling and
98 // unwinds call stack if necessary. Passes the allocated memory |ptr| and 98 // unwinds call stack if necessary. Passes the allocated memory |ptr| and
99 // allocation size |size| along with call stack info to RecordAlloc(). 99 // allocation size |size| along with call stack info to RecordAlloc().
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // corresponds to the allowable range of |sampling_rate| passed in during 152 // corresponds to the allowable range of |sampling_rate| passed in during
153 // initialization: [0.0f, 1.0f] -> [0, UINT64_MAX]. 153 // initialization: [0.0f, 1.0f] -> [0, UINT64_MAX].
154 uint64_t sampling_factor_; 154 uint64_t sampling_factor_;
155 155
156 DISALLOW_COPY_AND_ASSIGN(LeakDetector); 156 DISALLOW_COPY_AND_ASSIGN(LeakDetector);
157 }; 157 };
158 158
159 } // namespace metrics 159 } // namespace metrics
160 160
161 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_H_ 161 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698