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

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

Issue 1660383002: Refactoring: Move some classes from content/child to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add PLATFORM_EXPORT; Address haraken's review Created 4 years, 10 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
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 451fe7bb7b811df1a629f19e2e94e3ea03e79792..72904f70552b179fefbf22415ce953f662f5ff87 100644
--- a/third_party/WebKit/Source/platform/exported/Platform.cpp
+++ b/third_party/WebKit/Source/platform/exported/Platform.cpp
@@ -28,13 +28,29 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "base/thread_task_runner_handle.h"
+#include "base/trace_event/memory_dump_manager.h"
#include "platform/PartitionAllocMemoryDumpProvider.h"
#include "platform/graphics/CompositorFactory.h"
+#include "platform/web_memory_dump_provider_adapter.h"
#include "public/platform/Platform.h"
+#include "wtf/HashMap.h"
+#include "wtf/OwnPtr.h"
namespace blink {
static Platform* s_platform = 0;
+using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDumpProviderAdapter>>;
+
+namespace {
+
+ProviderToAdapterMap& memoryDumpProviders()
+{
+ DEFINE_STATIC_LOCAL(ProviderToAdapterMap, providerToAdapterMap, ());
+ return providerToAdapterMap;
+}
+
+} // namespace
Platform::Platform()
: m_mainThread(0)
@@ -76,4 +92,25 @@ WebThread* Platform::mainThread() const
return m_mainThread;
}
+void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* provider, const char* name)
+{
+ WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(provider);
+ ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(provider, adoptPtr(adapter));
+ if (!result.isNewEntry)
+ return;
+ adapter->set_is_registered(true);
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(adapter, name, base::ThreadTaskRunnerHandle::Get());
+}
+
+void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* provider)
+{
+ ProviderToAdapterMap::iterator it = memoryDumpProviders().find(provider);
+ if (it == memoryDumpProviders().end())
+ return;
+ WebMemoryDumpProviderAdapter* adapter = it->value.get();
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(adapter);
+ adapter->set_is_registered(false);
+ memoryDumpProviders().remove(it);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698