| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 25 matching lines...) Expand all Loading... |
| 36 #include "bindings/core/v8/V8Initializer.h" | 36 #include "bindings/core/v8/V8Initializer.h" |
| 37 #include "core/Init.h" | 37 #include "core/Init.h" |
| 38 #include "core/animation/AnimationClock.h" | 38 #include "core/animation/AnimationClock.h" |
| 39 #include "core/dom/Microtask.h" | 39 #include "core/dom/Microtask.h" |
| 40 #include "core/fetch/WebCacheMemoryDumpProvider.h" | 40 #include "core/fetch/WebCacheMemoryDumpProvider.h" |
| 41 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 42 #include "core/page/Page.h" | 42 #include "core/page/Page.h" |
| 43 #include "core/workers/WorkerGlobalScopeProxy.h" | 43 #include "core/workers/WorkerGlobalScopeProxy.h" |
| 44 #include "gin/public/v8_platform.h" | 44 #include "gin/public/v8_platform.h" |
| 45 #include "modules/InitModules.h" | 45 #include "modules/InitModules.h" |
| 46 #include "platform/Histogram.h" |
| 46 #include "platform/LayoutTestSupport.h" | 47 #include "platform/LayoutTestSupport.h" |
| 47 #include "platform/Logging.h" | 48 #include "platform/Logging.h" |
| 48 #include "platform/RuntimeEnabledFeatures.h" | 49 #include "platform/RuntimeEnabledFeatures.h" |
| 49 #include "platform/fonts/FontCacheMemoryDumpProvider.h" | 50 #include "platform/fonts/FontCacheMemoryDumpProvider.h" |
| 50 #include "platform/graphics/ImageDecodingStore.h" | 51 #include "platform/graphics/ImageDecodingStore.h" |
| 51 #include "platform/heap/GCTaskRunner.h" | 52 #include "platform/heap/GCTaskRunner.h" |
| 52 #include "platform/heap/Heap.h" | 53 #include "platform/heap/Heap.h" |
| 53 #include "public/platform/Platform.h" | 54 #include "public/platform/Platform.h" |
| 54 #include "public/platform/WebPrerenderingSupport.h" | 55 #include "public/platform/WebPrerenderingSupport.h" |
| 55 #include "public/platform/WebThread.h" | 56 #include "public/platform/WebThread.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 static double currentTimeFunction() | 137 static double currentTimeFunction() |
| 137 { | 138 { |
| 138 return Platform::current()->currentTimeSeconds(); | 139 return Platform::current()->currentTimeSeconds(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 static double monotonicallyIncreasingTimeFunction() | 142 static double monotonicallyIncreasingTimeFunction() |
| 142 { | 143 { |
| 143 return Platform::current()->monotonicallyIncreasingTimeSeconds(); | 144 return Platform::current()->monotonicallyIncreasingTimeSeconds(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 static void histogramEnumerationFunction(const char* name, int sample, int bound
aryValue) | 147 static void maxObservedSizeFunction(size_t sizeInMB) |
| 147 { | 148 { |
| 148 Platform::current()->histogramEnumeration(name, sample, boundaryValue); | 149 const size_t supportedMaxSizeInMB = 4 * 1024; |
| 150 if (sizeInMB >= supportedMaxSizeInMB) |
| 151 sizeInMB = supportedMaxSizeInMB - 1; |
| 152 |
| 153 // Send a UseCounter only when we see the highest memory usage |
| 154 // we've ever seen. |
| 155 DEFINE_STATIC_LOCAL(EnumerationHistogram, committedSizeHistogram, ("Partitio
nAlloc.CommittedSize", supportedMaxSizeInMB)); |
| 156 committedSizeHistogram.count(sizeInMB); |
| 149 } | 157 } |
| 150 | 158 |
| 151 static void callOnMainThreadFunction(WTF::MainThreadFunction function, void* con
text) | 159 static void callOnMainThreadFunction(WTF::MainThreadFunction function, void* con
text) |
| 152 { | 160 { |
| 153 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HERE, n
ew MainThreadTaskRunner(function, context)); | 161 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HERE, n
ew MainThreadTaskRunner(function, context)); |
| 154 } | 162 } |
| 155 | 163 |
| 156 static void adjustAmountOfExternalAllocatedMemory(int size) | 164 static void adjustAmountOfExternalAllocatedMemory(int size) |
| 157 { | 165 { |
| 158 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size); | 166 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size); |
| 159 } | 167 } |
| 160 | 168 |
| 161 void initializeWithoutV8(Platform* platform) | 169 void initializeWithoutV8(Platform* platform) |
| 162 { | 170 { |
| 163 ASSERT(!s_webKitInitialized); | 171 ASSERT(!s_webKitInitialized); |
| 164 s_webKitInitialized = true; | 172 s_webKitInitialized = true; |
| 165 | 173 |
| 166 WTF::Partitions::initialize(histogramEnumerationFunction); | 174 WTF::Partitions::initialize(maxObservedSizeFunction); |
| 167 ASSERT(platform); | 175 ASSERT(platform); |
| 168 Platform::initialize(platform); | 176 Platform::initialize(platform); |
| 169 | 177 |
| 170 WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction, ad
justAmountOfExternalAllocatedMemory); | 178 WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction, ad
justAmountOfExternalAllocatedMemory); |
| 171 WTF::initializeMainThread(callOnMainThreadFunction); | 179 WTF::initializeMainThread(callOnMainThreadFunction); |
| 172 Heap::init(); | 180 Heap::init(); |
| 173 | 181 |
| 174 ThreadState::attachMainThread(); | 182 ThreadState::attachMainThread(); |
| 175 // currentThread() is null if we are running on a thread without a message l
oop. | 183 // currentThread() is null if we are running on a thread without a message l
oop. |
| 176 if (WebThread* currentThread = platform->currentThread()) { | 184 if (WebThread* currentThread = platform->currentThread()) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 ASSERT(!reloadPages); | 308 ASSERT(!reloadPages); |
| 301 Page::refreshPlugins(); | 309 Page::refreshPlugins(); |
| 302 } | 310 } |
| 303 | 311 |
| 304 void decommitFreeableMemory() | 312 void decommitFreeableMemory() |
| 305 { | 313 { |
| 306 WTF::Partitions::decommitFreeableMemory(); | 314 WTF::Partitions::decommitFreeableMemory(); |
| 307 } | 315 } |
| 308 | 316 |
| 309 } // namespace blink | 317 } // namespace blink |
| OLD | NEW |