| OLD | NEW |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 void getCachedHeapSize(HeapInfo& info) | 53 void getCachedHeapSize(HeapInfo& info) |
| 54 { | 54 { |
| 55 maybeUpdate(); | 55 maybeUpdate(); |
| 56 info = m_info; | 56 info = m_info; |
| 57 } | 57 } |
| 58 | 58 |
| 59 static HeapSizeCache& forCurrentThread() | 59 static HeapSizeCache& forCurrentThread() |
| 60 { | 60 { |
| 61 AtomicallyInitializedStatic(ThreadSpecific<HeapSizeCache>*, heapSizeCach
e = new ThreadSpecific<HeapSizeCache>); | 61 AtomicallyInitializedStaticReference(ThreadSpecific<HeapSizeCache>, heap
SizeCache, new ThreadSpecific<HeapSizeCache>); |
| 62 return **heapSizeCache; | 62 return *heapSizeCache; |
| 63 } | 63 } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 void maybeUpdate() | 66 void maybeUpdate() |
| 67 { | 67 { |
| 68 // We rate-limit queries to once every twenty minutes to make it more di
fficult | 68 // We rate-limit queries to once every twenty minutes to make it more di
fficult |
| 69 // for attackers to compare memory usage before and after some event. | 69 // for attackers to compare memory usage before and after some event. |
| 70 const double TwentyMinutesInSeconds = 20 * 60; | 70 const double TwentyMinutesInSeconds = 20 * 60; |
| 71 | 71 |
| 72 double now = monotonicallyIncreasingTime(); | 72 double now = monotonicallyIncreasingTime(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 MemoryInfo::MemoryInfo() | 140 MemoryInfo::MemoryInfo() |
| 141 { | 141 { |
| 142 if (RuntimeEnabledFeatures::preciseMemoryInfoEnabled()) | 142 if (RuntimeEnabledFeatures::preciseMemoryInfoEnabled()) |
| 143 ScriptGCEvent::getHeapSize(m_info); | 143 ScriptGCEvent::getHeapSize(m_info); |
| 144 else | 144 else |
| 145 HeapSizeCache::forCurrentThread().getCachedHeapSize(m_info); | 145 HeapSizeCache::forCurrentThread().getCachedHeapSize(m_info); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |