PlatformInstrumentation.h [plain text]
#ifndef PlatformInstrumentation_h
#define PlatformInstrumentation_h
#include <wtf/MainThread.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class PlatformInstrumentationClient {
public:
virtual ~PlatformInstrumentationClient();
virtual void willDecodeImage(const String& imageType) = 0;
virtual void didDecodeImage() = 0;
virtual void willResizeImage(bool shouldCache) = 0;
virtual void didResizeImage() = 0;
};
class PlatformInstrumentation {
public:
static const char ImageDecodeEvent[];
static const char ImageResizeEvent[];
static const char ImageTypeArgument[];
static const char CachedArgument[];
static void setClient(PlatformInstrumentationClient*);
static bool hasClient() { return m_client; }
static void willDecodeImage(const String& imageType);
static void didDecodeImage();
static void willResizeImage(bool shouldCache);
static void didResizeImage();
private:
static const char CategoryName[];
static PlatformInstrumentationClient* m_client;
};
#define FAST_RETURN_IF_NO_CLIENT_OR_NOT_MAIN_THREAD() if (!m_client || !isMainThread()) return;
inline void PlatformInstrumentation::willDecodeImage(const String& imageType)
{
FAST_RETURN_IF_NO_CLIENT_OR_NOT_MAIN_THREAD();
m_client->willDecodeImage(imageType);
}
inline void PlatformInstrumentation::didDecodeImage()
{
FAST_RETURN_IF_NO_CLIENT_OR_NOT_MAIN_THREAD();
m_client->didDecodeImage();
}
inline void PlatformInstrumentation::willResizeImage(bool shouldCache)
{
FAST_RETURN_IF_NO_CLIENT_OR_NOT_MAIN_THREAD();
m_client->willResizeImage(shouldCache);
}
inline void PlatformInstrumentation::didResizeImage()
{
FAST_RETURN_IF_NO_CLIENT_OR_NOT_MAIN_THREAD();
m_client->didResizeImage();
}
}
#endif // PlatformInstrumentation_h