From 6882a04fb36642862b11efe514251d32070c3d65 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 25 Aug 2016 19:20:41 +0300 Subject: Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443) Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev --- Source/WebKit2/UIProcess/StatisticsRequest.cpp | 49 +++++++++++--------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'Source/WebKit2/UIProcess/StatisticsRequest.cpp') diff --git a/Source/WebKit2/UIProcess/StatisticsRequest.cpp b/Source/WebKit2/UIProcess/StatisticsRequest.cpp index 6f81ccbb3..bf51d234b 100644 --- a/Source/WebKit2/UIProcess/StatisticsRequest.cpp +++ b/Source/WebKit2/UIProcess/StatisticsRequest.cpp @@ -26,9 +26,8 @@ #include "config.h" #include "StatisticsRequest.h" -#include "ImmutableArray.h" -#include "MutableDictionary.h" -#include +#include "APIArray.h" +#include "APIDictionary.h" namespace WebKit { @@ -45,32 +44,24 @@ StatisticsRequest::~StatisticsRequest() uint64_t StatisticsRequest::addOutstandingRequest() { - static int64_t uniqueRequestID; + static std::atomic uniqueRequestID; -#if HAVE(ATOMICS_64BIT) - uint64_t requestID = atomicIncrement(&uniqueRequestID); -#else - static Mutex uniqueRequestMutex; - uniqueRequestMutex.lock(); uint64_t requestID = ++uniqueRequestID; - uniqueRequestMutex.unlock(); -#endif - m_outstandingRequests.add(requestID); return requestID; } -static void addToDictionaryFromHashMap(MutableDictionary* dictionary, const HashMap& map) +static void addToDictionaryFromHashMap(API::Dictionary* dictionary, const HashMap& map) { HashMap::const_iterator end = map.end(); for (HashMap::const_iterator it = map.begin(); it != end; ++it) - dictionary->set(it->key, RefPtr(WebUInt64::create(it->value)).get()); + dictionary->set(it->key, RefPtr(API::UInt64::create(it->value)).get()); } -static PassRefPtr createDictionaryFromHashMap(const HashMap& map) +static Ref createDictionaryFromHashMap(const HashMap& map) { - RefPtr result = MutableDictionary::create(); - addToDictionaryFromHashMap(result.get(), map); + Ref result = API::Dictionary::create(); + addToDictionaryFromHashMap(result.ptr(), map); return result; } @@ -80,7 +71,7 @@ void StatisticsRequest::completedRequest(uint64_t requestID, const StatisticsDat m_outstandingRequests.remove(requestID); if (!m_responseDictionary) - m_responseDictionary = MutableDictionary::create(); + m_responseDictionary = API::Dictionary::create(); // FIXME (Multi-WebProcess) : This code overwrites any previous response data received. // When getting responses from multiple WebProcesses we need to combine items instead of clobbering them. @@ -88,21 +79,23 @@ void StatisticsRequest::completedRequest(uint64_t requestID, const StatisticsDat addToDictionaryFromHashMap(m_responseDictionary.get(), data.statisticsNumbers); if (!data.javaScriptProtectedObjectTypeCounts.isEmpty()) - m_responseDictionary->set("JavaScriptProtectedObjectTypeCounts", createDictionaryFromHashMap(data.javaScriptProtectedObjectTypeCounts).get()); + m_responseDictionary->set("JavaScriptProtectedObjectTypeCounts", createDictionaryFromHashMap(data.javaScriptProtectedObjectTypeCounts)); if (!data.javaScriptObjectTypeCounts.isEmpty()) - m_responseDictionary->set("JavaScriptObjectTypeCounts", createDictionaryFromHashMap(data.javaScriptObjectTypeCounts).get()); - - size_t cacheStatisticsCount = data.webCoreCacheStatistics.size(); - if (cacheStatisticsCount) { - Vector > cacheStatisticsVector(cacheStatisticsCount); - for (size_t i = 0; i < cacheStatisticsCount; ++i) - cacheStatisticsVector[i] = createDictionaryFromHashMap(data.webCoreCacheStatistics[i]); - m_responseDictionary->set("WebCoreCacheStatistics", ImmutableArray::adopt(cacheStatisticsVector).get()); + m_responseDictionary->set("JavaScriptObjectTypeCounts", createDictionaryFromHashMap(data.javaScriptObjectTypeCounts)); + + if (!data.webCoreCacheStatistics.isEmpty()) { + Vector> cacheStatistics; + cacheStatistics.reserveInitialCapacity(data.webCoreCacheStatistics.size()); + + for (const auto& statistic : data.webCoreCacheStatistics) + cacheStatistics.uncheckedAppend(createDictionaryFromHashMap(statistic)); + + m_responseDictionary->set("WebCoreCacheStatistics", API::Array::create(WTFMove(cacheStatistics))); } if (m_outstandingRequests.isEmpty()) { m_callback->performCallbackWithReturnValue(m_responseDictionary.get()); - m_callback = 0; + m_callback = nullptr; } } -- cgit v1.2.1