summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/StatisticsRequest.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
commit881da28418d380042aa95a97f0cbd42560a64f7c (patch)
treea794dff3274695e99c651902dde93d934ea7a5af /Source/WebKit2/UIProcess/StatisticsRequest.cpp
parent7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff)
parent0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff)
downloadqtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebKit2/UIProcess/StatisticsRequest.cpp')
-rw-r--r--Source/WebKit2/UIProcess/StatisticsRequest.cpp49
1 files changed, 21 insertions, 28 deletions
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 <wtf/Threading.h>
+#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<int64_t> 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<String, uint64_t>& map)
+static void addToDictionaryFromHashMap(API::Dictionary* dictionary, const HashMap<String, uint64_t>& map)
{
HashMap<String, uint64_t>::const_iterator end = map.end();
for (HashMap<String, uint64_t>::const_iterator it = map.begin(); it != end; ++it)
- dictionary->set(it->key, RefPtr<WebUInt64>(WebUInt64::create(it->value)).get());
+ dictionary->set(it->key, RefPtr<API::UInt64>(API::UInt64::create(it->value)).get());
}
-static PassRefPtr<MutableDictionary> createDictionaryFromHashMap(const HashMap<String, uint64_t>& map)
+static Ref<API::Dictionary> createDictionaryFromHashMap(const HashMap<String, uint64_t>& map)
{
- RefPtr<MutableDictionary> result = MutableDictionary::create();
- addToDictionaryFromHashMap(result.get(), map);
+ Ref<API::Dictionary> 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) <rdar://problem/13200059>: 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<RefPtr<APIObject> > 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<RefPtr<API::Object>> 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;
}
}