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

Side by Side Diff: third_party/WebKit/Source/platform/PurgeableVector.cpp

Issue 1369253002: Add Web Resources usage to chrome://tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: Fix names. Created 5 years, 2 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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "platform/PurgeableVector.h" 32 #include "platform/PurgeableVector.h"
33 33
34 #include "public/platform/Platform.h" 34 #include "public/platform/Platform.h"
35 #include "public/platform/WebDiscardableMemory.h" 35 #include "public/platform/WebDiscardableMemory.h"
36 #include "public/platform/WebProcessMemoryDump.h"
36 #include "wtf/Assertions.h" 37 #include "wtf/Assertions.h"
37 #include "wtf/OwnPtr.h" 38 #include "wtf/OwnPtr.h"
38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
39 40
40 #include <cstring> 41 #include <cstring>
41 42
42 namespace blink { 43 namespace blink {
43 44
44 // WebDiscardableMemory allocations are expensive and page-grained. We only use 45 // WebDiscardableMemory allocations are expensive and page-grained. We only use
45 // them when there's a reasonable amount of memory to be saved by the OS 46 // them when there's a reasonable amount of memory to be saved by the OS
(...skipping 26 matching lines...) Expand all
72 // Using reserveInitialCapacity() on the underlying vector ensures that the vector uses the 73 // Using reserveInitialCapacity() on the underlying vector ensures that the vector uses the
73 // exact specified capacity to avoid consuming too much memory for small resources. 74 // exact specified capacity to avoid consuming too much memory for small resources.
74 m_vector.reserveInitialCapacity(capacity); 75 m_vector.reserveInitialCapacity(capacity);
75 } else { 76 } else {
76 m_vector.reserveCapacity(capacity); 77 m_vector.reserveCapacity(capacity);
77 } 78 }
78 79
79 moveDataFromDiscardableToVector(); 80 moveDataFromDiscardableToVector();
80 } 81 }
81 82
83 void PurgeableVector::onMemoryDump(const String& dumpName, WebProcessMemoryDump* memoryDump) const
84 {
85 ASSERT(!(m_discardable && m_vector.size()));
86 if (m_discardable) {
87 WebMemoryAllocatorDump* dump = m_discardable->createMemoryAllocatorDump( dumpName, memoryDump);
88 dump->AddScalar("discardable_size", "bytes", m_discardableSize);
89 } else if (m_vector.size()) {
90 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dum pName);
91 dump->AddScalar("size", "bytes", m_vector.size());
92 memoryDump->AddSuballocation(dump->guid(), String(WTF::Partitions::kAllo catedObjectPoolName));
93 }
94 }
95
82 void PurgeableVector::moveDataFromDiscardableToVector() 96 void PurgeableVector::moveDataFromDiscardableToVector()
83 { 97 {
84 if (m_discardable) { 98 if (m_discardable) {
85 m_vector.append(static_cast<const char*>(m_discardable->data()), m_disca rdableSize); 99 m_vector.append(static_cast<const char*>(m_discardable->data()), m_disca rdableSize);
86 clearDiscardable(); 100 clearDiscardable();
87 } 101 }
88 } 102 }
89 103
90 void PurgeableVector::clearDiscardable() 104 void PurgeableVector::clearDiscardable()
91 { 105 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // fragmentation. 267 // fragmentation.
254 // Since the page size is only used below to minimize fragmentation it's sti ll safe to use it 268 // Since the page size is only used below to minimize fragmentation it's sti ll safe to use it
255 // even if it gets out of sync (e.g. due to the use of huge pages). 269 // even if it gets out of sync (e.g. due to the use of huge pages).
256 const size_t kPageSize = 4096; 270 const size_t kPageSize = 4096;
257 newCapacity = (newCapacity + kPageSize - 1) & ~(kPageSize - 1); 271 newCapacity = (newCapacity + kPageSize - 1) & ~(kPageSize - 1);
258 272
259 return std::max(capacity, newCapacity); // Overflow check. 273 return std::max(capacity, newCapacity); // Overflow check.
260 } 274 }
261 275
262 } // namespace blink 276 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/PurgeableVector.h ('k') | third_party/WebKit/Source/platform/SharedBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698