Modified: trunk/Source/WebCore/platform/mac/SharedTimerMac.mm (169954 => 169955)
--- trunk/Source/WebCore/platform/mac/SharedTimerMac.mm 2014-06-13 22:52:50 UTC (rev 169954)
+++ trunk/Source/WebCore/platform/mac/SharedTimerMac.mm 2014-06-13 23:01:31 UTC (rev 169955)
@@ -43,16 +43,10 @@
WTF_MAKE_NONCOPYABLE(PowerObserver);
public:
- static PassOwnPtr<PowerObserver> create()
- {
- return adoptPtr(new PowerObserver);
- }
+ PowerObserver();
~PowerObserver();
private:
- PowerObserver();
-
- static void didReceiveSystemPowerNotification(void* context, io_service_t, uint32_t messageType, void* messageArgument);
void didReceiveSystemPowerNotification(io_service_t, uint32_t messageType, void* messageArgument);
void restartSharedTimer();
@@ -65,11 +59,13 @@
PowerObserver::PowerObserver()
: m_powerConnection(0)
- , m_notificationPort(0)
+ , m_notificationPort(nullptr)
, m_notifierReference(0)
, m_dispatchQueue(dispatch_queue_create("com.apple.WebKit.PowerObserver", 0))
{
- m_powerConnection = IORegisterForSystemPower(this, &m_notificationPort, didReceiveSystemPowerNotification, &m_notifierReference);
+ m_powerConnection = IORegisterForSystemPower(this, &m_notificationPort, [](void* context, io_service_t service, uint32_t messageType, void* messageArgument) {
+ static_cast<PowerObserver*>(context)->didReceiveSystemPowerNotification(service, messageType, messageArgument);
+ }, &m_notifierReference);
if (!m_powerConnection)
return;
@@ -88,11 +84,6 @@
IONotificationPortDestroy(m_notificationPort);
}
-void PowerObserver::didReceiveSystemPowerNotification(void* context, io_service_t service, uint32_t messageType, void* messageArgument)
-{
- static_cast<PowerObserver*>(context)->didReceiveSystemPowerNotification(service, messageType, messageArgument);
-}
-
void PowerObserver::didReceiveSystemPowerNotification(io_service_t, uint32_t messageType, void* messageArgument)
{
IOAllowPowerChange(m_powerConnection, reinterpret_cast<long>(messageArgument));
@@ -118,7 +109,7 @@
timerFired(0, 0);
}
-static PowerObserver* PowerObserver;
+static PowerObserver* powerObserver;
void setSharedTimerFiredFunction(void (*f)())
{
@@ -129,9 +120,9 @@
static void timerFired(CFRunLoopTimerRef, void*)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- sharedTimerFiredFunction();
- [pool drain];
+ @autoreleasepool {
+ sharedTimerFiredFunction();
+ }
}
void setSharedTimerFireInterval(double interval)
@@ -147,8 +138,8 @@
sharedTimer = CFRunLoopTimerCreate(0, fireDate, 0, 0, 0, timerFired, 0);
CFRunLoopAddTimer(CFRunLoopGetCurrent(), sharedTimer, kCFRunLoopCommonModes);
- if (!PowerObserver)
- PowerObserver = PowerObserver::create().leakPtr();
+ if (!powerObserver)
+ powerObserver = std::make_unique<PowerObserver>().release();
}
void stopSharedTimer()
Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (169954 => 169955)
--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp 2014-06-13 22:52:50 UTC (rev 169954)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp 2014-06-13 23:01:31 UTC (rev 169955)
@@ -205,24 +205,19 @@
// BlobResourceHandle doesn't wait for didReceiveResponse, and it currently cannot be used for downloading.
}
-void delayedStartBlobResourceHandle(void* context)
-{
- RefPtr<BlobResourceHandle> handle = adoptRef(static_cast<BlobResourceHandle*>(context));
- handle->doStart();
-}
-
void BlobResourceHandle::start()
{
- if (m_async) {
- // Keep BlobResourceHandle alive until delayedStartBlobResourceHandle runs.
- ref();
-
- // Finish this async call quickly and return.
- callOnMainThread(delayedStartBlobResourceHandle, this);
+ if (!m_async) {
+ doStart();
return;
}
- doStart();
+ RefPtr<BlobResourceHandle> handle(this);
+
+ // Finish this async call quickly and return.
+ callOnMainThread([handle] {
+ handle->doStart();
+ });
}
void BlobResourceHandle::doStart()
Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.h (169954 => 169955)
--- trunk/Source/WebCore/platform/network/BlobResourceHandle.h 2014-06-13 22:52:50 UTC (rev 169954)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.h 2014-06-13 23:01:31 UTC (rev 169955)
@@ -58,8 +58,6 @@
bool aborted() const { return m_aborted; }
private:
- friend void delayedStartBlobResourceHandle(void*);
-
BlobResourceHandle(BlobData*, const ResourceRequest&, ResourceHandleClient*, bool async);
virtual ~BlobResourceHandle();