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

Side by Side Diff: Source/core/timing/MemoryInfo.cpp

Issue 106353005: Expose performance.memory in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@Perf-Memory-SharedWorker
Patch Set: Created 6 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 "core/timing/MemoryInfo.h" 32 #include "core/timing/MemoryInfo.h"
33 33
34 #include "RuntimeEnabledFeatures.h"
34 #include <limits> 35 #include <limits>
35 #include "core/frame/Frame.h" 36 #include "core/frame/Frame.h"
36 #include "core/frame/Settings.h" 37 #include "core/frame/Settings.h"
37 #include "wtf/CurrentTime.h" 38 #include "wtf/CurrentTime.h"
38 #include "wtf/MainThread.h" 39 #include "wtf/MainThread.h"
39 #include "wtf/MathExtras.h" 40 #include "wtf/MathExtras.h"
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 DEFINE_GC_INFO(MemoryInfo); 44 DEFINE_GC_INFO(MemoryInfo);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 126 }
126 127
127 for (int i = 0; i < numberOfBuckets; ++i) { 128 for (int i = 0; i < numberOfBuckets; ++i) {
128 if (size <= bucketSizeList[i]) 129 if (size <= bucketSizeList[i])
129 return bucketSizeList[i]; 130 return bucketSizeList[i];
130 } 131 }
131 132
132 return bucketSizeList[numberOfBuckets - 1]; 133 return bucketSizeList[numberOfBuckets - 1];
133 } 134 }
134 135
135 136 MemoryInfo::MemoryInfo()
136 MemoryInfo::MemoryInfo(Frame* frame)
137 { 137 {
138 ScriptWrappable::init(this); 138 ScriptWrappable::init(this);
139 if (!frame || !frame->settings())
140 return;
141 139
142 if (frame->settings()->memoryInfoEnabled()) { 140 if (RuntimeEnabledFeatures::preciseMemoryInfoEnabled()) {
143 ScriptGCEvent::getHeapSize(m_info); 141 ScriptGCEvent::getHeapSize(m_info);
144 } else { 142 } else {
145 DEFINE_STATIC_LOCAL(HeapSizeCache, heapSizeCache, ()); 143 DEFINE_STATIC_LOCAL(HeapSizeCache, heapSizeCache, ());
146 heapSizeCache.getCachedHeapSize(m_info); 144 heapSizeCache.getCachedHeapSize(m_info);
147 } 145 }
148 } 146 }
149 147
150 } // namespace WebCore 148 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698