WebKitStatistics.cpp [plain text]
#include "config.h"
#include "WebKitDLL.h"
#include "WebKitStatistics.h"
#include "WebKitStatisticsPrivate.h"
#include <WebCore/BString.h>
#include <wtf/text/StringBuilder.h>
using namespace WebCore;
int WebViewCount;
int WebDataSourceCount;
int WebFrameCount;
int WebHTMLRepresentationCount;
int WebFrameViewCount;
WebKitStatistics::WebKitStatistics()
: m_refCount(0)
{
gClassCount++;
gClassNameCount.add("WebKitStatistics");
}
WebKitStatistics::~WebKitStatistics()
{
gClassCount--;
gClassNameCount.remove("WebKitStatistics");
}
WebKitStatistics* WebKitStatistics::createInstance()
{
WebKitStatistics* instance = new WebKitStatistics();
instance->AddRef();
return instance;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::QueryInterface(REFIID riid, void** ppvObject)
{
*ppvObject = 0;
if (IsEqualGUID(riid, IID_IUnknown))
*ppvObject = static_cast<WebKitStatistics*>(this);
else if (IsEqualGUID(riid, IID_IWebKitStatistics))
*ppvObject = static_cast<WebKitStatistics*>(this);
else
return E_NOINTERFACE;
AddRef();
return S_OK;
}
ULONG STDMETHODCALLTYPE WebKitStatistics::AddRef(void)
{
return ++m_refCount;
}
ULONG STDMETHODCALLTYPE WebKitStatistics::Release(void)
{
ULONG newRef = --m_refCount;
if (!newRef)
delete(this);
return newRef;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::webViewCount(
int *count)
{
*count = WebViewCount;
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::frameCount(
int *count)
{
*count = WebFrameCount;
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::dataSourceCount(
int *count)
{
*count = WebDataSourceCount;
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::viewCount(
int *count)
{
*count = WebFrameViewCount;
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::HTMLRepresentationCount(
int *count)
{
*count = WebHTMLRepresentationCount;
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::comClassCount(
int *classCount)
{
*classCount = gClassCount;
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebKitStatistics::comClassNameCounts(
BSTR *output)
{
StringBuilder builder;
for (auto& slot : gClassNameCount) {
builder.appendNumber(slot.value);
builder.append('\t');
builder.append(slot.key);
builder.append('\n');
}
*output = BString(builder.toString()).release();
return S_OK;
}