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

Unified Diff: third_party/WebKit/Source/platform/exported/Platform.cpp

Issue 1785163002: Move the contents of initializeWithoutV8/shutdownWithoutV8 to Platform::initialize/shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/exported/Platform.cpp
diff --git a/third_party/WebKit/Source/platform/exported/Platform.cpp b/third_party/WebKit/Source/platform/exported/Platform.cpp
index ff29254cbb7c40ab8966bea597129860fddbff5a..ce2ee9d202e8078b99db9eaf7949406afc9c4839 100644
--- a/third_party/WebKit/Source/platform/exported/Platform.cpp
+++ b/third_party/WebKit/Source/platform/exported/Platform.cpp
@@ -30,19 +30,24 @@
#include "base/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
+#include "platform/Histogram.h"
#include "platform/PartitionAllocMemoryDumpProvider.h"
#include "platform/fonts/FontCacheMemoryDumpProvider.h"
#include "platform/graphics/CompositorFactory.h"
+#include "platform/heap/GCTaskRunner.h"
#include "platform/web_memory_dump_provider_adapter.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebPrerenderingSupport.h"
#include "wtf/HashMap.h"
#include "wtf/OwnPtr.h"
namespace blink {
-static Platform* s_platform = 0;
+static Platform* s_platform = nullptr;
using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDumpProviderAdapter>>;
+static GCTaskRunner* s_gcTaskRunner = nullptr;
+
namespace {
ProviderToAdapterMap& memoryDumpProviders()
@@ -58,14 +63,42 @@ Platform::Platform()
{
}
+static void maxObservedSizeFunction(size_t sizeInMB)
+{
+ const size_t supportedMaxSizeInMB = 4 * 1024;
+ if (sizeInMB >= supportedMaxSizeInMB)
+ sizeInMB = supportedMaxSizeInMB - 1;
+
+ // Send a UseCounter only when we see the highest memory usage
+ // we've ever seen.
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, committedSizeHistogram, ("PartitionAlloc.CommittedSize", supportedMaxSizeInMB));
+ committedSizeHistogram.count(sizeInMB);
+}
+
+static void callOnMainThreadFunction(WTF::MainThreadFunction function, void* context)
+{
+ Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(function, AllowCrossThreadAccess(context)));
+}
+
void Platform::initialize(Platform* platform)
{
+ ASSERT(!s_platform);
ASSERT(platform);
s_platform = platform;
s_platform->m_mainThread = platform->currentThread();
+ WTF::Partitions::initialize(maxObservedSizeFunction);
+ WTF::initialize();
+ WTF::initializeMainThread(callOnMainThreadFunction);
+
+ Heap::init();
+
+ ThreadState::attachMainThread();
+
// TODO(ssid): remove this check after fixing crbug.com/486782.
if (s_platform->m_mainThread) {
+ ASSERT(!s_gcTaskRunner);
+ s_gcTaskRunner = new GCTaskRunner(s_platform->m_mainThread);
s_platform->registerMemoryDumpProvider(PartitionAllocMemoryDumpProvider::instance(), "PartitionAlloc");
s_platform->registerMemoryDumpProvider(FontCacheMemoryDumpProvider::instance(), "FontCaches");
}
@@ -75,13 +108,27 @@ void Platform::initialize(Platform* platform)
void Platform::shutdown()
{
+ ASSERT(isMainThread());
CompositorFactory::shutdown();
if (s_platform->m_mainThread) {
s_platform->unregisterMemoryDumpProvider(FontCacheMemoryDumpProvider::instance());
s_platform->unregisterMemoryDumpProvider(PartitionAllocMemoryDumpProvider::instance());
+ ASSERT(s_gcTaskRunner);
+ delete s_gcTaskRunner;
+ s_gcTaskRunner = nullptr;
}
+ // Detach the main thread before starting the shutdown sequence
+ // so that the main thread won't get involved in a GC during the shutdown.
+ ThreadState::detachMainThread();
+
+ Heap::shutdown();
+
+ WTF::shutdown();
+ WebPrerenderingSupport::shutdown();
+ WTF::Partitions::shutdown();
+
s_platform->m_mainThread = nullptr;
s_platform = nullptr;
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698