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

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

Issue 2451583002: Add MDP for TabRestorer.
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/sessions/core/persistent_tab_restore_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ESTIMATE_MEMORY_USAGE_H_ 5 #ifndef BASE_TRACE_EVENT_ESTIMATE_MEMORY_USAGE_H_
6 #define BASE_TRACE_EVENT_ESTIMATE_MEMORY_USAGE_H_ 6 #define BASE_TRACE_EVENT_ESTIMATE_MEMORY_USAGE_H_
7 7
8 #include <array> 8 #include <array>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 #if defined(__GLIBCXX__) && _GLIBCXX_USE_CXX11_ABI == 0 240 #if defined(__GLIBCXX__) && _GLIBCXX_USE_CXX11_ABI == 0
241 // libstdc++ with COW std::string - each string allocates a header 241 // libstdc++ with COW std::string - each string allocates a header
242 // (see std::basic_string::_Rep). We don't take into account number 242 // (see std::basic_string::_Rep). We don't take into account number
243 // of references, but we do handle 'empty string' case. 243 // of references, but we do handle 'empty string' case.
244 struct Header { 244 struct Header {
245 typename string_type::size_type length; 245 typename string_type::size_type length;
246 typename string_type::size_type capacity; 246 typename string_type::size_type capacity;
247 int refcount; 247 int refcount;
248 }; 248 };
249 // There is one shared empty string, which we estimate to 0. 249 // There is one shared empty string, which we estimate to 0.
250 static const char* empty_cstr = nullptr; 250 static const value_type* empty_cstr = nullptr;
251 if (!empty_cstr) empty_cstr = std::string().c_str(); 251 if (!empty_cstr) empty_cstr = string_type().c_str();
252 return (string.c_str() == empty_cstr) ? 252 return (string.c_str() == empty_cstr) ?
253 0 : 253 0 :
254 sizeof(Header) + (string.capacity() + 1) * sizeof(value_type); 254 sizeof(Header) + (string.capacity() + 1) * sizeof(value_type);
255 #else 255 #else
256 // C++11 doesn't leave much room for implementors - std::string can 256 // C++11 doesn't leave much room for implementors - std::string can
257 // use short string optimization, but that's about it. We detect SSO 257 // use short string optimization, but that's about it. We detect SSO
258 // by checking that c_str() points inside |string|. 258 // by checking that c_str() points inside |string|.
259 const char* cstr = reinterpret_cast<const char*>(string.c_str()); 259 const char* cstr = reinterpret_cast<const char*>(string.c_str());
260 const char* inline_cstr = reinterpret_cast<const char*>(&string); 260 const char* inline_cstr = reinterpret_cast<const char*>(&string);
261 if (cstr >= inline_cstr && cstr < inline_cstr + sizeof(string)) { 261 if (cstr >= inline_cstr && cstr < inline_cstr + sizeof(string)) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 typename std::unordered_multimap<K, V, H, KE, A>::value_type; 444 typename std::unordered_multimap<K, V, H, KE, A>::value_type;
445 return EstimateHashMapMemoryUsage<value_type>(map.bucket_count(), 445 return EstimateHashMapMemoryUsage<value_type>(map.bucket_count(),
446 map.size()) + 446 map.size()) +
447 EstimateIterableMemoryUsage(map); 447 EstimateIterableMemoryUsage(map);
448 } 448 }
449 449
450 } // namespace trace_event 450 } // namespace trace_event
451 } // namespace base 451 } // namespace base
452 452
453 #endif // BASE_TRACE_EVENT_ESTIMATE_MEMORY_USAGE_H_ 453 #endif // BASE_TRACE_EVENT_ESTIMATE_MEMORY_USAGE_H_
OLDNEW
« no previous file with comments | « no previous file | components/sessions/core/persistent_tab_restore_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698