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

Side by Side Diff: third_party/WebKit/Source/platform/exported/Platform.cpp

Issue 2009483002: Remove WebMemoryDumpProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 19 matching lines...) Expand all
30 30
31 #include "base/threading/thread_task_runner_handle.h" 31 #include "base/threading/thread_task_runner_handle.h"
32 #include "base/trace_event/memory_dump_manager.h" 32 #include "base/trace_event/memory_dump_manager.h"
33 #include "platform/Histogram.h" 33 #include "platform/Histogram.h"
34 #include "platform/MemoryCacheDumpProvider.h" 34 #include "platform/MemoryCacheDumpProvider.h"
35 #include "platform/PartitionAllocMemoryDumpProvider.h" 35 #include "platform/PartitionAllocMemoryDumpProvider.h"
36 #include "platform/fonts/FontCacheMemoryDumpProvider.h" 36 #include "platform/fonts/FontCacheMemoryDumpProvider.h"
37 #include "platform/graphics/CompositorFactory.h" 37 #include "platform/graphics/CompositorFactory.h"
38 #include "platform/heap/BlinkGCMemoryDumpProvider.h" 38 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
39 #include "platform/heap/GCTaskRunner.h" 39 #include "platform/heap/GCTaskRunner.h"
40 #include "platform/web_memory_dump_provider_adapter.h"
41 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
42 #include "public/platform/ServiceRegistry.h" 41 #include "public/platform/ServiceRegistry.h"
43 #include "public/platform/WebPrerenderingSupport.h" 42 #include "public/platform/WebPrerenderingSupport.h"
44 #include "wtf/HashMap.h" 43 #include "wtf/HashMap.h"
45 #include "wtf/OwnPtr.h" 44 #include "wtf/OwnPtr.h"
46 45
47 namespace blink { 46 namespace blink {
48 47
49 static Platform* s_platform = nullptr; 48 static Platform* s_platform = nullptr;
50 using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDum pProviderAdapter>>;
51 49
52 static GCTaskRunner* s_gcTaskRunner = nullptr; 50 static GCTaskRunner* s_gcTaskRunner = nullptr;
53 51
54 namespace {
55
56 ProviderToAdapterMap& memoryDumpProviders()
57 {
58 DEFINE_STATIC_LOCAL(ProviderToAdapterMap, providerToAdapterMap, ());
59 return providerToAdapterMap;
60 }
61
62 } // namespace
63
64 Platform::Platform() 52 Platform::Platform()
65 : m_mainThread(0) 53 : m_mainThread(0)
66 { 54 {
67 } 55 }
68 56
69 static void maxObservedSizeFunction(size_t sizeInMB) 57 static void maxObservedSizeFunction(size_t sizeInMB)
70 { 58 {
71 const size_t supportedMaxSizeInMB = 4 * 1024; 59 const size_t supportedMaxSizeInMB = 4 * 1024;
72 if (sizeInMB >= supportedMaxSizeInMB) 60 if (sizeInMB >= supportedMaxSizeInMB)
73 sizeInMB = supportedMaxSizeInMB - 1; 61 sizeInMB = supportedMaxSizeInMB - 1;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Platform* Platform::current() 138 Platform* Platform::current()
151 { 139 {
152 return s_platform; 140 return s_platform;
153 } 141 }
154 142
155 WebThread* Platform::mainThread() const 143 WebThread* Platform::mainThread() const
156 { 144 {
157 return m_mainThread; 145 return m_mainThread;
158 } 146 }
159 147
160 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* provider, const char* name)
161 {
162 // MemoryDumpProvider needs a message loop.
163 if (!Platform::current()->currentThread())
164 return;
165
166 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(pro vider);
167 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(provider, adoptPtr(adapter));
168 if (!result.isNewEntry)
169 return;
170 adapter->set_is_registered(true);
171 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(ad apter, name, base::ThreadTaskRunnerHandle::Get());
172 }
173
174 void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* provider)
175 {
176 // MemoryDumpProvider needs a message loop.
177 if (!Platform::current()->currentThread())
178 return;
179
180 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(provider);
181 if (it == memoryDumpProviders().end())
182 return;
183 WebMemoryDumpProviderAdapter* adapter = it->value.get();
184 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( adapter);
185 adapter->set_is_registered(false);
186 memoryDumpProviders().remove(it);
187 }
188
189 ServiceRegistry* Platform::serviceRegistry() 148 ServiceRegistry* Platform::serviceRegistry()
190 { 149 {
191 return ServiceRegistry::getEmptyServiceRegistry(); 150 return ServiceRegistry::getEmptyServiceRegistry();
192 } 151 }
193 152
194 } // namespace blink 153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698