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

Side by Side Diff: base/trace_event/memory_usage_estimator.h

Issue 2792183003: Remove base::is_trivially_destructible and use the standard library. (Closed)
Patch Set: triviallydestruct: rm-tests Created 3 years, 8 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 BASE_TRACE_EVENT_MEMORY_USAGE_ESTIMATOR_H_ 5 #ifndef BASE_TRACE_EVENT_MEMORY_USAGE_ESTIMATOR_H_
6 #define BASE_TRACE_EVENT_MEMORY_USAGE_ESTIMATOR_H_ 6 #define BASE_TRACE_EVENT_MEMORY_USAGE_ESTIMATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <array> 10 #include <array>
11 #include <deque> 11 #include <deque>
12 #include <list> 12 #include <list>
13 #include <map> 13 #include <map>
14 #include <memory> 14 #include <memory>
15 #include <queue> 15 #include <queue>
16 #include <set> 16 #include <set>
17 #include <stack> 17 #include <stack>
18 #include <string> 18 #include <string>
19 #include <type_traits> 19 #include <type_traits>
20 #include <unordered_map> 20 #include <unordered_map>
21 #include <unordered_set> 21 #include <unordered_set>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/base_export.h" 24 #include "base/base_export.h"
25 #include "base/containers/linked_list.h" 25 #include "base/containers/linked_list.h"
26 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
27 #include "base/template_util.h"
28 27
29 // Composable memory usage estimators. 28 // Composable memory usage estimators.
30 // 29 //
31 // This file defines set of EstimateMemoryUsage(object) functions that return 30 // This file defines set of EstimateMemoryUsage(object) functions that return
32 // approximate memory usage of their argument. 31 // approximate memory usage of their argument.
33 // 32 //
34 // The ultimate goal is to make memory usage estimation for a class simply a 33 // The ultimate goal is to make memory usage estimation for a class simply a
35 // matter of aggregating EstimateMemoryUsage() results over all fields. 34 // matter of aggregating EstimateMemoryUsage() results over all fields.
36 // 35 //
37 // That is achieved via composability: if EstimateMemoryUsage() is defined 36 // That is achieved via composability: if EstimateMemoryUsage() is defined
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 199
201 template <class T> 200 template <class T>
202 struct EMUCaller<T, typename std::enable_if<HasEMU<T>::value>::type> { 201 struct EMUCaller<T, typename std::enable_if<HasEMU<T>::value>::type> {
203 static size_t Call(const T& value) { return EstimateMemoryUsage(value); } 202 static size_t Call(const T& value) { return EstimateMemoryUsage(value); }
204 }; 203 };
205 204
206 template <class T> 205 template <class T>
207 struct EMUCaller< 206 struct EMUCaller<
208 T, 207 T,
209 typename std::enable_if<!HasEMU<T>::value && 208 typename std::enable_if<!HasEMU<T>::value &&
210 is_trivially_destructible<T>::value>::type> { 209 std::is_trivially_destructible<T>::value>::type> {
211 static size_t Call(const T& value) { return 0; } 210 static size_t Call(const T& value) { return 0; }
212 }; 211 };
213 212
214 // Returns reference to the underlying container of a container adapter. 213 // Returns reference to the underlying container of a container adapter.
215 // Works for std::stack, std::queue and std::priority_queue. 214 // Works for std::stack, std::queue and std::priority_queue.
216 template <class A> 215 template <class A>
217 const typename A::container_type& GetUnderlyingContainer(const A& adapter) { 216 const typename A::container_type& GetUnderlyingContainer(const A& adapter) {
218 struct ExposedAdapter : A { 217 struct ExposedAdapter : A {
219 using A::c; 218 using A::c;
220 }; 219 };
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 539
541 template <class T, class C> 540 template <class T, class C>
542 size_t EstimateMemoryUsage(const std::stack<T, C>& stack) { 541 size_t EstimateMemoryUsage(const std::stack<T, C>& stack) {
543 return EstimateMemoryUsage(internal::GetUnderlyingContainer(stack)); 542 return EstimateMemoryUsage(internal::GetUnderlyingContainer(stack));
544 } 543 }
545 544
546 } // namespace trace_event 545 } // namespace trace_event
547 } // namespace base 546 } // namespace base
548 547
549 #endif // BASE_TRACE_EVENT_MEMORY_USAGE_ESTIMATOR_H_ 548 #endif // BASE_TRACE_EVENT_MEMORY_USAGE_ESTIMATOR_H_
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_allocation_register.h ('k') | components/tracing/core/proto_zero_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698