Replace all remaining uses of WTF::Mutex with WTF::Lock
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 19:31:28 +0000 (19:31 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 19:31:28 +0000 (19:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148089

Reviewed by Geoffrey Garen.

Source/WebCore:

No new tests because no new behavior.

* Modules/webaudio/AsyncAudioDecoder.cpp:
(WebCore::AsyncAudioDecoder::AsyncAudioDecoder):
(WebCore::AsyncAudioDecoder::runLoop):
* Modules/webaudio/AsyncAudioDecoder.h:
* Modules/webaudio/AudioContext.h:
* Modules/webaudio/MediaStreamAudioSource.cpp:
(WebCore::MediaStreamAudioSource::addAudioConsumer):
(WebCore::MediaStreamAudioSource::removeAudioConsumer):
(WebCore::MediaStreamAudioSource::setAudioFormat):
(WebCore::MediaStreamAudioSource::consumeAudio):
* Modules/webaudio/MediaStreamAudioSource.h:
* Modules/webdatabase/Database.cpp:
(WebCore::Database::close):
(WebCore::Database::runTransaction):
(WebCore::Database::inProgressTransactionCompleted):
(WebCore::Database::hasPendingTransaction):
* Modules/webdatabase/Database.h:
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTaskSynchronizer::taskCompleted):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::start):
(WebCore::DatabaseThread::databaseThread):
* Modules/webdatabase/DatabaseThread.h:
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::setDatabaseDirectoryPath):
(WebCore::DatabaseTracker::canEstablishDatabase):
(WebCore::DatabaseTracker::retryCanEstablishDatabase):
(WebCore::DatabaseTracker::hasEntryForOrigin):
(WebCore::DatabaseTracker::getMaxSizeForDatabase):
(WebCore::DatabaseTracker::closeAllDatabases):
(WebCore::DatabaseTracker::fullPathForDatabase):
(WebCore::DatabaseTracker::origins):
(WebCore::DatabaseTracker::databaseNamesForOrigin):
(WebCore::DatabaseTracker::detailsForNameAndOrigin):
(WebCore::DatabaseTracker::setDatabaseDetails):
(WebCore::DatabaseTracker::doneCreatingDatabase):
(WebCore::DatabaseTracker::addOpenDatabase):
(WebCore::DatabaseTracker::removeOpenDatabase):
(WebCore::DatabaseTracker::getOpenDatabases):
(WebCore::DatabaseTracker::originLockFor):
(WebCore::DatabaseTracker::quotaForOrigin):
(WebCore::DatabaseTracker::setQuota):
(WebCore::DatabaseTracker::deleteOrigin):
(WebCore::DatabaseTracker::deleteDatabase):
(WebCore::DatabaseTracker::deleteDatabaseFile):
(WebCore::DatabaseTracker::removeDeletedOpenedDatabases):
(WebCore::DatabaseTracker::deleteDatabaseFileIfEmpty):
(WebCore::DatabaseTracker::openDatabaseMutex):
(WebCore::DatabaseTracker::setClient):
(WebCore::notificationMutex):
(WebCore::DatabaseTracker::scheduleNotifyDatabaseChanged):
(WebCore::DatabaseTracker::notifyDatabasesChanged):
* Modules/webdatabase/DatabaseTracker.h:
* Modules/webdatabase/OriginLock.h:
* Modules/webdatabase/SQLCallbackWrapper.h:
(WebCore::SQLCallbackWrapper::clear):
(WebCore::SQLCallbackWrapper::unwrap):
(WebCore::SQLCallbackWrapper::hasCallback):
* Modules/webdatabase/SQLTransactionBackend.cpp:
(WebCore::SQLTransactionBackend::doCleanup):
(WebCore::SQLTransactionBackend::enqueueStatementBackend):
(WebCore::SQLTransactionBackend::getNextStatement):
* Modules/webdatabase/SQLTransactionBackend.h:
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::scheduleExecutionTermination):
(WebCore::WorkerScriptController::isExecutionTerminating):
* bindings/js/WorkerScriptController.h:
* dom/default/PlatformMessagePortChannel.cpp:
(WebCore::MessagePortChannel::postMessageToRemote):
(WebCore::MessagePortChannel::tryGetMessageFromRemote):
(WebCore::MessagePortChannel::isConnectedTo):
(WebCore::MessagePortChannel::hasPendingActivity):
(WebCore::MessagePortChannel::locallyEntangledPort):
(WebCore::PlatformMessagePortChannel::setRemotePort):
(WebCore::PlatformMessagePortChannel::entangledChannel):
(WebCore::PlatformMessagePortChannel::closeInternal):
* dom/default/PlatformMessagePortChannel.h:
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::removeAllIcons):
(WebCore::IconDatabase::synchronousIconForPageURL):
(WebCore::IconDatabase::synchronousNativeIconForPageURL):
(WebCore::IconDatabase::synchronousIconURLForPageURL):
(WebCore::IconDatabase::retainIconForPageURL):
(WebCore::IconDatabase::performRetainIconForPageURL):
(WebCore::IconDatabase::releaseIconForPageURL):
(WebCore::IconDatabase::performReleaseIconForPageURL):
(WebCore::IconDatabase::setIconDataForIconURL):
(WebCore::IconDatabase::setIconURLForPageURL):
(WebCore::IconDatabase::synchronousLoadDecisionForIconURL):
(WebCore::IconDatabase::synchronousIconDataKnownForIconURL):
(WebCore::IconDatabase::pageURLMappingCount):
(WebCore::IconDatabase::retainedPageURLCount):
(WebCore::IconDatabase::iconRecordCount):
(WebCore::IconDatabase::iconRecordCountWithData):
(WebCore::IconDatabase::wakeSyncThread):
(WebCore::IconDatabase::scheduleOrDeferSyncTimer):
(WebCore::IconDatabase::isOpenBesidesMainThreadCallbacks):
(WebCore::IconDatabase::databasePath):
(WebCore::IconDatabase::getOrCreatePageURLRecord):
(WebCore::IconDatabase::iconDatabaseSyncThread):
(WebCore::IconDatabase::performOpenInitialization):
(WebCore::IconDatabase::performURLImport):
(WebCore::IconDatabase::syncThreadMainLoop):
(WebCore::IconDatabase::performPendingRetainAndReleaseOperations):
(WebCore::IconDatabase::readFromDatabase):
(WebCore::IconDatabase::writeToDatabase):
(WebCore::IconDatabase::pruneUnretainedIcons):
(WebCore::IconDatabase::cleanupSyncThread):
* loader/icon/IconDatabase.h:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
(WebCore::ScrollingTree::commitNewTreeState):
(WebCore::ScrollingTree::setMainFramePinState):
(WebCore::ScrollingTree::mainFrameScrollPosition):
(WebCore::ScrollingTree::setMainFrameScrollPosition):
(WebCore::ScrollingTree::isPointInNonFastScrollableRegion):
(WebCore::ScrollingTree::isRubberBandInProgress):
(WebCore::ScrollingTree::setMainFrameIsRubberBanding):
(WebCore::ScrollingTree::isScrollSnapInProgress):
(WebCore::ScrollingTree::setMainFrameIsScrollSnapping):
(WebCore::ScrollingTree::setCanRubberBandState):
(WebCore::ScrollingTree::rubberBandsAtLeft):
(WebCore::ScrollingTree::rubberBandsAtRight):
(WebCore::ScrollingTree::rubberBandsAtBottom):
(WebCore::ScrollingTree::rubberBandsAtTop):
(WebCore::ScrollingTree::setScrollPinningBehavior):
(WebCore::ScrollingTree::scrollPinningBehavior):
(WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
(WebCore::ScrollingTree::latchedNode):
(WebCore::ScrollingTree::setLatchedNode):
(WebCore::ScrollingTree::clearLatchedNode):
* page/scrolling/ScrollingTree.h:
* platform/MemoryPressureHandler.h:
* platform/audio/HRTFDatabaseLoader.cpp:
(WebCore::HRTFDatabaseLoader::loadAsynchronously):
(WebCore::HRTFDatabaseLoader::waitForLoaderThreadCompletion):
* platform/audio/HRTFDatabaseLoader.h:
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::setReceivedMemoryPressure):
(WebCore::MemoryPressureHandler::clearMemoryPressure):
(WebCore::MemoryPressureHandler::shouldWaitForMemoryClearMessage):
(WebCore::MemoryPressureHandler::respondToMemoryPressureIfNeeded):
* platform/graphics/DisplayRefreshMonitor.cpp:
(WebCore::DisplayRefreshMonitor::displayDidRefresh):
* platform/graphics/DisplayRefreshMonitor.h:
(WebCore::DisplayRefreshMonitor::setMonotonicAnimationStartTime):
(WebCore::DisplayRefreshMonitor::mutex):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::setDelayCallbacks):
(WebCore::MediaPlayerPrivateAVFoundation::clearMainThreadPendingFlag):
(WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::AVFWrapper::callbackContext):
(WebCore::AVFWrapper::~AVFWrapper):
(WebCore::AVFWrapper::mapLock):
(WebCore::AVFWrapper::addToMap):
(WebCore::AVFWrapper::removeFromMap):
(WebCore::AVFWrapper::periodicTimeObserverCallback):
(WebCore::AVFWrapper::processNotification):
(WebCore::AVFWrapper::loadPlayableCompletionCallback):
(WebCore::AVFWrapper::loadMetadataCompletionCallback):
(WebCore::AVFWrapper::seekCompletedCallback):
(WebCore::AVFWrapper::processCue):
(WebCore::AVFWrapper::legibleOutputCallback):
(WebCore::AVFWrapper::processShouldWaitForLoadingOfResource):
(WebCore::AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource):
* platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
(WebCore::InbandTextTrackPrivateGStreamer::handleSample):
(WebCore::InbandTextTrackPrivateGStreamer::notifyTrackOfSample):
* platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h:
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
(WebCore::TrackPrivateBaseGStreamer::tagsChanged):
(WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged):
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
* platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
(WebCore::DisplayRefreshMonitorMac::requestRefreshCallback):
(WebCore::DisplayRefreshMonitorMac::displayLinkFired):
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::MediaPlayerPrivateMediaFoundation::addListener):
(WebCore::MediaPlayerPrivateMediaFoundation::removeListener):
(WebCore::MediaPlayerPrivateMediaFoundation::notifyDeleted):
(WebCore::MediaPlayerPrivateMediaFoundation::AsyncCallback::Invoke):
(WebCore::MediaPlayerPrivateMediaFoundation::AsyncCallback::onMediaPlayerDeleted):
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
* platform/ios/LegacyTileCache.h:
* platform/ios/LegacyTileCache.mm:
(WebCore::LegacyTileCache::setTilesOpaque):
(WebCore::LegacyTileCache::doLayoutTiles):
(WebCore::LegacyTileCache::setCurrentScale):
(WebCore::LegacyTileCache::commitScaleChange):
(WebCore::LegacyTileCache::layoutTilesNow):
(WebCore::LegacyTileCache::layoutTilesNowForRect):
(WebCore::LegacyTileCache::removeAllNonVisibleTiles):
(WebCore::LegacyTileCache::removeAllTiles):
(WebCore::LegacyTileCache::removeForegroundTiles):
(WebCore::LegacyTileCache::setContentReplacementImage):
(WebCore::LegacyTileCache::contentReplacementImage):
(WebCore::LegacyTileCache::tileCreationTimerFired):
(WebCore::LegacyTileCache::setNeedsDisplayInRect):
(WebCore::LegacyTileCache::updateTilingMode):
(WebCore::LegacyTileCache::setTilingMode):
(WebCore::LegacyTileCache::doPendingRepaints):
(WebCore::LegacyTileCache::flushSavedDisplayRects):
(WebCore::LegacyTileCache::prepareToDraw):
* platform/ios/LegacyTileLayerPool.h:
* platform/ios/LegacyTileLayerPool.mm:
(WebCore::LegacyTileLayerPool::addLayer):
(WebCore::LegacyTileLayerPool::takeLayerWithSize):
(WebCore::LegacyTileLayerPool::setCapacity):
(WebCore::LegacyTileLayerPool::prune):
(WebCore::LegacyTileLayerPool::drain):
* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownloadManager::add):
(WebCore::CurlDownloadManager::remove):
(WebCore::CurlDownloadManager::getActiveDownloadCount):
(WebCore::CurlDownloadManager::getPendingDownloadCount):
(WebCore::CurlDownloadManager::stopThreadIfIdle):
(WebCore::CurlDownloadManager::updateHandleList):
(WebCore::CurlDownload::~CurlDownload):
(WebCore::CurlDownload::init):
(WebCore::CurlDownload::getTempPath):
(WebCore::CurlDownload::getUrl):
(WebCore::CurlDownload::getResponse):
(WebCore::CurlDownload::closeFile):
(WebCore::CurlDownload::didReceiveHeader):
(WebCore::CurlDownload::didReceiveData):
(WebCore::CurlDownload::didFail):
* platform/network/curl/CurlDownload.h:
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::cookieJarPath):
(WebCore::sharedResourceMutex):
(WebCore::curl_lock_callback):
(WebCore::curl_unlock_callback):
* platform/network/ios/QuickLook.mm:
(WebCore::QLDirectoryAttributes):
(qlPreviewConverterDictionaryMutex):
(WebCore::addQLPreviewConverterWithFileForURL):
(WebCore::qlPreviewConverterUTIForURL):
(WebCore::removeQLPreviewConverterForURL):
(WebCore::safeQLURLForDocumentURLAndResourceURL):
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::close):
(WebCore::SQLiteDatabase::maximumSize):
(WebCore::SQLiteDatabase::setMaximumSize):
(WebCore::SQLiteDatabase::pageSize):
(WebCore::SQLiteDatabase::freeSpaceSize):
(WebCore::SQLiteDatabase::totalSize):
(WebCore::SQLiteDatabase::runIncrementalVacuumCommand):
(WebCore::SQLiteDatabase::setAuthorizer):
* platform/sql/SQLiteDatabase.h:
(WebCore::SQLiteDatabase::databaseMutex):
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::step):
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::start):
(WebCore::WorkerThread::workerThread):
(WebCore::WorkerThread::stop):
* workers/WorkerThread.h:

Source/WebKit:

* Storage/StorageAreaSync.cpp:
(WebCore::StorageAreaSync::syncTimerFired):
(WebCore::StorageAreaSync::markImported):
(WebCore::StorageAreaSync::blockUntilImportComplete):
(WebCore::StorageAreaSync::performSync):
* Storage/StorageAreaSync.h:
* Storage/StorageTracker.cpp:
(WebCore::StorageTracker::setDatabaseDirectoryPath):
(WebCore::StorageTracker::finishedImportingOriginIdentifiers):
(WebCore::StorageTracker::syncImportOriginIdentifiers):
(WebCore::StorageTracker::syncFileSystemAndTrackerDatabase):
(WebCore::StorageTracker::setOriginDetails):
(WebCore::StorageTracker::syncSetOriginDetails):
(WebCore::StorageTracker::origins):
(WebCore::StorageTracker::deleteAllOrigins):
(WebCore::StorageTracker::syncDeleteAllOrigins):
(WebCore::StorageTracker::deleteOrigin):
(WebCore::StorageTracker::syncDeleteOrigin):
(WebCore::StorageTracker::canDeleteOrigin):
(WebCore::StorageTracker::cancelDeletingOrigin):
(WebCore::StorageTracker::diskUsageForOrigin):
* Storage/StorageTracker.h:

Source/WebKit/ios:

* WebCoreSupport/WebFixedPositionContent.mm:
(WebFixedPositionContentDataLock):
(-[WebFixedPositionContent scrollOrZoomChanged:]):
(-[WebFixedPositionContent overflowScrollPositionForLayer:changedTo:]):
(-[WebFixedPositionContent setViewportConstrainedLayers:stickyContainerMap:]):
(-[WebFixedPositionContent hasFixedOrStickyPositionLayers]):
(-[WebFixedPositionContent minimumOffsetFromFixedPositionLayersToAnchorEdge:ofRect:inLayer:]):

Source/WebKit/mac:

* Storage/WebDatabaseManager.mm:
(transactionBackgroundTaskIdentifierLock):
(+[WebDatabaseManager startBackgroundTask]):
(+[WebDatabaseManager endBackgroundTask]):
* WebView/WebView.mm:
(-[WebView _synchronizeCustomFixedPositionLayoutRect]):
(-[WebView _setCustomFixedPositionLayoutRectInWebThread:synchronize:]):
(-[WebView _setCustomFixedPositionLayoutRect:]):
(-[WebView _fetchCustomFixedPositionLayoutRect:]):
* WebView/WebViewData.h:

Source/WebKit/win:

* Plugins/PluginMainThreadScheduler.cpp:
(WebCore::PluginMainThreadScheduler::scheduleCall):
(WebCore::PluginMainThreadScheduler::registerPlugin):
(WebCore::PluginMainThreadScheduler::unregisterPlugin):
(WebCore::PluginMainThreadScheduler::dispatchCallsForPlugin):
* Plugins/PluginMainThreadScheduler.h:
* WebIconDatabase.cpp:
(WebIconDatabase::didRemoveAllIcons):
(WebIconDatabase::didImportIconURLForPageURL):
(WebIconDatabase::deliverNotifications):
* WebIconDatabase.h:
* WebLocalizableStrings.cpp:
(mainBundleLocStrings):
(frameworkLocStringsMutex):
(findCachedString):
(cacheString):

Source/WebKit2:

* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::postDatabaseTask):
(WebKit::DatabaseProcess::performNextDatabaseTask):
* DatabaseProcess/DatabaseProcess.h:
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::shutdown):
(WebKit::UniqueIDBDatabase::postMainThreadTask):
(WebKit::UniqueIDBDatabase::performNextMainThreadTask):
(WebKit::UniqueIDBDatabase::postDatabaseTask):
(WebKit::UniqueIDBDatabase::performNextDatabaseTask):
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
* Platform/IPC/Connection.cpp:
(IPC::Connection::sendSyncMessage):
(IPC::Connection::sendSyncMessageFromSecondaryThread):
(IPC::Connection::waitForSyncReply):
(IPC::Connection::processIncomingSyncReply):
(IPC::Connection::connectionDidClose):
* Platform/IPC/Connection.h:
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::appendUpdate):
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::createCompositingThread):
(WebKit::ThreadedCompositor::runCompositingThread):
(WebKit::ThreadedCompositor::terminateCompositingThread):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm:
(WebKit::CustomProtocolManager::addCustomProtocol):
(WebKit::CustomProtocolManager::removeCustomProtocol):
(WebKit::CustomProtocolManager::registerScheme):
(WebKit::CustomProtocolManager::unregisterScheme):
(WebKit::CustomProtocolManager::supportsScheme):
(WebKit::CustomProtocolManager::protocolForID):
* Shared/Network/CustomProtocols/CustomProtocolManager.h:
* Shared/linux/SeccompFilters/SeccompBroker.cpp:
* WebProcess/Plugins/PluginProcessConnectionManager.cpp:
(WebKit::PluginProcessConnectionManager::getPluginProcessConnection):
(WebKit::PluginProcessConnectionManager::removePluginProcessConnection):
(WebKit::PluginProcessConnectionManager::pluginProcessCrashed):
* WebProcess/Plugins/PluginProcessConnectionManager.h:
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::addScrollingTreeForPage):
(WebKit::EventDispatcher::removeScrollingTreeForPage):
(WebKit::EventDispatcher::wheelEvent):
* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/soup/WebKitSoupRequestInputStream.cpp:
(webkitSoupRequestInputStreamReadAsync):
(webkitSoupRequestInputStreamAddData):

Source/WTF:

This also beefs up and rationalizes the Condition API, so that it can deal with units of time
other than just steady_clock. This makes it easier to port ThreadCondition and
std::condition_variable code over to Condition. This patch does not take a position on what
kind of time is best; from reading a lot of the uses in WebCore, it seems like our use of
double to measure seconds is often nicer than the many different classes in std::chrono.

Also added a Condition speed test, to make sure that all of this is a good idea. And indeed it
is. The 1-producer/1-consumer scenario with a 100-element queue runs 36x faster using
Lock/Condition than Mutex/ThreadCondition when you use the notifyOne()-per-enqueue style. It
runs 58x faster with Lock/Condition when you use the notifyAll()-at-boundary style. Note that
I have a bug open for making the notifyOne()-per-enqueue style even faster:
https://bugs.webkit.org/show_bug.cgi?id=148090. Also, the 10-consumer/10-producer scenario with
a 100-element queue runs 20x faster with Lock/Condition for notifyOne()-per-enqueue and 30x
faster with notifyAll()-at-boundary. The only way to tweak the test to get
Mutex/ThreadCondition to win is to have one producer, one consumer, a 1-element queue, and use
the notifyOne()-per-enqueue style. In that case, one of the two threads is going to be waiting
most of the time and the test basically measures wake-up latency and nothing else. Because
Condition::wait() does a little bit more work than ThreadCondition::wait(),
Mutex/ThreadCondition end up running 3% faster in this test case. But if you vary any of the
parameters of the test, Mutex/ThreadCondition ends up losing - all it takes is more threads or
a queue size of 5 or more. To my knowledge, we never do producer/consumer with a queue bounded
to one element precisely because that approach is the least efficient regardless of locking
algorithm. For example, neither WTF::MessageQueue nor DFG::Worklist have any bounds on their
queue size. So, it seems that replacing all uses of system mutexes and condition variables with
our own thing is a great idea.

* benchmarks/LockSpeedTest.cpp:
* benchmarks/ConditionSpeedTest.cpp: Added.
* wtf/Condition.h:
(WTF::Condition::Condition):
(WTF::Condition::waitUntil):
(WTF::Condition::waitFor):
(WTF::Condition::wait):
(WTF::Condition::waitUntilWallClockSeconds):
(WTF::Condition::waitUntilMonotonicClockSeconds):
(WTF::Condition::notifyOne):
(WTF::Condition::notifyAll):
(WTF::Condition::waitForSecondsImpl):
(WTF::Condition::waitForImpl):
(WTF::Condition::absoluteFromRelative):
* wtf/MessageQueue.h:
(WTF::MessageQueue::infiniteTime):
(WTF::MessageQueue<DataType>::append):
(WTF::MessageQueue<DataType>::appendAndKill):
(WTF::MessageQueue<DataType>::appendAndCheckEmpty):
(WTF::MessageQueue<DataType>::prepend):
(WTF::MessageQueue<DataType>::removeIf):
(WTF::MessageQueue<DataType>::isEmpty):
(WTF::MessageQueue<DataType>::kill):
(WTF::MessageQueue<DataType>::killed):
* wtf/ParallelJobsGeneric.cpp:
(WTF::ParallelEnvironment::ThreadPrivate::execute):
(WTF::ParallelEnvironment::ThreadPrivate::waitForFinish):
(WTF::ParallelEnvironment::ThreadPrivate::workerThread):
* wtf/ParallelJobsGeneric.h:
* wtf/ParkingLot.cpp:
(WTF::ParkingLot::parkConditionally):
* wtf/ParkingLot.h:
(WTF::ParkingLot::compareAndPark):
* wtf/ThreadingPthreads.cpp:
(WTF::initializeThreading):
* wtf/ThreadingWin.cpp:
(WTF::initializeThreading):
* wtf/dtoa.cpp:
(WTF::pow5mult):
* wtf/dtoa.h:

Tools:

* DumpRenderTree/JavaScriptThreading.cpp:
(javaScriptThreadsMutex):
(runJavaScriptThread):
(startJavaScriptThreads):
(stopJavaScriptThreads):
* TestWebKitAPI/Tests/WTF/Condition.cpp: Fixed a bug in the test that I found from turning the test into a benchmark.
* TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/glib/WorkQueueGLib.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188594 268f45cc-cd09-0410-ab3c-d52691b4dbfc

109 files changed:
Source/WTF/ChangeLog
Source/WTF/benchmarks/ConditionSpeedTest.cpp [new file with mode: 0644]
Source/WTF/benchmarks/LockSpeedTest.cpp
Source/WTF/wtf/Condition.h
Source/WTF/wtf/MessageQueue.h
Source/WTF/wtf/ParallelJobsGeneric.cpp
Source/WTF/wtf/ParallelJobsGeneric.h
Source/WTF/wtf/ParkingLot.cpp
Source/WTF/wtf/ParkingLot.h
Source/WTF/wtf/ThreadingPthreads.cpp
Source/WTF/wtf/ThreadingWin.cpp
Source/WTF/wtf/dtoa.cpp
Source/WTF/wtf/dtoa.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AsyncAudioDecoder.cpp
Source/WebCore/Modules/webaudio/AsyncAudioDecoder.h
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp
Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/Modules/webdatabase/Database.h
Source/WebCore/Modules/webdatabase/DatabaseTask.cpp
Source/WebCore/Modules/webdatabase/DatabaseTask.h
Source/WebCore/Modules/webdatabase/DatabaseThread.cpp
Source/WebCore/Modules/webdatabase/DatabaseThread.h
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.h
Source/WebCore/Modules/webdatabase/OriginLock.h
Source/WebCore/Modules/webdatabase/SQLCallbackWrapper.h
Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp
Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/js/WorkerScriptController.h
Source/WebCore/dom/default/PlatformMessagePortChannel.cpp
Source/WebCore/dom/default/PlatformMessagePortChannel.h
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/loader/icon/IconDatabase.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/platform/MemoryPressureHandler.h
Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp
Source/WebCore/platform/audio/HRTFDatabaseLoader.h
Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp
Source/WebCore/platform/graphics/DisplayRefreshMonitor.h
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h
Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h
Source/WebCore/platform/ios/LegacyTileCache.h
Source/WebCore/platform/ios/LegacyTileCache.mm
Source/WebCore/platform/ios/LegacyTileLayerPool.h
Source/WebCore/platform/ios/LegacyTileLayerPool.mm
Source/WebCore/platform/network/curl/CurlDownload.cpp
Source/WebCore/platform/network/curl/CurlDownload.h
Source/WebCore/platform/network/curl/ResourceHandleManager.cpp
Source/WebCore/platform/network/ios/QuickLook.mm
Source/WebCore/platform/sql/SQLiteDatabase.cpp
Source/WebCore/platform/sql/SQLiteDatabase.h
Source/WebCore/platform/sql/SQLiteStatement.cpp
Source/WebCore/workers/WorkerThread.cpp
Source/WebCore/workers/WorkerThread.h
Source/WebKit/ChangeLog
Source/WebKit/Storage/StorageAreaSync.cpp
Source/WebKit/Storage/StorageAreaSync.h
Source/WebKit/Storage/StorageTracker.cpp
Source/WebKit/Storage/StorageTracker.h
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/WebCoreSupport/WebFixedPositionContent.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Storage/WebDatabaseManager.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewData.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/Plugins/PluginMainThreadScheduler.cpp
Source/WebKit/win/Plugins/PluginMainThreadScheduler.h
Source/WebKit/win/WebIconDatabase.cpp
Source/WebKit/win/WebIconDatabase.h
Source/WebKit/win/WebLocalizableStrings.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp
Source/WebKit2/DatabaseProcess/DatabaseProcess.h
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h
Source/WebKit2/Platform/IPC/Connection.cpp
Source/WebKit2/Platform/IPC/Connection.h
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
Source/WebKit2/Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm
Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h
Source/WebKit2/Shared/linux/SeccompFilters/SeccompBroker.cpp
Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.cpp
Source/WebKit2/WebProcess/Plugins/PluginProcessConnectionManager.h
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/EventDispatcher.h
Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp
Tools/ChangeLog
Tools/DumpRenderTree/JavaScriptThreading.cpp
Tools/TestWebKitAPI/Tests/WTF/Condition.cpp
Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp
Tools/TestWebKitAPI/Tests/WTF/glib/WorkQueueGLib.cpp

index 3d34853..b7926b4 100644 (file)
@@ -1,3 +1,77 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        This also beefs up and rationalizes the Condition API, so that it can deal with units of time
+        other than just steady_clock. This makes it easier to port ThreadCondition and
+        std::condition_variable code over to Condition. This patch does not take a position on what
+        kind of time is best; from reading a lot of the uses in WebCore, it seems like our use of
+        double to measure seconds is often nicer than the many different classes in std::chrono.
+
+        Also added a Condition speed test, to make sure that all of this is a good idea. And indeed it
+        is. The 1-producer/1-consumer scenario with a 100-element queue runs 36x faster using
+        Lock/Condition than Mutex/ThreadCondition when you use the notifyOne()-per-enqueue style. It
+        runs 58x faster with Lock/Condition when you use the notifyAll()-at-boundary style. Note that
+        I have a bug open for making the notifyOne()-per-enqueue style even faster:
+        https://bugs.webkit.org/show_bug.cgi?id=148090. Also, the 10-consumer/10-producer scenario with
+        a 100-element queue runs 20x faster with Lock/Condition for notifyOne()-per-enqueue and 30x
+        faster with notifyAll()-at-boundary. The only way to tweak the test to get
+        Mutex/ThreadCondition to win is to have one producer, one consumer, a 1-element queue, and use
+        the notifyOne()-per-enqueue style. In that case, one of the two threads is going to be waiting
+        most of the time and the test basically measures wake-up latency and nothing else. Because
+        Condition::wait() does a little bit more work than ThreadCondition::wait(),
+        Mutex/ThreadCondition end up running 3% faster in this test case. But if you vary any of the
+        parameters of the test, Mutex/ThreadCondition ends up losing - all it takes is more threads or
+        a queue size of 5 or more. To my knowledge, we never do producer/consumer with a queue bounded
+        to one element precisely because that approach is the least efficient regardless of locking
+        algorithm. For example, neither WTF::MessageQueue nor DFG::Worklist have any bounds on their
+        queue size. So, it seems that replacing all uses of system mutexes and condition variables with
+        our own thing is a great idea.
+
+        * benchmarks/LockSpeedTest.cpp:
+        * benchmarks/ConditionSpeedTest.cpp: Added.
+        * wtf/Condition.h:
+        (WTF::Condition::Condition):
+        (WTF::Condition::waitUntil):
+        (WTF::Condition::waitFor):
+        (WTF::Condition::wait):
+        (WTF::Condition::waitUntilWallClockSeconds):
+        (WTF::Condition::waitUntilMonotonicClockSeconds):
+        (WTF::Condition::notifyOne):
+        (WTF::Condition::notifyAll):
+        (WTF::Condition::waitForSecondsImpl):
+        (WTF::Condition::waitForImpl):
+        (WTF::Condition::absoluteFromRelative):
+        * wtf/MessageQueue.h:
+        (WTF::MessageQueue::infiniteTime):
+        (WTF::MessageQueue<DataType>::append):
+        (WTF::MessageQueue<DataType>::appendAndKill):
+        (WTF::MessageQueue<DataType>::appendAndCheckEmpty):
+        (WTF::MessageQueue<DataType>::prepend):
+        (WTF::MessageQueue<DataType>::removeIf):
+        (WTF::MessageQueue<DataType>::isEmpty):
+        (WTF::MessageQueue<DataType>::kill):
+        (WTF::MessageQueue<DataType>::killed):
+        * wtf/ParallelJobsGeneric.cpp:
+        (WTF::ParallelEnvironment::ThreadPrivate::execute):
+        (WTF::ParallelEnvironment::ThreadPrivate::waitForFinish):
+        (WTF::ParallelEnvironment::ThreadPrivate::workerThread):
+        * wtf/ParallelJobsGeneric.h:
+        * wtf/ParkingLot.cpp:
+        (WTF::ParkingLot::parkConditionally):
+        * wtf/ParkingLot.h:
+        (WTF::ParkingLot::compareAndPark):
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::initializeThreading):
+        * wtf/ThreadingWin.cpp:
+        (WTF::initializeThreading):
+        * wtf/dtoa.cpp:
+        (WTF::pow5mult):
+        * wtf/dtoa.h:
+
 2015-08-17  Alex Christensen  <achristensen@webkit.org>
 
         Build Debug Suffix on Windows with CMake
diff --git a/Source/WTF/benchmarks/ConditionSpeedTest.cpp b/Source/WTF/benchmarks/ConditionSpeedTest.cpp
new file mode 100644 (file)
index 0000000..cb1d101
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+// On Mac, you can build this like so:
+// clang++ -o ConditionSpeedTest Source/WTF/benchmarks/ConditionSpeedTest.cpp -O3 -W -ISource/WTF -LWebKitBuild/Release -lWTF -framework Foundation -licucore -std=c++11
+
+#include "config.h"
+
+#include <mutex>
+#include <thread>
+#include <unistd.h>
+#include <wtf/Condition.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/DataLog.h>
+#include <wtf/Deque.h>
+#include <wtf/Lock.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/StringPrintStream.h>
+#include <wtf/Threading.h>
+#include <wtf/ThreadingPrimitives.h>
+#include <wtf/Vector.h>
+
+namespace {
+
+const bool verbose = false;
+
+unsigned numProducers;
+unsigned numConsumers;
+unsigned maxQueueSize;
+unsigned numMessagesPerProducer;
+    
+NO_RETURN void usage()
+{
+    printf("Usage: ConditionSpeedTest lock|mutex|all <num producers> <num consumers> <max queue size> <num messages per producer>\n");
+    exit(1);
+}
+
+template<typename Functor, typename ConditionType, typename LockType>
+void wait(ConditionType& condition, LockType& lock, const Functor& predicate)
+{
+    while (!predicate())
+        condition.wait(lock);
+}
+
+template<typename LockType, typename ConditionType, typename NotifyFunctor, typename NotifyAllFunctor>
+void runTest(
+    unsigned numProducers,
+    unsigned numConsumers,
+    unsigned maxQueueSize,
+    unsigned numMessagesPerProducer,
+    const NotifyFunctor& notify,
+    const NotifyAllFunctor& notifyAll)
+{
+    Deque<unsigned> queue;
+    bool shouldContinue = true;
+    LockType lock;
+    ConditionType emptyCondition;
+    ConditionType fullCondition;
+
+    Vector<ThreadIdentifier> consumerThreads;
+    Vector<ThreadIdentifier> producerThreads;
+
+    Vector<unsigned> received;
+    LockType receivedLock;
+    
+    for (unsigned i = numConsumers; i--;) {
+        ThreadIdentifier threadIdentifier = createThread(
+            "Consumer thread",
+            [&] () {
+                for (;;) {
+                    unsigned result;
+                    unsigned mustNotify = false;
+                    {
+                        std::unique_lock<LockType> locker(lock);
+                        wait(
+                            emptyCondition, lock,
+                            [&] () {
+                                if (verbose)
+                                    dataLog(toString(currentThread(), ": Checking consumption predicate with shouldContinue = ", shouldContinue, ", queue.size() == ", queue.size(), "\n"));
+                                return !shouldContinue || !queue.isEmpty();
+                            });
+                        if (!shouldContinue && queue.isEmpty())
+                            return;
+                        mustNotify = queue.size() == maxQueueSize;
+                        result = queue.takeFirst();
+                    }
+                    notify(fullCondition, mustNotify);
+
+                    {
+                        std::lock_guard<LockType> locker(receivedLock);
+                        received.append(result);
+                    }
+                }
+            });
+        consumerThreads.append(threadIdentifier);
+    }
+
+    for (unsigned i = numProducers; i--;) {
+        ThreadIdentifier threadIdentifier = createThread(
+            "Producer Thread",
+            [&] () {
+                for (unsigned i = 0; i < numMessagesPerProducer; ++i) {
+                    bool mustNotify = false;
+                    {
+                        std::unique_lock<LockType> locker(lock);
+                        wait(
+                            fullCondition, lock,
+                            [&] () {
+                                if (verbose)
+                                    dataLog(toString(currentThread(), ": Checking production predicate with shouldContinue = ", shouldContinue, ", queue.size() == ", queue.size(), "\n"));
+                                return queue.size() < maxQueueSize;
+                            });
+                        mustNotify = queue.isEmpty();
+                        queue.append(i);
+                    }
+                    notify(emptyCondition, mustNotify);
+                }
+            });
+        producerThreads.append(threadIdentifier);
+    }
+
+    for (ThreadIdentifier threadIdentifier : producerThreads)
+        waitForThreadCompletion(threadIdentifier);
+
+    {
+        std::lock_guard<LockType> locker(lock);
+        shouldContinue = false;
+    }
+    notifyAll(emptyCondition);
+
+    for (ThreadIdentifier threadIdentifier : consumerThreads)
+        waitForThreadCompletion(threadIdentifier);
+
+    RELEASE_ASSERT(numProducers * numMessagesPerProducer == received.size());
+    std::sort(received.begin(), received.end());
+    for (unsigned messageIndex = 0; messageIndex < numMessagesPerProducer; ++messageIndex) {
+        for (unsigned producerIndex = 0; producerIndex < numProducers; ++producerIndex)
+            RELEASE_ASSERT(messageIndex == received[messageIndex * numProducers + producerIndex]);
+    }
+}
+
+template<typename LockType, typename ConditionType, typename NotifyFunctor, typename NotifyAllFunctor>
+void runBenchmark(
+    const char* name,
+    const NotifyFunctor& notify,
+    const NotifyAllFunctor& notifyAll)
+{
+    double before = monotonicallyIncreasingTimeMS();
+    
+    runTest<LockType, ConditionType>(
+        numProducers,
+        numConsumers,
+        maxQueueSize,
+        numMessagesPerProducer,
+        notify,
+        notifyAll);
+
+    double after = monotonicallyIncreasingTimeMS();
+
+    printf("%s: %.3lf ms.\n", name, after - before);
+}
+
+} // anonymous namespace
+
+int main(int argc, char** argv)
+{
+    WTF::initializeThreading();
+
+    if (argc != 6
+        || sscanf(argv[2], "%u", &numProducers) != 1
+        || sscanf(argv[3], "%u", &numConsumers) != 1
+        || sscanf(argv[4], "%u", &maxQueueSize) != 1
+        || sscanf(argv[5], "%u", &numMessagesPerProducer) != 1)
+        usage();
+
+    bool didRun = false;
+    if (!strcmp(argv[1], "lock") || !strcmp(argv[1], "all")) {
+        runBenchmark<Lock, Condition>(
+            "WTF Lock NotifyOne",
+            [&] (Condition& condition, bool mustNotify) {
+                condition.notifyOne();
+            },
+            [&] (Condition& condition) {
+                condition.notifyAll();
+            });
+        runBenchmark<Lock, Condition>(
+            "WTF Lock NotifyAll",
+            [&] (Condition& condition, bool mustNotify) {
+                if (mustNotify)
+                    condition.notifyAll();
+            },
+            [&] (Condition& condition) {
+                condition.notifyAll();
+            });
+        didRun = true;
+    }
+    if (!strcmp(argv[1], "mutex") || !strcmp(argv[1], "all")) {
+        runBenchmark<Mutex, ThreadCondition>(
+            "Platform Mutex NotifyOne",
+            [&] (ThreadCondition& condition, bool mustNotify) {
+                condition.signal();
+            },
+            [&] (ThreadCondition& condition) {
+                condition.broadcast();
+            });
+        runBenchmark<Mutex, ThreadCondition>(
+            "Platform Mutex NotifyAll",
+            [&] (ThreadCondition& condition, bool mustNotify) {
+                if (mustNotify)
+                    condition.broadcast();
+            },
+            [&] (ThreadCondition& condition) {
+                condition.broadcast();
+            });
+        didRun = true;
+    }
+
+    if (!didRun)
+        usage();
+
+    return 0;
+}
+
index 6f83216..8cd4bd3 100644 (file)
@@ -23,6 +23,9 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
+// On Mac, you can build this like so:
+// clang++ -o LockSpeedTest Source/WTF/benchmarks/LockSpeedTest.cpp -O3 -W -ISource/WTF -LWebKitBuild/Release -lWTF -framework Foundation -licucore -std=c++11
+
 #include "config.h"
 
 #include <unistd.h>
index bd841fb..11536db 100644 (file)
 #include <chrono>
 #include <functional>
 #include <mutex>
+#include <wtf/CurrentTime.h>
 #include <wtf/ParkingLot.h>
 
 namespace WTF {
 
 class Condition {
 public:
+    typedef ParkingLot::Clock Clock;
+    
     Condition() { }
 
     // Wait on a parking queue while releasing the given lock. It will unlock the lock just before
     // parking, and relock it upon wakeup. Returns true if we woke up due to some call to
-    // notifyOne() or notifyAll(). Returns false if we woke up due to a timeout.
+    // notifyOne() or notifyAll(). Returns false if we woke up due to a timeout. Note that this form
+    // of waitUntil() has some quirks:
+    //
+    // No spurious wake-up: in order for this to return before the timeout, some notifyOne() or
+    // notifyAll() call must have happened. No scenario other than timeout or notify can lead to this
+    // method returning. This means, for example, that you can't use pthread cancelation or signals to
+    // cause early return.
+    //
+    // Past timeout: it's possible for waitUntil() to be called with a timeout in the past. In that
+    // case, waitUntil() will still release the lock and reacquire it. waitUntil() will always return
+    // false in that case. This is subtly different from some pthread_cond_timedwait() implementations,
+    // which may not release the lock for past timeout. But, this behavior is consistent with OpenGroup
+    // documentation for timedwait().
     template<typename LockType>
-    bool waitUntil(
-        LockType& lock, std::chrono::steady_clock::time_point timeout)
+    bool waitUntil(LockType& lock, Clock::time_point timeout)
     {
-        bool result = ParkingLot::parkConditionally(
-            &m_dummy,
-            [] () -> bool { return true; },
-            [&lock] () { lock.unlock(); },
-            timeout);
+        bool result;
+        if (timeout < Clock::now()) {
+            lock.unlock();
+            result = false;
+        } else {
+            result = ParkingLot::parkConditionally(
+                &m_dummy,
+                [] () -> bool { return true; },
+                [&lock] () { lock.unlock(); },
+                timeout);
+        }
         lock.lock();
         return result;
     }
@@ -56,8 +76,7 @@ public:
     // Wait until the given predicate is satisfied. Returns true if it is satisfied in the end.
     // May return early due to timeout.
     template<typename LockType, typename Functor>
-    bool waitUntil(
-        LockType& lock, std::chrono::steady_clock::time_point timeout, const Functor& predicate)
+    bool waitUntil(LockType& lock, Clock::time_point timeout, const Functor& predicate)
     {
         while (!predicate()) {
             if (!waitUntil(lock, timeout))
@@ -72,17 +91,13 @@ public:
     bool waitFor(
         LockType& lock, const DurationType& relativeTimeout, const Functor& predicate)
     {
-        std::chrono::steady_clock::time_point absoluteTimeout =
-            std::chrono::steady_clock::now() +
-            std::chrono::duration_cast<std::chrono::steady_clock::duration>(relativeTimeout);
-
-        return waitUntil(lock, absoluteTimeout, predicate);
+        return waitUntil(lock, absoluteFromRelative(relativeTimeout), predicate);
     }
 
     template<typename LockType>
     void wait(LockType& lock)
     {
-        waitUntil(lock, std::chrono::steady_clock::time_point::max());
+        waitUntil(lock, Clock::time_point::max());
     }
 
     template<typename LockType, typename Functor>
@@ -92,6 +107,32 @@ public:
             wait(lock);
     }
 
+    template<typename LockType, typename TimeType>
+    bool waitUntil(LockType& lock, const TimeType& timeout)
+    {
+        if (timeout == TimeType::max()) {
+            wait(lock);
+            return true;
+        }
+        return waitForImpl(lock, timeout - TimeType::clock::now());
+    }
+
+    template<typename LockType>
+    bool waitUntilWallClockSeconds(LockType& lock, double absoluteTimeoutSeconds)
+    {
+        return waitForSecondsImpl(lock, absoluteTimeoutSeconds - currentTime());
+    }
+
+    template<typename LockType>
+    bool waitUntilMonotonicClockSeconds(LockType& lock, double absoluteTimeoutSeconds)
+    {
+        return waitForSecondsImpl(lock, absoluteTimeoutSeconds - monotonicallyIncreasingTime());
+    }
+
+    // FIXME: We could replace the dummy byte with a boolean to tell us if there is anyone waiting
+    // right now. This could be used to implement a fast path for notifyOne() and notifyAll().
+    // https://bugs.webkit.org/show_bug.cgi?id=148090
+
     void notifyOne()
     {
         ParkingLot::unparkOne(&m_dummy);
@@ -103,7 +144,56 @@ public:
     }
     
 private:
+    template<typename LockType>
+    bool waitForSecondsImpl(LockType& lock, double relativeTimeoutSeconds)
+    {
+        double relativeTimeoutNanoseconds = relativeTimeoutSeconds * (1000.0 * 1000.0 * 1000.0);
+        
+        if (!(relativeTimeoutNanoseconds > 0)) {
+            // This handles insta-timeouts as well as NaN.
+            lock.unlock();
+            lock.lock();
+            return false;
+        }
+
+        if (relativeTimeoutNanoseconds > static_cast<double>(std::numeric_limits<int64_t>::max())) {
+            // If the timeout in nanoseconds cannot be expressed using a 64-bit integer, then we
+            // might as well wait forever.
+            wait(lock);
+            return true;
+        }
+        
+        auto relativeTimeout =
+            std::chrono::nanoseconds(static_cast<int64_t>(relativeTimeoutNanoseconds));
+
+        return waitForImpl(lock, relativeTimeout);
+    }
     
+    template<typename LockType, typename DurationType>
+    bool waitForImpl(LockType& lock, const DurationType& relativeTimeout)
+    {
+        return waitUntil(lock, absoluteFromRelative(relativeTimeout));
+    }
+
+    template<typename DurationType>
+    Clock::time_point absoluteFromRelative(const DurationType& relativeTimeout)
+    {
+        if (relativeTimeout < DurationType::zero())
+            return Clock::time_point::min();
+
+        if (relativeTimeout > Clock::duration::max()) {
+            // This is highly unlikely. But if it happens, we want to not do anything dumb. Sleeping
+            // without a timeout seems sensible when the timeout duration is greater than what can be
+            // expressed using steady_clock.
+            return Clock::time_point::max();
+        }
+        
+        Clock::duration myRelativeTimeout =
+            std::chrono::duration_cast<Clock::duration>(relativeTimeout);
+
+        return Clock::now() + myRelativeTimeout;
+    }
+
     uint8_t m_dummy;
 };
 
index 1a33d4c..680c893 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2015 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,9 @@
 
 #include <limits>
 #include <wtf/Assertions.h>
+#include <wtf/Condition.h>
 #include <wtf/Deque.h>
+#include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Threading.h>
 
@@ -77,8 +79,8 @@ namespace WTF {
         static double infiniteTime() { return std::numeric_limits<double>::max(); }
 
     private:
-        mutable Mutex m_mutex;
-        ThreadCondition m_condition;
+        mutable Lock m_mutex;
+        Condition m_condition;
         Deque<std::unique_ptr<DataType>> m_queue;
         bool m_killed;
     };
@@ -91,37 +93,37 @@ namespace WTF {
     template<typename DataType>
     inline void MessageQueue<DataType>::append(std::unique_ptr<DataType> message)
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         m_queue.append(WTF::move(message));
-        m_condition.signal();
+        m_condition.notifyOne();
     }
 
     template<typename DataType>
     inline void MessageQueue<DataType>::appendAndKill(std::unique_ptr<DataType> message)
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         m_queue.append(WTF::move(message));
         m_killed = true;
-        m_condition.broadcast();
+        m_condition.notifyAll();
     }
 
     // Returns true if the queue was empty before the item was added.
     template<typename DataType>
     inline bool MessageQueue<DataType>::appendAndCheckEmpty(std::unique_ptr<DataType> message)
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         bool wasEmpty = m_queue.isEmpty();
         m_queue.append(WTF::move(message));
-        m_condition.signal();
+        m_condition.notifyOne();
         return wasEmpty;
     }
 
     template<typename DataType>
     inline void MessageQueue<DataType>::prepend(std::unique_ptr<DataType> message)
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         m_queue.prepend(WTF::move(message));
-        m_condition.signal();
+        m_condition.notifyOne();
     }
 
     template<typename DataType>
@@ -137,7 +139,7 @@ namespace WTF {
     template<typename Predicate>
     inline auto MessageQueue<DataType>::waitForMessageFilteredWithTimeout(MessageQueueWaitResult& result, Predicate&& predicate, double absoluteTime) -> std::unique_ptr<DataType>
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         bool timedOut = false;
 
         auto found = m_queue.end();
@@ -149,7 +151,7 @@ namespace WTF {
             if (found != m_queue.end())
                 break;
 
-            timedOut = !m_condition.timedWait(m_mutex, absoluteTime);
+            timedOut = !m_condition.waitUntilWallClockSeconds(m_mutex, absoluteTime);
         }
 
         ASSERT(!timedOut || absoluteTime != infiniteTime());
@@ -174,7 +176,7 @@ namespace WTF {
     template<typename DataType>
     inline auto MessageQueue<DataType>::tryGetMessage() -> std::unique_ptr<DataType>
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         if (m_killed)
             return nullptr;
         if (m_queue.isEmpty())
@@ -186,7 +188,7 @@ namespace WTF {
     template<typename DataType>
     inline auto MessageQueue<DataType>::tryGetMessageIgnoringKilled() -> std::unique_ptr<DataType>
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         if (m_queue.isEmpty())
             return nullptr;
 
@@ -197,7 +199,7 @@ namespace WTF {
     template<typename Predicate>
     inline void MessageQueue<DataType>::removeIf(Predicate&& predicate)
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         while (true) {
             auto found = m_queue.findIf([&predicate](const std::unique_ptr<DataType>& ptr) -> bool {
                 ASSERT(ptr);
@@ -214,7 +216,7 @@ namespace WTF {
     template<typename DataType>
     inline bool MessageQueue<DataType>::isEmpty()
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         if (m_killed)
             return true;
         return m_queue.isEmpty();
@@ -223,15 +225,15 @@ namespace WTF {
     template<typename DataType>
     inline void MessageQueue<DataType>::kill()
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         m_killed = true;
-        m_condition.broadcast();
+        m_condition.notifyAll();
     }
 
     template<typename DataType>
     inline bool MessageQueue<DataType>::killed() const
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         return m_killed;
     }
 } // namespace WTF
index 2cc0bc6..4023f43 100644 (file)
@@ -105,17 +105,17 @@ bool ParallelEnvironment::ThreadPrivate::tryLockFor(ParallelEnvironment* parent)
 
 void ParallelEnvironment::ThreadPrivate::execute(ThreadFunction threadFunction, void* parameters)
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
 
     m_threadFunction = threadFunction;
     m_parameters = parameters;
     m_running = true;
-    m_threadCondition.signal();
+    m_threadCondition.notifyOne();
 }
 
 void ParallelEnvironment::ThreadPrivate::waitForFinish()
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
 
     while (m_running)
         m_threadCondition.wait(m_mutex);
@@ -124,14 +124,14 @@ void ParallelEnvironment::ThreadPrivate::waitForFinish()
 void ParallelEnvironment::ThreadPrivate::workerThread(void* threadData)
 {
     ThreadPrivate* sharedThread = reinterpret_cast<ThreadPrivate*>(threadData);
-    MutexLocker lock(sharedThread->m_mutex);
+    LockHolder lock(sharedThread->m_mutex);
 
     while (sharedThread->m_threadID) {
         if (sharedThread->m_running) {
             (*sharedThread->m_threadFunction)(sharedThread->m_parameters);
             sharedThread->m_running = false;
             sharedThread->m_parent = 0;
-            sharedThread->m_threadCondition.signal();
+            sharedThread->m_threadCondition.notifyOne();
         }
 
         sharedThread->m_threadCondition.wait(sharedThread->m_mutex);
index 731b960..3e2e29d 100644 (file)
@@ -30,6 +30,8 @@
 
 #if ENABLE(THREADING_GENERIC)
 
+#include <wtf/Condition.h>
+#include <wtf/Lock.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Threading.h>
 
@@ -76,8 +78,8 @@ public:
         bool m_running;
         ParallelEnvironment* m_parent;
 
-        mutable Mutex m_mutex;
-        ThreadCondition m_threadCondition;
+        mutable Lock m_mutex;
+        Condition m_threadCondition;
 
         ThreadFunction m_threadFunction;
         void* m_parameters;
index b4d9f5a..1bcb252 100644 (file)
@@ -511,7 +511,7 @@ bool ParkingLot::parkConditionally(
     const void* address,
     std::function<bool()> validation,
     std::function<void()> beforeSleep,
-    std::chrono::steady_clock::time_point timeout)
+    Clock::time_point timeout)
 {
     if (verbose)
         dataLog(toString(currentThread(), ": parking.\n"));
@@ -539,11 +539,11 @@ bool ParkingLot::parkConditionally(
     bool didGetDequeued;
     {
         std::unique_lock<std::mutex> locker(me->parkingLock);
-        while (me->address && std::chrono::steady_clock::now() < timeout) {
+        while (me->address && Clock::now() < timeout) {
             // This is pretty funny. On Linux, if you wait until the max time, it immediately reports that you timed
             // out. What's particularly bad about this is that it never releases the lock in that case. So, you loop
             // forever without yielding to the thread that would wake you up.
-            if (timeout == std::chrono::steady_clock::time_point::max())
+            if (timeout == Clock::time_point::max())
                 me->parkingCondition.wait(locker);
             else
                 me->parkingCondition.wait_until(locker, timeout);
index 383653e..747c116 100644 (file)
@@ -38,6 +38,8 @@ class ParkingLot {
     ParkingLot(const ParkingLot&) = delete;
 
 public:
+    typedef std::chrono::steady_clock Clock;
+    
     // Parks the thread in a queue associated with the given address, which cannot be null. The
     // parking only succeeds if the validation function returns true while the queue lock is held.
     // If validation returns false, it will unlock the internal parking queue and then it will
@@ -53,7 +55,7 @@ public:
         const void* address,
         std::function<bool()> validation,
         std::function<void()> beforeSleep,
-        std::chrono::steady_clock::time_point timeout);
+        Clock::time_point timeout);
 
     // Simple version of parkConditionally() that covers the most common case: you want to park
     // indefinitely so long as the value at the given address hasn't changed.
@@ -67,7 +69,7 @@ public:
                 return value == expected;
             },
             [] () { },
-            std::chrono::steady_clock::time_point::max());
+            Clock::time_point::max());
     }
 
     // Unparks one thread from the queue associated with the given address, which cannot be null.
@@ -103,7 +105,7 @@ public:
     // A1,T1 A2,T3 A1,T2 A2,T4
     // A1,T1 A2,T3 A2,T4 A1,T2
     //
-    // As well as many other possible interleaves that all have T1 before T2 and T3 before T4 but are
+    // As well as many other possible interleavings that all have T1 before T2 and T3 before T4 but are
     // otherwise unconstrained. This method is useful primarily for debugging. It's also used by unit
     // tests.
     WTF_EXPORT_PRIVATE static void forEach(std::function<void(ThreadIdentifier, const void*)>);
index 92e20e4..9a625ba 100644 (file)
@@ -126,7 +126,6 @@ void initializeThreading()
     ThreadIdentifierData::initializeOnce();
     StackStats::initialize();
     wtfThreadData();
-    s_dtoaP5Mutex = new Mutex;
     initializeDates();
 }
 
index ab40087..280a6d8 100644 (file)
@@ -165,7 +165,6 @@ void initializeThreading()
     threadMapMutex();
     initializeRandomNumberGenerator();
     wtfThreadData();
-    s_dtoaP5Mutex = new Mutex;
     initializeDates();
 }
 
index 48de25b..823b161 100644 (file)
@@ -3,7 +3,7 @@
  * The author of this software is David M. Gay.
  *
  * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
- * Copyright (C) 2002, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2002, 2005, 2006, 2007, 2008, 2010, 2012, 2015 Apple Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose without fee is hereby granted, provided that this entire notice
@@ -36,6 +36,7 @@
 #include "dtoa.h"
 
 #include <stdio.h>
+#include <wtf/Lock.h>
 #include <wtf/MathExtras.h>
 #include <wtf/Threading.h>
 #include <wtf/Vector.h>
@@ -54,7 +55,7 @@
 
 namespace WTF {
 
-Mutex* s_dtoaP5Mutex;
+static StaticLock s_dtoaP5Mutex;
 
 typedef union {
     double d;
@@ -375,7 +376,7 @@ static ALWAYS_INLINE void pow5mult(BigInt& b, int k)
     if (!(k >>= 2))
         return;
 
-    s_dtoaP5Mutex->lock();
+    s_dtoaP5Mutex.lock();
     P5Node* p5 = p5s;
 
     if (!p5) {
@@ -388,7 +389,7 @@ static ALWAYS_INLINE void pow5mult(BigInt& b, int k)
     }
 
     int p5sCountLocal = p5sCount;
-    s_dtoaP5Mutex->unlock();
+    s_dtoaP5Mutex.unlock();
     int p5sUsed = 0;
 
     for (;;) {
@@ -399,7 +400,7 @@ static ALWAYS_INLINE void pow5mult(BigInt& b, int k)
             break;
 
         if (++p5sUsed == p5sCountLocal) {
-            s_dtoaP5Mutex->lock();
+            s_dtoaP5Mutex.lock();
             if (p5sUsed == p5sCount) {
                 ASSERT(!p5->next);
                 p5->next = new P5Node;
@@ -410,7 +411,7 @@ static ALWAYS_INLINE void pow5mult(BigInt& b, int k)
             }
 
             p5sCountLocal = p5sCount;
-            s_dtoaP5Mutex->unlock();
+            s_dtoaP5Mutex.unlock();
         }
         p5 = p5->next;
     }
index fab840e..3c5b5b9 100644 (file)
 
 namespace WTF {
 
-class Mutex;
-
-extern Mutex* s_dtoaP5Mutex;
-
 typedef char DtoaBuffer[80];
 
 WTF_EXPORT_PRIVATE void dtoa(DtoaBuffer result, double dd, bool& sign, int& exponent, unsigned& precision);
index f204531..fa97386 100644 (file)
@@ -1,3 +1,274 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        No new tests because no new behavior.
+
+        * Modules/webaudio/AsyncAudioDecoder.cpp:
+        (WebCore::AsyncAudioDecoder::AsyncAudioDecoder):
+        (WebCore::AsyncAudioDecoder::runLoop):
+        * Modules/webaudio/AsyncAudioDecoder.h:
+        * Modules/webaudio/AudioContext.h:
+        * Modules/webaudio/MediaStreamAudioSource.cpp:
+        (WebCore::MediaStreamAudioSource::addAudioConsumer):
+        (WebCore::MediaStreamAudioSource::removeAudioConsumer):
+        (WebCore::MediaStreamAudioSource::setAudioFormat):
+        (WebCore::MediaStreamAudioSource::consumeAudio):
+        * Modules/webaudio/MediaStreamAudioSource.h:
+        * Modules/webdatabase/Database.cpp:
+        (WebCore::Database::close):
+        (WebCore::Database::runTransaction):
+        (WebCore::Database::inProgressTransactionCompleted):
+        (WebCore::Database::hasPendingTransaction):
+        * Modules/webdatabase/Database.h:
+        * Modules/webdatabase/DatabaseTask.cpp:
+        (WebCore::DatabaseTaskSynchronizer::taskCompleted):
+        * Modules/webdatabase/DatabaseTask.h:
+        * Modules/webdatabase/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::start):
+        (WebCore::DatabaseThread::databaseThread):
+        * Modules/webdatabase/DatabaseThread.h:
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::setDatabaseDirectoryPath):
+        (WebCore::DatabaseTracker::canEstablishDatabase):
+        (WebCore::DatabaseTracker::retryCanEstablishDatabase):
+        (WebCore::DatabaseTracker::hasEntryForOrigin):
+        (WebCore::DatabaseTracker::getMaxSizeForDatabase):
+        (WebCore::DatabaseTracker::closeAllDatabases):
+        (WebCore::DatabaseTracker::fullPathForDatabase):
+        (WebCore::DatabaseTracker::origins):
+        (WebCore::DatabaseTracker::databaseNamesForOrigin):
+        (WebCore::DatabaseTracker::detailsForNameAndOrigin):
+        (WebCore::DatabaseTracker::setDatabaseDetails):
+        (WebCore::DatabaseTracker::doneCreatingDatabase):
+        (WebCore::DatabaseTracker::addOpenDatabase):
+        (WebCore::DatabaseTracker::removeOpenDatabase):
+        (WebCore::DatabaseTracker::getOpenDatabases):
+        (WebCore::DatabaseTracker::originLockFor):
+        (WebCore::DatabaseTracker::quotaForOrigin):
+        (WebCore::DatabaseTracker::setQuota):
+        (WebCore::DatabaseTracker::deleteOrigin):
+        (WebCore::DatabaseTracker::deleteDatabase):
+        (WebCore::DatabaseTracker::deleteDatabaseFile):
+        (WebCore::DatabaseTracker::removeDeletedOpenedDatabases):
+        (WebCore::DatabaseTracker::deleteDatabaseFileIfEmpty):
+        (WebCore::DatabaseTracker::openDatabaseMutex):
+        (WebCore::DatabaseTracker::setClient):
+        (WebCore::notificationMutex):
+        (WebCore::DatabaseTracker::scheduleNotifyDatabaseChanged):
+        (WebCore::DatabaseTracker::notifyDatabasesChanged):
+        * Modules/webdatabase/DatabaseTracker.h:
+        * Modules/webdatabase/OriginLock.h:
+        * Modules/webdatabase/SQLCallbackWrapper.h:
+        (WebCore::SQLCallbackWrapper::clear):
+        (WebCore::SQLCallbackWrapper::unwrap):
+        (WebCore::SQLCallbackWrapper::hasCallback):
+        * Modules/webdatabase/SQLTransactionBackend.cpp:
+        (WebCore::SQLTransactionBackend::doCleanup):
+        (WebCore::SQLTransactionBackend::enqueueStatementBackend):
+        (WebCore::SQLTransactionBackend::getNextStatement):
+        * Modules/webdatabase/SQLTransactionBackend.h:
+        * bindings/js/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::scheduleExecutionTermination):
+        (WebCore::WorkerScriptController::isExecutionTerminating):
+        * bindings/js/WorkerScriptController.h:
+        * dom/default/PlatformMessagePortChannel.cpp:
+        (WebCore::MessagePortChannel::postMessageToRemote):
+        (WebCore::MessagePortChannel::tryGetMessageFromRemote):
+        (WebCore::MessagePortChannel::isConnectedTo):
+        (WebCore::MessagePortChannel::hasPendingActivity):
+        (WebCore::MessagePortChannel::locallyEntangledPort):
+        (WebCore::PlatformMessagePortChannel::setRemotePort):
+        (WebCore::PlatformMessagePortChannel::entangledChannel):
+        (WebCore::PlatformMessagePortChannel::closeInternal):
+        * dom/default/PlatformMessagePortChannel.h:
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::IconDatabase::removeAllIcons):
+        (WebCore::IconDatabase::synchronousIconForPageURL):
+        (WebCore::IconDatabase::synchronousNativeIconForPageURL):
+        (WebCore::IconDatabase::synchronousIconURLForPageURL):
+        (WebCore::IconDatabase::retainIconForPageURL):
+        (WebCore::IconDatabase::performRetainIconForPageURL):
+        (WebCore::IconDatabase::releaseIconForPageURL):
+        (WebCore::IconDatabase::performReleaseIconForPageURL):
+        (WebCore::IconDatabase::setIconDataForIconURL):
+        (WebCore::IconDatabase::setIconURLForPageURL):
+        (WebCore::IconDatabase::synchronousLoadDecisionForIconURL):
+        (WebCore::IconDatabase::synchronousIconDataKnownForIconURL):
+        (WebCore::IconDatabase::pageURLMappingCount):
+        (WebCore::IconDatabase::retainedPageURLCount):
+        (WebCore::IconDatabase::iconRecordCount):
+        (WebCore::IconDatabase::iconRecordCountWithData):
+        (WebCore::IconDatabase::wakeSyncThread):
+        (WebCore::IconDatabase::scheduleOrDeferSyncTimer):
+        (WebCore::IconDatabase::isOpenBesidesMainThreadCallbacks):
+        (WebCore::IconDatabase::databasePath):
+        (WebCore::IconDatabase::getOrCreatePageURLRecord):
+        (WebCore::IconDatabase::iconDatabaseSyncThread):
+        (WebCore::IconDatabase::performOpenInitialization):
+        (WebCore::IconDatabase::performURLImport):
+        (WebCore::IconDatabase::syncThreadMainLoop):
+        (WebCore::IconDatabase::performPendingRetainAndReleaseOperations):
+        (WebCore::IconDatabase::readFromDatabase):
+        (WebCore::IconDatabase::writeToDatabase):
+        (WebCore::IconDatabase::pruneUnretainedIcons):
+        (WebCore::IconDatabase::cleanupSyncThread):
+        * loader/icon/IconDatabase.h:
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
+        (WebCore::ScrollingTree::commitNewTreeState):
+        (WebCore::ScrollingTree::setMainFramePinState):
+        (WebCore::ScrollingTree::mainFrameScrollPosition):
+        (WebCore::ScrollingTree::setMainFrameScrollPosition):
+        (WebCore::ScrollingTree::isPointInNonFastScrollableRegion):
+        (WebCore::ScrollingTree::isRubberBandInProgress):
+        (WebCore::ScrollingTree::setMainFrameIsRubberBanding):
+        (WebCore::ScrollingTree::isScrollSnapInProgress):
+        (WebCore::ScrollingTree::setMainFrameIsScrollSnapping):
+        (WebCore::ScrollingTree::setCanRubberBandState):
+        (WebCore::ScrollingTree::rubberBandsAtLeft):
+        (WebCore::ScrollingTree::rubberBandsAtRight):
+        (WebCore::ScrollingTree::rubberBandsAtBottom):
+        (WebCore::ScrollingTree::rubberBandsAtTop):
+        (WebCore::ScrollingTree::setScrollPinningBehavior):
+        (WebCore::ScrollingTree::scrollPinningBehavior):
+        (WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
+        (WebCore::ScrollingTree::latchedNode):
+        (WebCore::ScrollingTree::setLatchedNode):
+        (WebCore::ScrollingTree::clearLatchedNode):
+        * page/scrolling/ScrollingTree.h:
+        * platform/MemoryPressureHandler.h:
+        * platform/audio/HRTFDatabaseLoader.cpp:
+        (WebCore::HRTFDatabaseLoader::loadAsynchronously):
+        (WebCore::HRTFDatabaseLoader::waitForLoaderThreadCompletion):
+        * platform/audio/HRTFDatabaseLoader.h:
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::setReceivedMemoryPressure):
+        (WebCore::MemoryPressureHandler::clearMemoryPressure):
+        (WebCore::MemoryPressureHandler::shouldWaitForMemoryClearMessage):
+        (WebCore::MemoryPressureHandler::respondToMemoryPressureIfNeeded):
+        * platform/graphics/DisplayRefreshMonitor.cpp:
+        (WebCore::DisplayRefreshMonitor::displayDidRefresh):
+        * platform/graphics/DisplayRefreshMonitor.h:
+        (WebCore::DisplayRefreshMonitor::setMonotonicAnimationStartTime):
+        (WebCore::DisplayRefreshMonitor::mutex):
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::setDelayCallbacks):
+        (WebCore::MediaPlayerPrivateAVFoundation::clearMainThreadPendingFlag):
+        (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification):
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::AVFWrapper::callbackContext):
+        (WebCore::AVFWrapper::~AVFWrapper):
+        (WebCore::AVFWrapper::mapLock):
+        (WebCore::AVFWrapper::addToMap):
+        (WebCore::AVFWrapper::removeFromMap):
+        (WebCore::AVFWrapper::periodicTimeObserverCallback):
+        (WebCore::AVFWrapper::processNotification):
+        (WebCore::AVFWrapper::loadPlayableCompletionCallback):
+        (WebCore::AVFWrapper::loadMetadataCompletionCallback):
+        (WebCore::AVFWrapper::seekCompletedCallback):
+        (WebCore::AVFWrapper::processCue):
+        (WebCore::AVFWrapper::legibleOutputCallback):
+        (WebCore::AVFWrapper::processShouldWaitForLoadingOfResource):
+        (WebCore::AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource):
+        * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
+        (WebCore::InbandTextTrackPrivateGStreamer::handleSample):
+        (WebCore::InbandTextTrackPrivateGStreamer::notifyTrackOfSample):
+        * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h:
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
+        (WebCore::TrackPrivateBaseGStreamer::tagsChanged):
+        (WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged):
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
+        * platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
+        (WebCore::DisplayRefreshMonitorMac::requestRefreshCallback):
+        (WebCore::DisplayRefreshMonitorMac::displayLinkFired):
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
+        (WebCore::MediaPlayerPrivateMediaFoundation::addListener):
+        (WebCore::MediaPlayerPrivateMediaFoundation::removeListener):
+        (WebCore::MediaPlayerPrivateMediaFoundation::notifyDeleted):
+        (WebCore::MediaPlayerPrivateMediaFoundation::AsyncCallback::Invoke):
+        (WebCore::MediaPlayerPrivateMediaFoundation::AsyncCallback::onMediaPlayerDeleted):
+        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
+        * platform/ios/LegacyTileCache.h:
+        * platform/ios/LegacyTileCache.mm:
+        (WebCore::LegacyTileCache::setTilesOpaque):
+        (WebCore::LegacyTileCache::doLayoutTiles):
+        (WebCore::LegacyTileCache::setCurrentScale):
+        (WebCore::LegacyTileCache::commitScaleChange):
+        (WebCore::LegacyTileCache::layoutTilesNow):
+        (WebCore::LegacyTileCache::layoutTilesNowForRect):
+        (WebCore::LegacyTileCache::removeAllNonVisibleTiles):
+        (WebCore::LegacyTileCache::removeAllTiles):
+        (WebCore::LegacyTileCache::removeForegroundTiles):
+        (WebCore::LegacyTileCache::setContentReplacementImage):
+        (WebCore::LegacyTileCache::contentReplacementImage):
+        (WebCore::LegacyTileCache::tileCreationTimerFired):
+        (WebCore::LegacyTileCache::setNeedsDisplayInRect):
+        (WebCore::LegacyTileCache::updateTilingMode):
+        (WebCore::LegacyTileCache::setTilingMode):
+        (WebCore::LegacyTileCache::doPendingRepaints):
+        (WebCore::LegacyTileCache::flushSavedDisplayRects):
+        (WebCore::LegacyTileCache::prepareToDraw):
+        * platform/ios/LegacyTileLayerPool.h:
+        * platform/ios/LegacyTileLayerPool.mm:
+        (WebCore::LegacyTileLayerPool::addLayer):
+        (WebCore::LegacyTileLayerPool::takeLayerWithSize):
+        (WebCore::LegacyTileLayerPool::setCapacity):
+        (WebCore::LegacyTileLayerPool::prune):
+        (WebCore::LegacyTileLayerPool::drain):
+        * platform/network/curl/CurlDownload.cpp:
+        (WebCore::CurlDownloadManager::add):
+        (WebCore::CurlDownloadManager::remove):
+        (WebCore::CurlDownloadManager::getActiveDownloadCount):
+        (WebCore::CurlDownloadManager::getPendingDownloadCount):
+        (WebCore::CurlDownloadManager::stopThreadIfIdle):
+        (WebCore::CurlDownloadManager::updateHandleList):
+        (WebCore::CurlDownload::~CurlDownload):
+        (WebCore::CurlDownload::init):
+        (WebCore::CurlDownload::getTempPath):
+        (WebCore::CurlDownload::getUrl):
+        (WebCore::CurlDownload::getResponse):
+        (WebCore::CurlDownload::closeFile):
+        (WebCore::CurlDownload::didReceiveHeader):
+        (WebCore::CurlDownload::didReceiveData):
+        (WebCore::CurlDownload::didFail):
+        * platform/network/curl/CurlDownload.h:
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::cookieJarPath):
+        (WebCore::sharedResourceMutex):
+        (WebCore::curl_lock_callback):
+        (WebCore::curl_unlock_callback):
+        * platform/network/ios/QuickLook.mm:
+        (WebCore::QLDirectoryAttributes):
+        (qlPreviewConverterDictionaryMutex):
+        (WebCore::addQLPreviewConverterWithFileForURL):
+        (WebCore::qlPreviewConverterUTIForURL):
+        (WebCore::removeQLPreviewConverterForURL):
+        (WebCore::safeQLURLForDocumentURLAndResourceURL):
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::SQLiteDatabase::close):
+        (WebCore::SQLiteDatabase::maximumSize):
+        (WebCore::SQLiteDatabase::setMaximumSize):
+        (WebCore::SQLiteDatabase::pageSize):
+        (WebCore::SQLiteDatabase::freeSpaceSize):
+        (WebCore::SQLiteDatabase::totalSize):
+        (WebCore::SQLiteDatabase::runIncrementalVacuumCommand):
+        (WebCore::SQLiteDatabase::setAuthorizer):
+        * platform/sql/SQLiteDatabase.h:
+        (WebCore::SQLiteDatabase::databaseMutex):
+        * platform/sql/SQLiteStatement.cpp:
+        (WebCore::SQLiteStatement::prepare):
+        (WebCore::SQLiteStatement::step):
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThread::start):
+        (WebCore::WorkerThread::workerThread):
+        (WebCore::WorkerThread::stop):
+        * workers/WorkerThread.h:
+
 2015-08-18  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Cocoa] Honor the 'trak' table by opting in via text-rendering: optimizeLegibility
index b467d18..7dc6415 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 AsyncAudioDecoder::AsyncAudioDecoder()
 {
     // Start worker thread.
-    MutexLocker lock(m_threadCreationMutex);
+    LockHolder lock(m_threadCreationMutex);
     m_threadID = createThread(AsyncAudioDecoder::threadEntry, this, "Audio Decoder");
 }
 
@@ -76,7 +76,7 @@ void AsyncAudioDecoder::runLoop()
 
     {
         // Wait for until we have m_threadID established before starting the run loop.
-        MutexLocker lock(m_threadCreationMutex);
+        LockHolder lock(m_threadCreationMutex);
     }
 
     // Keep running decoding tasks until we're killed.
index 5e40cd2..8015b46 100644 (file)
@@ -81,7 +81,7 @@ private:
     void runLoop();
 
     WTF::ThreadIdentifier m_threadID;
-    Mutex m_threadCreationMutex;
+    Lock m_threadCreationMutex;
     MessageQueue<DecodingTask> m_queue;
 };
 
index f7d56e9..56d1b78 100644 (file)
@@ -380,7 +380,7 @@ private:
     unsigned m_connectionCount { 0 };
 
     // Graph locking.
-    Mutex m_contextGraphMutex;
+    Lock m_contextGraphMutex;
     volatile ThreadIdentifier m_audioThread { 0 };
     volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then this is the thread which owns it, otherwise == UndefinedThreadIdentifier
 
index b6e26e7..9a0297a 100644 (file)
@@ -63,13 +63,13 @@ const RealtimeMediaSourceStates& MediaStreamAudioSource::states()
 
 void MediaStreamAudioSource::addAudioConsumer(PassRefPtr<AudioDestinationConsumer> consumer)
 {
-    MutexLocker locker(m_audioConsumersLock);
+    LockHolder locker(m_audioConsumersLock);
     m_audioConsumers.append(consumer);
 }
 
 bool MediaStreamAudioSource::removeAudioConsumer(AudioDestinationConsumer* consumer)
 {
-    MutexLocker locker(m_audioConsumersLock);
+    LockHolder locker(m_audioConsumersLock);
     size_t pos = m_audioConsumers.find(consumer);
     if (pos != notFound) {
         m_audioConsumers.remove(pos);
@@ -80,14 +80,14 @@ bool MediaStreamAudioSource::removeAudioConsumer(AudioDestinationConsumer* consu
 
 void MediaStreamAudioSource::setAudioFormat(size_t numberOfChannels, float sampleRate)
 {
-    MutexLocker locker(m_audioConsumersLock);
+    LockHolder locker(m_audioConsumersLock);
     for (auto& consumer : m_audioConsumers)
         consumer->setFormat(numberOfChannels, sampleRate);
 }
 
 void MediaStreamAudioSource::consumeAudio(AudioBus* bus, size_t numberOfFrames)
 {
-    MutexLocker locker(m_audioConsumersLock);
+    LockHolder locker(m_audioConsumersLock);
     for (auto& consumer : m_audioConsumers)
         consumer->consumeAudio(bus, numberOfFrames);
 }
index 418b32e..8e4d76a 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "AudioDestinationConsumer.h"
 #include "RealtimeMediaSource.h"
+#include <wtf/Lock.h>
 #include <wtf/RefCounted.h>
 #include <wtf/ThreadingPrimitives.h>
 #include <wtf/Vector.h>
@@ -65,7 +66,7 @@ private:
     MediaStreamAudioSource();
 
     String m_deviceId;
-    Mutex m_audioConsumersLock;
+    Lock m_audioConsumersLock;
     Vector<RefPtr<AudioDestinationConsumer>> m_audioConsumers;
     RealtimeMediaSourceStates m_currentStates;
 };
index bcefef3..3dfefc3 100644 (file)
@@ -294,7 +294,7 @@ void Database::close()
     ASSERT(currentThread() == databaseContext()->databaseThread()->getThreadID());
 
     {
-        MutexLocker locker(m_transactionInProgressMutex);
+        LockHolder locker(m_transactionInProgressMutex);
 
         // Clean up transactions that have not been scheduled yet:
         // Transaction phase 1 cleanup. See comment on "What happens if a
@@ -353,7 +353,7 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
 #if PLATFORM(IOS)
     {
         // Make sure we wait till the background removal of the empty database files finished before trying to open any database.
-        MutexLocker locker(DatabaseTracker::openDatabaseMutex());
+        LockHolder locker(DatabaseTracker::openDatabaseMutex());
     }
 #endif
 
@@ -565,7 +565,7 @@ void Database::scheduleTransaction()
 
 PassRefPtr<SQLTransactionBackend> Database::runTransaction(PassRefPtr<SQLTransaction> transaction, bool readOnly, const ChangeVersionData* data)
 {
-    MutexLocker locker(m_transactionInProgressMutex);
+    LockHolder locker(m_transactionInProgressMutex);
     if (!m_isTransactionQueueEnabled)
         return 0;
 
@@ -593,14 +593,14 @@ void Database::scheduleTransactionStep(SQLTransactionBackend* transaction)
 
 void Database::inProgressTransactionCompleted()
 {
-    MutexLocker locker(m_transactionInProgressMutex);
+    LockHolder locker(m_transactionInProgressMutex);
     m_transactionInProgress = false;
     scheduleTransaction();
 }
 
 bool Database::hasPendingTransaction()
 {
-    MutexLocker locker(m_transactionInProgressMutex);
+    LockHolder locker(m_transactionInProgressMutex);
     return m_transactionInProgress || !m_transactionQueue.isEmpty();
 }
 
index b22f8fc..3d466ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,6 +33,7 @@
 #include "DatabaseError.h"
 #include "SQLiteDatabase.h"
 #include <wtf/Deque.h>
+#include <wtf/Lock.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -162,7 +163,7 @@ private:
     RefPtr<DatabaseAuthorizer> m_databaseAuthorizer;
 
     Deque<RefPtr<SQLTransactionBackend>> m_transactionQueue;
-    Mutex m_transactionInProgressMutex;
+    Lock m_transactionInProgressMutex;
     bool m_transactionInProgress;
     bool m_isTransactionQueueEnabled;
 
index 91ae7e6..53fd8de 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,7 +53,7 @@ void DatabaseTaskSynchronizer::taskCompleted()
 {
     m_synchronousMutex.lock();
     m_taskCompleted = true;
-    m_synchronousCondition.signal();
+    m_synchronousCondition.notifyOne();
     m_synchronousMutex.unlock();
 }
 
index e61c20c..214bb46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,8 +31,9 @@
 #include "DatabaseBasicTypes.h"
 #include "DatabaseError.h"
 #include "SQLTransactionBackend.h"
+#include <wtf/Condition.h>
+#include <wtf/Lock.h>
 #include <wtf/PassRefPtr.h>
-#include <wtf/Threading.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -58,8 +59,8 @@ public:
 
 private:
     bool m_taskCompleted;
-    Mutex m_synchronousMutex;
-    ThreadCondition m_synchronousCondition;
+    Lock m_synchronousMutex;
+    Condition m_synchronousCondition;
 #ifndef NDEBUG
     bool m_hasCheckedForTermination;
 #endif
index 2d76ef5..4dd8f06 100644 (file)
@@ -61,7 +61,7 @@ DatabaseThread::~DatabaseThread()
 
 bool DatabaseThread::start()
 {
-    MutexLocker lock(m_threadCreationMutex);
+    LockHolder lock(m_threadCreationMutex);
 
     if (m_threadID)
         return true;
@@ -100,7 +100,7 @@ void DatabaseThread::databaseThread()
 {
     {
         // Wait for DatabaseThread::start() to complete.
-        MutexLocker lock(m_threadCreationMutex);
+        LockHolder lock(m_threadCreationMutex);
         LOG(StorageAPI, "Started DatabaseThread %p", this);
     }
 
index dedb5e0..8d9f350 100644 (file)
@@ -72,7 +72,7 @@ private:
     static void databaseThreadStart(void*);
     void databaseThread();
 
-    Mutex m_threadCreationMutex;
+    Lock m_threadCreationMutex;
     ThreadIdentifier m_threadID;
     RefPtr<DatabaseThread> m_selfRef;
 
index 739757d..007a4b4 100644 (file)
@@ -89,7 +89,7 @@ DatabaseTracker::DatabaseTracker(const String& databasePath)
 
 void DatabaseTracker::setDatabaseDirectoryPath(const String& path)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     ASSERT(!m_database.isOpen());
     m_databaseDirectoryPath = path.isolatedCopy();
 }
@@ -166,7 +166,7 @@ bool DatabaseTracker::canEstablishDatabase(DatabaseContext* context, const Strin
 {
     error = DatabaseError::None;
 
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     SecurityOrigin* origin = context->securityOrigin();
 
     if (isDeletingDatabaseOrOriginFor(origin, name)) {
@@ -218,7 +218,7 @@ bool DatabaseTracker::retryCanEstablishDatabase(DatabaseContext* context, const
 {
     error = DatabaseError::None;
 
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     SecurityOrigin* origin = context->securityOrigin();
 
     // We have already eliminated other types of errors in canEstablishDatabase().
@@ -257,7 +257,7 @@ bool DatabaseTracker::hasEntryForOriginNoLock(SecurityOrigin* origin)
 
 bool DatabaseTracker::hasEntryForOrigin(SecurityOrigin* origin)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     return hasEntryForOriginNoLock(origin);
 }
 
@@ -286,7 +286,7 @@ unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* databa
 {
     // The maximum size for a database is the full quota for its origin, minus the current usage within the origin,
     // plus the current usage of the given database
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     SecurityOrigin* origin = database->securityOrigin();
 
     unsigned long long quota = quotaForOriginNoLock(origin);
@@ -311,7 +311,7 @@ void DatabaseTracker::closeAllDatabases()
 {
     Vector<Ref<Database>> openDatabases;
     {
-        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
+        LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
         if (!m_openDatabaseMap)
             return;
         for (auto& nameMap : m_openDatabaseMap->values()) {
@@ -389,13 +389,13 @@ String DatabaseTracker::fullPathForDatabaseNoLock(SecurityOrigin* origin, const
 
 String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfNotExists)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     return fullPathForDatabaseNoLock(origin, name, createIfNotExists).isolatedCopy();
 }
 
 void DatabaseTracker::origins(Vector<RefPtr<SecurityOrigin>>& originsResult)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
 
     openTrackerDatabase(DontCreateIfDoesNotExist);
     if (!m_database.isOpen())
@@ -448,7 +448,7 @@ bool DatabaseTracker::databaseNamesForOrigin(SecurityOrigin* origin, Vector<Stri
 {
     Vector<String> temp;
     {
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         if (!databaseNamesForOriginNoLock(origin, temp))
           return false;
     }
@@ -465,7 +465,7 @@ DatabaseDetails DatabaseTracker::detailsForNameAndOrigin(const String& name, Sec
     int64_t expectedUsage;
 
     {
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
 
         openTrackerDatabase(DontCreateIfDoesNotExist);
         if (!m_database.isOpen())
@@ -500,7 +500,7 @@ void DatabaseTracker::setDatabaseDetails(SecurityOrigin* origin, const String& n
     String originIdentifier = origin->databaseIdentifier();
     int64_t guid = 0;
 
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
 
     openTrackerDatabase(CreateIfDoesNotExist);
     if (!m_database.isOpen())
@@ -549,7 +549,7 @@ void DatabaseTracker::setDatabaseDetails(SecurityOrigin* origin, const String& n
 
 void DatabaseTracker::doneCreatingDatabase(Database* database)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     doneCreatingDatabase(database->securityOrigin(), database->stringIdentifier());
 }
 
@@ -559,7 +559,7 @@ void DatabaseTracker::addOpenDatabase(Database* database)
         return;
 
     {
-        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
+        LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
 
         if (!m_openDatabaseMap)
             m_openDatabaseMap = std::make_unique<DatabaseOriginMap>();
@@ -589,7 +589,7 @@ void DatabaseTracker::removeOpenDatabase(Database* database)
         return;
 
     {
-        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
+        LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
 
         if (!m_openDatabaseMap) {
             ASSERT_NOT_REACHED();
@@ -629,7 +629,7 @@ void DatabaseTracker::removeOpenDatabase(Database* database)
 
 void DatabaseTracker::getOpenDatabases(SecurityOrigin* origin, const String& name, HashSet<RefPtr<Database>>* databases)
 {
-    MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
+    LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
     if (!m_openDatabaseMap)
         return;
 
@@ -647,7 +647,7 @@ void DatabaseTracker::getOpenDatabases(SecurityOrigin* origin, const String& nam
 
 RefPtr<OriginLock> DatabaseTracker::originLockFor(SecurityOrigin* origin)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     String databaseIdentifier = origin->databaseIdentifier();
 
     // The originLockMap is accessed from multiple DatabaseThreads since
@@ -727,13 +727,13 @@ unsigned long long DatabaseTracker::quotaForOriginNoLock(SecurityOrigin* origin)
 
 unsigned long long DatabaseTracker::quotaForOrigin(SecurityOrigin* origin)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
     return quotaForOriginNoLock(origin);
 }
 
 void DatabaseTracker::setQuota(SecurityOrigin* origin, unsigned long long quota)
 {
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
 
     if (quotaForOriginNoLock(origin) == quota)
         return;
@@ -864,7 +864,7 @@ bool DatabaseTracker::deleteOrigin(SecurityOrigin* origin)
 {
     Vector<String> databaseNames;
     {
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         openTrackerDatabase(DontCreateIfDoesNotExist);
         if (!m_database.isOpen())
             return false;
@@ -890,7 +890,7 @@ bool DatabaseTracker::deleteOrigin(SecurityOrigin* origin)
     }
 
     {
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         deleteOriginLockFor(origin);
         doneDeletingOrigin(origin);
 
@@ -1071,7 +1071,7 @@ void DatabaseTracker::doneDeletingOrigin(SecurityOrigin *origin)
 bool DatabaseTracker::deleteDatabase(SecurityOrigin* origin, const String& name)
 {
     {
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         openTrackerDatabase(DontCreateIfDoesNotExist);
         if (!m_database.isOpen())
             return false;
@@ -1086,12 +1086,12 @@ bool DatabaseTracker::deleteDatabase(SecurityOrigin* origin, const String& name)
     // We drop the lock here because holding locks during a call to deleteDatabaseFile will deadlock.
     if (!deleteDatabaseFile(origin, name)) {
         LOG_ERROR("Unable to delete file for database %s in origin %s", name.ascii().data(), origin->databaseIdentifier().ascii().data());
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         doneDeletingDatabase(origin, name);
         return false;
     }
 
-    MutexLocker lockDatabase(m_databaseGuard);
+    LockHolder lockDatabase(m_databaseGuard);
 
     SQLiteStatement statement(m_database, "DELETE FROM Databases WHERE origin=? AND name=?");
     if (statement.prepare() != SQLITE_OK) {
@@ -1131,7 +1131,7 @@ bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& n
 
 #ifndef NDEBUG
     {
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         ASSERT(isDeletingDatabaseOrOriginFor(origin, name));
     }
 #endif
@@ -1142,7 +1142,7 @@ bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& n
     // Database::markAsDeletedAndClose(), since that can cause a deadlock
     // during the synchronous DatabaseThread call it triggers.
     {
-        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
+        LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
         if (m_openDatabaseMap) {
             // There are some open databases, lets check if they are for this origin.
             DatabaseNameMap* nameMap = m_openDatabaseMap->get(origin);
@@ -1185,7 +1185,7 @@ void DatabaseTracker::removeDeletedOpenedDatabases()
     
     {
         // Acquire the lock before calling openTrackerDatabase.
-        MutexLocker lockDatabase(m_databaseGuard);
+        LockHolder lockDatabase(m_databaseGuard);
         openTrackerDatabase(DontCreateIfDoesNotExist);
     }
 
@@ -1201,7 +1201,7 @@ void DatabaseTracker::removeDeletedOpenedDatabases()
     // Database::markAsDeletedAndClose(), since that can cause a deadlock
     // during the synchronous DatabaseThread call it triggers.
     {
-        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
+        LockHolder openDatabaseMapLock(m_openDatabaseMapGuard);
         if (m_openDatabaseMap) {
             for (auto& openDatabase : *m_openDatabaseMap) {
                 auto& origin = openDatabase.key;
@@ -1305,9 +1305,9 @@ bool DatabaseTracker::deleteDatabaseFileIfEmpty(const String& path)
     return SQLiteFileSystem::deleteDatabaseFile(path);
 }
 
-Mutex& DatabaseTracker::openDatabaseMutex()
+Lock& DatabaseTracker::openDatabaseMutex()
 {
-    static NeverDestroyed<Mutex> mutex;
+    static NeverDestroyed<Lock> mutex;
     return mutex;
 }
 
@@ -1330,9 +1330,9 @@ void DatabaseTracker::setClient(DatabaseManagerClient* client)
     m_client = client;
 }
 
-static Mutex& notificationMutex()
+static Lock& notificationMutex()
 {
-    static NeverDestroyed<Mutex> mutex;
+    static NeverDestroyed<Lock> mutex;
     return mutex;
 }
 
@@ -1346,7 +1346,7 @@ static NotificationQueue& notificationQueue()
 
 void DatabaseTracker::scheduleNotifyDatabaseChanged(SecurityOrigin* origin, const String& name)
 {
-    MutexLocker locker(notificationMutex());
+    LockHolder locker(notificationMutex());
 
     notificationQueue().append(std::pair<RefPtr<SecurityOrigin>, String>(origin->isolatedCopy(), name.isolatedCopy()));
     scheduleForNotification();
@@ -1372,7 +1372,7 @@ void DatabaseTracker::notifyDatabasesChanged(void*)
 
     NotificationQueue notifications;
     {
-        MutexLocker locker(notificationMutex());
+        LockHolder locker(notificationMutex());
 
         notifications.swap(notificationQueue());
 
index 74067b9..8542fd0 100644 (file)
@@ -107,7 +107,7 @@ public:
     // MobileSafari will grab this mutex on the main thread before dispatching the task to 
     // clean up zero byte database files.  Any operations to open new database will have to
     // wait for that task to finish by waiting on this mutex.
-    static Mutex& openDatabaseMutex();
+    static Lock& openDatabaseMutex();
     
     WEBCORE_EXPORT static void emptyDatabaseFilesRemovalTaskWillBeScheduled();
     WEBCORE_EXPORT static void emptyDatabaseFilesRemovalTaskDidFinish();
@@ -150,11 +150,11 @@ private:
     typedef HashMap<String, DatabaseSet*> DatabaseNameMap;
     typedef HashMap<RefPtr<SecurityOrigin>, DatabaseNameMap*> DatabaseOriginMap;
 
-    Mutex m_openDatabaseMapGuard;
+    Lock m_openDatabaseMapGuard;
     mutable std::unique_ptr<DatabaseOriginMap> m_openDatabaseMap;
 
     // This lock protects m_database, m_originLockMap, m_databaseDirectoryPath, m_originsBeingDeleted, m_beingCreated, and m_beingDeleted.
-    Mutex m_databaseGuard;
+    Lock m_databaseGuard;
     SQLiteDatabase m_database;
 
     typedef HashMap<String, RefPtr<OriginLock>> OriginLockMap;
index 45c1557..a253781 100644 (file)
@@ -27,8 +27,8 @@
 #define OriginLock_h
 
 #include "FileSystem.h"
+#include <wtf/Lock.h>
 #include <wtf/ThreadSafeRefCounted.h>
-#include <wtf/ThreadingPrimitives.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -48,7 +48,7 @@ private:
     static String lockFileNameForPath(String originPath);
 
     String m_lockFileName;
-    Mutex m_mutex;
+    Lock m_mutex;
 #if USE(FILE_LOCK)
     PlatformFileHandle m_lockHandle;
 #endif
index ca22801..32dd06b 100644 (file)
@@ -29,7 +29,7 @@
 #define SQLCallbackWrapper_h
 
 #include "ScriptExecutionContext.h"
-#include <wtf/ThreadingPrimitives.h>
+#include <wtf/Lock.h>
 
 namespace WebCore {
 
@@ -58,7 +58,7 @@ public:
         ScriptExecutionContext* scriptExecutionContextPtr;
         T* callback;
         {
-            MutexLocker locker(m_mutex);
+            LockHolder locker(m_mutex);
             if (!m_callback) {
                 ASSERT(!m_scriptExecutionContext);
                 return;
@@ -83,7 +83,7 @@ public:
 
     PassRefPtr<T> unwrap()
     {
-        MutexLocker locker(m_mutex);
+        LockHolder locker(m_mutex);
         ASSERT(!m_callback || m_scriptExecutionContext->isContextThread());
         m_scriptExecutionContext = nullptr;
         return m_callback.release();
@@ -93,7 +93,7 @@ public:
     bool hasCallback() const { return m_callback; }
 
 private:
-    Mutex m_mutex;
+    Lock m_mutex;
     RefPtr<T> m_callback;
     RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
 };
index 7c5ade2..1efd7c9 100644 (file)
@@ -381,7 +381,7 @@ void SQLTransactionBackend::doCleanup()
 
     releaseOriginLockIfNeeded();
 
-    MutexLocker locker(m_statementMutex);
+    LockHolder locker(m_statementMutex);
     m_statementQueue.clear();
 
     if (m_sqliteTransaction) {
@@ -465,7 +465,7 @@ SQLTransactionBackend::StateFunction SQLTransactionBackend::stateFunctionFor(SQL
 
 void SQLTransactionBackend::enqueueStatementBackend(std::unique_ptr<SQLStatement> statementBackend)
 {
-    MutexLocker locker(m_statementMutex);
+    LockHolder locker(m_statementMutex);
     m_statementQueue.append(WTF::move(statementBackend));
 }
 
@@ -681,7 +681,7 @@ void SQLTransactionBackend::getNextStatement()
 {
     m_currentStatementBackend = nullptr;
 
-    MutexLocker locker(m_statementMutex);
+    LockHolder locker(m_statementMutex);
     if (!m_statementQueue.isEmpty())
         m_currentStatementBackend = m_statementQueue.takeFirst();
 }
index 8101c60..8300af6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,7 +33,7 @@
 #include <memory>
 #include <wtf/Deque.h>
 #include <wtf/Forward.h>
-#include <wtf/ThreadingPrimitives.h>
+#include <wtf/Lock.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -125,7 +125,7 @@ private:
     bool m_readOnly;
     bool m_hasVersionMismatch;
 
-    Mutex m_statementMutex;
+    Lock m_statementMutex;
     Deque<std::unique_ptr<SQLStatement>> m_statementQueue;
 
     std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
index c0e3687..5a98c80 100644 (file)
@@ -151,7 +151,7 @@ void WorkerScriptController::scheduleExecutionTermination()
     // The mutex provides a memory barrier to ensure that once
     // termination is scheduled, isExecutionTerminating will
     // accurately reflect that state when called from another thread.
-    MutexLocker locker(m_scheduledTerminationMutex);
+    LockHolder locker(m_scheduledTerminationMutex);
     if (m_vm->watchdog)
         m_vm->watchdog->fire();
 }
@@ -159,7 +159,7 @@ void WorkerScriptController::scheduleExecutionTermination()
 bool WorkerScriptController::isExecutionTerminating() const
 {
     // See comments in scheduleExecutionTermination regarding mutex usage.
-    MutexLocker locker(m_scheduledTerminationMutex);
+    LockHolder locker(m_scheduledTerminationMutex);
     if (m_vm->watchdog)
         return m_vm->watchdog->didFire();
     return false;
index d57aad6..5747043 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2015 Apple Inc. All Rights Reserved.
  * Copyright (C) 2012 Google Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
 #include <debugger/Debugger.h>
 #include <heap/Strong.h>
 #include <wtf/Forward.h>
+#include <wtf/Lock.h>
 #include <wtf/NakedPtr.h>
-#include <wtf/Threading.h>
 
 namespace Deprecated {
 class ScriptValue;
@@ -97,7 +97,7 @@ namespace WebCore {
         WorkerGlobalScope* m_workerGlobalScope;
         JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
         bool m_executionForbidden;
-        mutable Mutex m_scheduledTerminationMutex;
+        mutable Lock m_scheduledTerminationMutex;
     };
 
 } // namespace WebCore
index c417486..b5a682d 100644 (file)
@@ -88,7 +88,7 @@ void MessagePortChannel::disentangle()
 
 void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
 {
-    MutexLocker lock(m_channel->m_mutex);
+    LockHolder lock(m_channel->m_mutex);
     if (!m_channel->m_outgoingQueue)
         return;
     bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(std::make_unique<PlatformMessagePortChannel::EventData>(message, WTF::move(channels)));
@@ -98,7 +98,7 @@ void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> m
 
 bool MessagePortChannel::tryGetMessageFromRemote(RefPtr<SerializedScriptValue>& message, std::unique_ptr<MessagePortChannelArray>& channels)
 {
-    MutexLocker lock(m_channel->m_mutex);
+    LockHolder lock(m_channel->m_mutex);
     auto result = m_channel->m_incomingQueue->tryGetMessage();
     if (!result)
         return false;
@@ -121,20 +121,20 @@ void MessagePortChannel::close()
 bool MessagePortChannel::isConnectedTo(MessagePort* port)
 {
     // FIXME: What guarantees that the result remains the same after we release the lock?
-    MutexLocker lock(m_channel->m_mutex);
+    LockHolder lock(m_channel->m_mutex);
     return m_channel->m_remotePort == port;
 }
 
 bool MessagePortChannel::hasPendingActivity()
 {
     // FIXME: What guarantees that the result remains the same after we release the lock?
-    MutexLocker lock(m_channel->m_mutex);
+    LockHolder lock(m_channel->m_mutex);
     return !m_channel->m_incomingQueue->isEmpty();
 }
 
 MessagePort* MessagePortChannel::locallyEntangledPort(const ScriptExecutionContext* context)
 {
-    MutexLocker lock(m_channel->m_mutex);
+    LockHolder lock(m_channel->m_mutex);
     // See if both contexts are run by the same thread (are the same context, or are both documents).
     if (m_channel->m_remotePort) {
         // The remote port's ScriptExecutionContext is guaranteed not to change here - MessagePort::contextDestroyed()
@@ -164,7 +164,7 @@ PlatformMessagePortChannel::~PlatformMessagePortChannel()
 
 void PlatformMessagePortChannel::setRemotePort(MessagePort* port)
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     // Should never set port if it is already set.
     ASSERT(!port || !m_remotePort);
     m_remotePort = port;
@@ -175,13 +175,13 @@ PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::entangledChan
     // FIXME: What guarantees that the result remains the same after we release the lock?
     // This lock only guarantees that the returned pointer will not be pointing to released memory,
     // but not that it will still be pointing to this object's entangled port channel.
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     return m_entangledChannel;
 }
 
 void PlatformMessagePortChannel::closeInternal()
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     // Disentangle ourselves from the other end. We still maintain a reference to our incoming queue, since previously-existing messages should still be delivered.
     m_remotePort = nullptr;
     m_entangledChannel = nullptr;
index b703d12..0306539 100644 (file)
@@ -95,8 +95,8 @@ namespace WebCore {
         void setRemotePort(MessagePort*);
         void closeInternal();
 
-        // Mutex used to ensure exclusive access to the object internals.
-        Mutex m_mutex;
+        // Lock used to ensure exclusive access to the object internals.
+        Lock m_mutex;
 
         // Pointer to our entangled pair - cleared when close() is called.
         RefPtr<PlatformMessagePortChannel> m_entangledChannel;
index 64a7555..f9bc46e 100644 (file)
@@ -186,7 +186,7 @@ void IconDatabase::removeAllIcons()
     
     // Clear the in-memory record of every IconRecord, anything waiting to be read from disk, and anything waiting to be written to disk
     {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
         
         // Clear the IconRecords for every page URL - RefCounting will cause the IconRecords themselves to be deleted
         // We don't delete the actual PageRecords because we have the "retain icon for url" count to keep track of
@@ -200,14 +200,14 @@ void IconDatabase::removeAllIcons()
                     
         // Clear all in-memory records of things that need to be synced out to disk
         {
-            MutexLocker locker(m_pendingSyncLock);
+            LockHolder locker(m_pendingSyncLock);
             m_pageURLsPendingSync.clear();
             m_iconsPendingSync.clear();
         }
         
         // Clear all in-memory records of things that need to be read in from disk
         {
-            MutexLocker locker(m_pendingReadingLock);
+            LockHolder locker(m_pendingReadingLock);
             m_pageURLsPendingImport.clear();
             m_pageURLsInterestedInIcons.clear();
             m_iconsPendingReading.clear();
@@ -229,7 +229,7 @@ Image* IconDatabase::synchronousIconForPageURL(const String& pageURLOriginal, co
     if (!isOpen() || !documentCanHaveIcon(pageURLOriginal))
         return 0;
 
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
 
     performPendingRetainAndReleaseOperations();
     
@@ -245,7 +245,7 @@ Image* IconDatabase::synchronousIconForPageURL(const String& pageURLOriginal, co
     // 1 - The initial url import is incomplete and this pageURL was marked to be notified once it is complete if an iconURL exists
     // 2 - The initial url import IS complete and this pageURL has no icon
     if (!pageRecord) {
-        MutexLocker locker(m_pendingReadingLock);
+        LockHolder locker(m_pendingReadingLock);
         
         // Import is ongoing, there might be an icon.  In this case, register to be notified when the icon comes in
         // If we ever reach this condition, we know we've already made the pageURL copy
@@ -276,7 +276,7 @@ Image* IconDatabase::synchronousIconForPageURL(const String& pageURLOriginal, co
         if (pageURLCopy.isNull())
             pageURLCopy = pageURLOriginal.isolatedCopy();
     
-        MutexLocker locker(m_pendingReadingLock);
+        LockHolder locker(m_pendingReadingLock);
         m_pageURLsInterestedInIcons.add(pageURLCopy);
         m_iconsPendingReading.add(iconRecord);
         wakeSyncThread();
@@ -307,7 +307,7 @@ PassNativeImagePtr IconDatabase::synchronousNativeIconForPageURL(const String& p
     if (!icon)
         return 0;
 
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     return icon->nativeImageForCurrentFrame();
 }
 
@@ -329,7 +329,7 @@ String IconDatabase::synchronousIconURLForPageURL(const String& pageURLOriginal)
     if (!isOpen() || !documentCanHaveIcon(pageURLOriginal))
         return String();
         
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     
     PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURLOriginal);
     if (!pageRecord)
@@ -417,7 +417,7 @@ void IconDatabase::retainIconForPageURL(const String& pageURL)
         return;
 
     {
-        MutexLocker locker(m_urlsToRetainOrReleaseLock);
+        LockHolder locker(m_urlsToRetainOrReleaseLock);
         m_urlsToRetain.add(pageURL.isolatedCopy());
         m_retainOrReleaseIconRequested = true;
     }
@@ -450,7 +450,7 @@ void IconDatabase::performRetainIconForPageURL(const String& pageURLOriginal, in
         if (!m_iconURLImportComplete)
             return;
 
-        MutexLocker locker(m_pendingSyncLock);
+        LockHolder locker(m_pendingSyncLock);
         // If this pageURL waiting to be sync'ed, update the sync record
         // This saves us in the case where a page was ready to be deleted from the database but was just retained - so theres no need to delete it!
         if (!m_privateBrowsingEnabled && m_pageURLsPendingSync.contains(pageURL)) {
@@ -470,7 +470,7 @@ void IconDatabase::releaseIconForPageURL(const String& pageURL)
         return;
 
     {
-        MutexLocker locker(m_urlsToRetainOrReleaseLock);
+        LockHolder locker(m_urlsToRetainOrReleaseLock);
         m_urlsToRelease.add(pageURL.isolatedCopy());
         m_retainOrReleaseIconRequested = true;
     }
@@ -506,7 +506,7 @@ void IconDatabase::performReleaseIconForPageURL(const String& pageURLOriginal, i
     ASSERT(!iconRecord || (iconRecord && m_iconURLToRecordMap.get(iconRecord->iconURL()) == iconRecord));
 
     {
-        MutexLocker locker(m_pendingReadingLock);
+        LockHolder locker(m_pendingReadingLock);
         
         // Since this pageURL is going away, there's no reason anyone would ever be interested in its read results    
         if (!m_iconURLImportComplete)
@@ -522,7 +522,7 @@ void IconDatabase::performReleaseIconForPageURL(const String& pageURLOriginal, i
     
     // Mark stuff for deletion from the database only if we're not in private browsing
     if (!m_privateBrowsingEnabled) {
-        MutexLocker locker(m_pendingSyncLock);
+        LockHolder locker(m_pendingSyncLock);
         m_pageURLsPendingSync.set(pageURLOriginal.isolatedCopy(), pageRecord->snapshot(true));
     
         // If this page is the last page to refer to a particular IconRecord, that IconRecord needs to
@@ -548,12 +548,12 @@ void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal,
     
     Vector<String> pageURLs;
     {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
     
         // If this icon was pending a read, remove it from that set because this new data should override what is on disk
         RefPtr<IconRecord> icon = m_iconURLToRecordMap.get(iconURL);
         if (icon) {
-            MutexLocker locker(m_pendingReadingLock);
+            LockHolder locker(m_pendingReadingLock);
             m_iconsPendingReading.remove(icon.get());
         } else
             icon = getOrCreateIconRecord(iconURL);
@@ -567,7 +567,7 @@ void IconDatabase::setIconDataForIconURL(PassRefPtr<SharedBuffer> dataOriginal,
         
         // Mark the IconRecord as requiring an update to the database only if private browsing is disabled
         if (!m_privateBrowsingEnabled) {
-            MutexLocker locker(m_pendingSyncLock);
+            LockHolder locker(m_pendingSyncLock);
             m_iconsPendingSync.set(iconURL, icon->snapshot());
         }
 
@@ -608,7 +608,7 @@ void IconDatabase::setIconURLForPageURL(const String& iconURLOriginal, const Str
     String iconURL, pageURL;
     
     {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
 
         PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURLOriginal);
         
@@ -636,13 +636,13 @@ void IconDatabase::setIconURLForPageURL(const String& iconURLOriginal, const Str
             ASSERT(iconRecord->retainingPageURLs().size() == 0);
             LOG(IconDatabase, "Icon for icon url %s is about to be destroyed - removing mapping for it", urlForLogging(iconRecord->iconURL()).ascii().data());
             m_iconURLToRecordMap.remove(iconRecord->iconURL());
-            MutexLocker locker(m_pendingReadingLock);
+            LockHolder locker(m_pendingReadingLock);
             m_iconsPendingReading.remove(iconRecord.get());
         }
         
         // And mark this mapping to be added to the database
         if (!m_privateBrowsingEnabled) {
-            MutexLocker locker(m_pendingSyncLock);
+            LockHolder locker(m_pendingSyncLock);
             m_pageURLsPendingSync.set(pageURL, pageRecord->snapshot());
             
             // If the icon is on its last ref, mark it for deletion
@@ -674,7 +674,7 @@ IconLoadDecision IconDatabase::synchronousLoadDecisionForIconURL(const String& i
     // 1 - When we read the icon urls from disk, getting the timeStamp at the same time
     // 2 - When we get a new icon from the loader, in which case the timestamp is set at that time
     {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
         if (IconRecord* icon = m_iconURLToRecordMap.get(iconURL)) {
             LOG(IconDatabase, "Found expiration time on a present icon based on existing IconRecord");
             return static_cast<int>(currentTime()) - static_cast<int>(icon->getTimestamp()) > iconExpirationTime ? IconLoadYes : IconLoadNo;
@@ -682,7 +682,7 @@ IconLoadDecision IconDatabase::synchronousLoadDecisionForIconURL(const String& i
     }
     
     // If we don't have a record for it, but we *have* imported all iconURLs from disk, then we should load it now
-    MutexLocker readingLocker(m_pendingReadingLock);
+    LockHolder readingLocker(m_pendingReadingLock);
     if (m_iconURLImportComplete)
         return IconLoadYes;
         
@@ -699,7 +699,7 @@ bool IconDatabase::synchronousIconDataKnownForIconURL(const String& iconURL)
 {
     ASSERT_NOT_SYNC_THREAD();
     
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     if (IconRecord* icon = m_iconURLToRecordMap.get(iconURL))
         return icon->imageDataStatus() != ImageDataStatusUnknown;
 
@@ -754,26 +754,26 @@ void IconDatabase::checkIntegrityBeforeOpening()
 
 size_t IconDatabase::pageURLMappingCount()
 {
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     return m_pageURLToRecordMap.size();
 }
 
 size_t IconDatabase::retainedPageURLCount()
 {
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     performPendingRetainAndReleaseOperations();
     return m_retainedPageURLs.size();
 }
 
 size_t IconDatabase::iconRecordCount()
 {
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     return m_iconURLToRecordMap.size();
 }
 
 size_t IconDatabase::iconRecordCountWithData()
 {
-    MutexLocker locker(m_urlAndIconLock);
+    LockHolder locker(m_urlAndIconLock);
     size_t result = 0;
     
     HashMap<String, IconRecord*>::iterator i = m_iconURLToRecordMap.begin();
@@ -829,13 +829,13 @@ void IconDatabase::notifyPendingLoadDecisions()
 
 void IconDatabase::wakeSyncThread()
 {
-    MutexLocker locker(m_syncLock);
+    LockHolder locker(m_syncLock);
 
     if (!m_disableSuddenTerminationWhileSyncThreadHasWorkToDo)
         m_disableSuddenTerminationWhileSyncThreadHasWorkToDo = std::make_unique<SuddenTerminationDisabler>();
 
     m_syncThreadHasWorkToDo = true;
-    m_syncCondition.signal();
+    m_syncCondition.notifyOne();
 }
 
 void IconDatabase::scheduleOrDeferSyncTimer()
@@ -874,13 +874,13 @@ bool IconDatabase::isOpen() const
 
 bool IconDatabase::isOpenBesidesMainThreadCallbacks() const
 {
-    MutexLocker locker(m_syncLock);
+    LockHolder locker(m_syncLock);
     return m_syncThreadRunning || m_syncDB.isOpen();
 }
 
 String IconDatabase::databasePath() const
 {
-    MutexLocker locker(m_syncLock);
+    LockHolder locker(m_syncLock);
     return m_completeDatabasePath.isolatedCopy();
 }
 
@@ -916,7 +916,7 @@ PageURLRecord* IconDatabase::getOrCreatePageURLRecord(const String& pageURL)
 
     PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURL);
     
-    MutexLocker locker(m_pendingReadingLock);
+    LockHolder locker(m_pendingReadingLock);
     if (!m_iconURLImportComplete) {
         // If the initial import of all URLs hasn't completed and we have no page record, we assume we *might* know about this later and create a record for it
         if (!pageRecord) {
@@ -985,7 +985,7 @@ void IconDatabase::iconDatabaseSyncThread()
     }
     
     {
-        MutexLocker locker(m_syncLock);
+        LockHolder locker(m_syncLock);
         if (!m_syncDB.open(m_completeDatabasePath)) {
             LOG_ERROR("Unable to open icon database at path %s - %s", m_completeDatabasePath.ascii().data(), m_syncDB.lastErrorMsg());
             return;
@@ -1113,7 +1113,7 @@ void IconDatabase::performOpenInitialization()
             m_syncDB.close();
             
             {
-                MutexLocker locker(m_syncLock);
+                LockHolder locker(m_syncLock);
                 // Should've been consumed by SQLite, delete just to make sure we don't see it again in the future;
                 deleteFile(m_completeDatabasePath + "-journal");
                 deleteFile(m_completeDatabasePath);
@@ -1215,7 +1215,7 @@ void IconDatabase::performURLImport()
         String iconURL = query.getColumnText(1);
 
         {
-            MutexLocker locker(m_urlAndIconLock);
+            LockHolder locker(m_urlAndIconLock);
 
             PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURL);
             
@@ -1248,7 +1248,7 @@ void IconDatabase::performURLImport()
         // one for the URL and one for the Image itself
         // Note that WebIconDatabase is not neccessarily API so we might be able to make this change
         {
-            MutexLocker locker(m_pendingReadingLock);
+            LockHolder locker(m_pendingReadingLock);
             if (m_pageURLsPendingImport.contains(pageURL)) {
                 dispatchDidImportIconURLForPageURLOnMainThread(pageURL);
                 m_pageURLsPendingImport.remove(pageURL);
@@ -1271,7 +1271,7 @@ void IconDatabase::performURLImport()
     // but after m_iconURLImportComplete is set to true, we don't care about this set anymore
     Vector<String> urls;
     {
-        MutexLocker locker(m_pendingReadingLock);
+        LockHolder locker(m_pendingReadingLock);
 
         urls.appendRange(m_pageURLsPendingImport.begin(), m_pageURLsPendingImport.end());
         m_pageURLsPendingImport.clear();        
@@ -1284,7 +1284,7 @@ void IconDatabase::performURLImport()
     // Remove unretained ones if database cleanup is allowed
     // Keep a set of ones that are retained and pending notification
     {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
 
         performPendingRetainAndReleaseOperations();
 
@@ -1301,12 +1301,12 @@ void IconDatabase::performURLImport()
                         m_iconURLToRecordMap.remove(iconRecord->iconURL());
                         
                         {
-                            MutexLocker locker(m_pendingReadingLock);
+                            LockHolder locker(m_pendingReadingLock);
                             m_pageURLsInterestedInIcons.remove(urls[i]);
                             m_iconsPendingReading.remove(iconRecord);
                         }
                         {
-                            MutexLocker locker(m_pendingSyncLock);
+                            LockHolder locker(m_pendingSyncLock);
                             m_iconsPendingSync.set(iconRecord->iconURL(), iconRecord->snapshot(true));                    
                         }
                     }
@@ -1371,7 +1371,7 @@ void IconDatabase::syncThreadMainLoop()
             break;
 
         {
-            MutexLocker locker(m_urlAndIconLock);
+            LockHolder locker(m_urlAndIconLock);
             performPendingRetainAndReleaseOperations();
         }
         
@@ -1451,7 +1451,7 @@ void IconDatabase::performPendingRetainAndReleaseOperations()
     HashCountedSet<String> toRelease;
 
     {
-        MutexLocker pendingWorkLocker(m_urlsToRetainOrReleaseLock);
+        LockHolder pendingWorkLocker(m_urlsToRetainOrReleaseLock);
         if (!m_retainOrReleaseIconRequested)
             return;
 
@@ -1488,7 +1488,7 @@ bool IconDatabase::readFromDatabase()
     // This way we won't hold the lock for a long period of time
     Vector<IconRecord*> icons;
     {
-        MutexLocker locker(m_pendingReadingLock);
+        LockHolder locker(m_pendingReadingLock);
         icons.appendRange(m_iconsPendingReading.begin(), m_iconsPendingReading.end());
     }
     
@@ -1501,9 +1501,9 @@ bool IconDatabase::readFromDatabase()
 
         // Verify this icon still wants to be read from disk
         {
-            MutexLocker urlLocker(m_urlAndIconLock);
+            LockHolder urlLocker(m_urlAndIconLock);
             {
-                MutexLocker readLocker(m_pendingReadingLock);
+                LockHolder readLocker(m_pendingReadingLock);
                 
                 if (m_iconsPendingReading.contains(icons[i])) {
                     // Set the new data
@@ -1591,11 +1591,11 @@ bool IconDatabase::writeToDatabase()
     // we'll pick it up on the next pass.  This greatly simplifies the locking strategy for this method and remains cohesive with changes
     // asked for by the database on the main thread
     {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
         Vector<IconSnapshot> iconSnapshots;
         Vector<PageURLSnapshot> pageSnapshots;
         {
-            MutexLocker locker(m_pendingSyncLock);
+            LockHolder locker(m_pendingSyncLock);
 
             iconSnapshots.appendRange(m_iconsPendingSync.begin().values(), m_iconsPendingSync.end().values());
             m_iconsPendingSync.clear();
@@ -1658,7 +1658,7 @@ void IconDatabase::pruneUnretainedIcons()
     
     int result;
     while ((result = pageSQL.step()) == SQLITE_ROW) {
-        MutexLocker locker(m_urlAndIconLock);
+        LockHolder locker(m_urlAndIconLock);
         if (!m_pageURLToRecordMap.contains(pageSQL.getColumnText(1)))
             pageIDsToDelete.append(pageSQL.getColumnInt64(0));
     }
@@ -1791,7 +1791,7 @@ void* IconDatabase::cleanupSyncThread()
     writeToDatabase();
     
     // Close the database
-    MutexLocker locker(m_syncLock);
+    LockHolder locker(m_syncLock);
     
     m_databaseDirectory = String();
     m_completeDatabasePath = String();
index 22a30fd..1c86731 100644 (file)
@@ -33,6 +33,7 @@
 #if ENABLE(ICONDATABASE)
 #include "SQLiteDatabase.h"
 #include "Timer.h"
+#include <wtf/Condition.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
@@ -141,8 +142,8 @@ private:
     bool m_isEnabled;
     bool m_privateBrowsingEnabled;
 
-    mutable Mutex m_syncLock;
-    ThreadCondition m_syncCondition;
+    mutable Lock m_syncLock;
+    Condition m_syncCondition;
     String m_databaseDirectory;
     // Holding m_syncLock is required when accessing m_completeDatabasePath
     String m_completeDatabasePath;
@@ -153,24 +154,24 @@ private:
     bool m_syncThreadHasWorkToDo;
     std::unique_ptr<SuddenTerminationDisabler> m_disableSuddenTerminationWhileSyncThreadHasWorkToDo;
 
-    Mutex m_urlAndIconLock;
+    Lock m_urlAndIconLock;
     // Holding m_urlAndIconLock is required when accessing any of the following data structures or the objects they contain
     HashMap<String, IconRecord*> m_iconURLToRecordMap;
     HashMap<String, PageURLRecord*> m_pageURLToRecordMap;
     HashSet<String> m_retainedPageURLs;
 
-    Mutex m_pendingSyncLock;
+    Lock m_pendingSyncLock;
     // Holding m_pendingSyncLock is required when accessing any of the following data structures
     HashMap<String, PageURLSnapshot> m_pageURLsPendingSync;
     HashMap<String, IconSnapshot> m_iconsPendingSync;
     
-    Mutex m_pendingReadingLock;    
+    Lock m_pendingReadingLock;    
     // Holding m_pendingSyncLock is required when accessing any of the following data structures - when dealing with IconRecord*s, holding m_urlAndIconLock is also required
     HashSet<String> m_pageURLsPendingImport;
     HashSet<String> m_pageURLsInterestedInIcons;
     HashSet<IconRecord*> m_iconsPendingReading;
 
-    Mutex m_urlsToRetainOrReleaseLock;
+    Lock m_urlsToRetainOrReleaseLock;
     // Holding m_urlsToRetainOrReleaseLock is required when accessing any of the following data structures.
     HashCountedSet<String> m_urlsToRetain;
     HashCountedSet<String> m_urlsToRelease;
index 7892abf..0f41fea 100644 (file)
@@ -49,7 +49,7 @@ ScrollingTree::~ScrollingTree()
 bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent& wheelEvent)
 {
     // This method is invoked by the event handling thread
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
 
     bool shouldSetLatch = wheelEvent.shouldConsiderLatching();
     
@@ -115,7 +115,7 @@ void ScrollingTree::commitNewTreeState(std::unique_ptr<ScrollingStateTree> scrol
         && (rootStateNodeChanged
             || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion)
             || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))) {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
 
         if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
             m_mainFrameScrollPosition = FloatPoint();
@@ -208,7 +208,7 @@ ScrollingTreeNode* ScrollingTree::nodeForID(ScrollingNodeID nodeID) const
 
 void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom)
 {
-    MutexLocker locker(m_swipeStateMutex);
+    LockHolder locker(m_swipeStateMutex);
 
     m_mainFramePinnedToTheLeft = pinnedToTheLeft;
     m_mainFramePinnedToTheRight = pinnedToTheRight;
@@ -218,54 +218,54 @@ void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheR
 
 FloatPoint ScrollingTree::mainFrameScrollPosition()
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     return m_mainFrameScrollPosition;
 }
 
 void ScrollingTree::setMainFrameScrollPosition(FloatPoint position)
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     m_mainFrameScrollPosition = position;
 }
 
 bool ScrollingTree::isPointInNonFastScrollableRegion(IntPoint p)
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     
     return m_nonFastScrollableRegion.contains(p);
 }
 
 bool ScrollingTree::isRubberBandInProgress()
 {
-    MutexLocker lock(m_mutex);    
+    LockHolder lock(m_mutex);    
 
     return m_mainFrameIsRubberBanding;
 }
 
 void ScrollingTree::setMainFrameIsRubberBanding(bool isRubberBanding)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     m_mainFrameIsRubberBanding = isRubberBanding;
 }
 
 bool ScrollingTree::isScrollSnapInProgress()
 {
-    MutexLocker lock(m_mutex);
+    LockHolder lock(m_mutex);
     
     return m_mainFrameIsScrollSnapping;
 }
     
 void ScrollingTree::setMainFrameIsScrollSnapping(bool isScrollSnapping)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     
     m_mainFrameIsScrollSnapping = isScrollSnapping;
 }
 
 void ScrollingTree::setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
 {
-    MutexLocker locker(m_swipeStateMutex);
+    LockHolder locker(m_swipeStateMutex);
 
     m_rubberBandsAtLeft = canRubberBandAtLeft;
     m_rubberBandsAtRight = canRubberBandAtRight;
@@ -275,28 +275,28 @@ void ScrollingTree::setCanRubberBandState(bool canRubberBandAtLeft, bool canRubb
 
 bool ScrollingTree::rubberBandsAtLeft()
 {
-    MutexLocker lock(m_swipeStateMutex);
+    LockHolder lock(m_swipeStateMutex);
 
     return m_rubberBandsAtLeft;
 }
 
 bool ScrollingTree::rubberBandsAtRight()
 {
-    MutexLocker lock(m_swipeStateMutex);
+    LockHolder lock(m_swipeStateMutex);
 
     return m_rubberBandsAtRight;
 }
 
 bool ScrollingTree::rubberBandsAtBottom()
 {
-    MutexLocker lock(m_swipeStateMutex);
+    LockHolder lock(m_swipeStateMutex);
 
     return m_rubberBandsAtBottom;
 }
 
 bool ScrollingTree::rubberBandsAtTop()
 {
-    MutexLocker lock(m_swipeStateMutex);
+    LockHolder lock(m_swipeStateMutex);
 
     return m_rubberBandsAtTop;
 }
@@ -308,14 +308,14 @@ bool ScrollingTree::isHandlingProgrammaticScroll()
 
 void ScrollingTree::setScrollPinningBehavior(ScrollPinningBehavior pinning)
 {
-    MutexLocker locker(m_swipeStateMutex);
+    LockHolder locker(m_swipeStateMutex);
     
     m_scrollPinningBehavior = pinning;
 }
 
 ScrollPinningBehavior ScrollingTree::scrollPinningBehavior()
 {
-    MutexLocker lock(m_swipeStateMutex);
+    LockHolder lock(m_swipeStateMutex);
     
     return m_scrollPinningBehavior;
 }
@@ -325,7 +325,7 @@ bool ScrollingTree::willWheelEventStartSwipeGesture(const PlatformWheelEvent& wh
     if (wheelEvent.phase() != PlatformWheelEventPhaseBegan)
         return false;
 
-    MutexLocker lock(m_swipeStateMutex);
+    LockHolder lock(m_swipeStateMutex);
 
     if (wheelEvent.deltaX() > 0 && m_mainFramePinnedToTheLeft && !m_rubberBandsAtLeft)
         return true;
@@ -351,19 +351,19 @@ bool ScrollingTree::scrollingPerformanceLoggingEnabled()
 
 ScrollingNodeID ScrollingTree::latchedNode()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     return m_latchedNode;
 }
 
 void ScrollingTree::setLatchedNode(ScrollingNodeID node)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     m_latchedNode = node;
 }
 
 void ScrollingTree::clearLatchedNode()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     m_latchedNode = 0;
 }
 
index 12cb26f..b97765b 100644 (file)
@@ -33,6 +33,7 @@
 #include "ScrollingCoordinator.h"
 #include "WheelEventTestTrigger.h"
 #include <wtf/HashMap.h>
+#include <wtf/Lock.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/TypeCasts.h>
 
@@ -160,11 +161,11 @@ private:
     typedef HashMap<ScrollingNodeID, ScrollingTreeNode*> ScrollingTreeNodeMap;
     ScrollingTreeNodeMap m_nodeMap;
 
-    Mutex m_mutex;
+    Lock m_mutex;
     Region m_nonFastScrollableRegion;
     FloatPoint m_mainFrameScrollPosition;
 
-    Mutex m_swipeStateMutex;
+    Lock m_swipeStateMutex;
     ScrollPinningBehavior m_scrollPinningBehavior { DoNotPin };
     ScrollingNodeID m_latchedNode { 0 };
 
index 5571058..bc41527 100644 (file)
@@ -34,6 +34,7 @@
 #include <wtf/Forward.h>
 
 #if PLATFORM(IOS)
+#include <wtf/Lock.h>
 #include <wtf/ThreadingPrimitives.h>
 #elif OS(LINUX)
 #include "Timer.h"
@@ -137,7 +138,7 @@ private:
     bool m_clearPressureOnMemoryRelease;
     void (^m_releaseMemoryBlock)();
     CFRunLoopObserverRef m_observer;
-    Mutex m_observerMutex;
+    Lock m_observerMutex;
 #elif OS(LINUX)
     int m_eventFD;
     int m_pressureLevelFD;
index dd55938..f71333c 100644 (file)
@@ -102,7 +102,7 @@ void HRTFDatabaseLoader::loadAsynchronously()
 {
     ASSERT(isMainThread());
 
-    MutexLocker locker(m_threadLock);
+    LockHolder locker(m_threadLock);
     
     if (!m_hrtfDatabase.get() && !m_databaseLoaderThread) {
         // Start the asynchronous database loading process.
@@ -117,7 +117,7 @@ bool HRTFDatabaseLoader::isLoaded() const
 
 void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
 {
-    MutexLocker locker(m_threadLock);
+    LockHolder locker(m_threadLock);
     
     // waitForThreadCompletion() should not be called twice for the same thread.
     if (m_databaseLoaderThread)
index 417b490..7889e10 100644 (file)
@@ -32,6 +32,7 @@
 #include "HRTFDatabase.h"
 #include <memory>
 #include <wtf/HashMap.h>
+#include <wtf/Lock.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -76,7 +77,7 @@ private:
     std::unique_ptr<HRTFDatabase> m_hrtfDatabase;
 
     // Holding a m_threadLock is required when accessing m_databaseLoaderThread.
-    Mutex m_threadLock;
+    Lock m_threadLock;
     ThreadIdentifier m_databaseLoaderThread;
 
     float m_databaseSampleRate;
index 5ed366d..6d0d0e0 100644 (file)
@@ -256,7 +256,7 @@ void MemoryPressureHandler::setReceivedMemoryPressure(MemoryPressureReason reaso
     m_underMemoryPressure = true;
 
     {
-        MutexLocker locker(m_observerMutex);
+        LockHolder locker(m_observerMutex);
         if (!m_observer) {
             m_observer = CFRunLoopObserverCreate(NULL, kCFRunLoopBeforeWaiting | kCFRunLoopExit, NO /* don't repeat */,
                 0, WebCore::respondToMemoryPressureCallback, NULL);
@@ -272,14 +272,14 @@ void MemoryPressureHandler::clearMemoryPressure()
     m_underMemoryPressure = false;
 
     {
-        MutexLocker locker(m_observerMutex);
+        LockHolder locker(m_observerMutex);
         m_memoryPressureReason = MemoryPressureReasonNone;
     }
 }
 
 bool MemoryPressureHandler::shouldWaitForMemoryClearMessage()
 {
-    MutexLocker locker(m_observerMutex);
+    LockHolder locker(m_observerMutex);
     return m_memoryPressureReason & MemoryPressureReasonVMStatus;
 }
 
@@ -288,7 +288,7 @@ void MemoryPressureHandler::respondToMemoryPressureIfNeeded()
     ASSERT(WebThreadIsLockedOrDisabled());
 
     {
-        MutexLocker locker(m_observerMutex);
+        LockHolder locker(m_observerMutex);
         m_observer = 0;
     }
 
index f23808c..8fe9ae1 100644 (file)
@@ -89,7 +89,7 @@ void DisplayRefreshMonitor::displayDidRefresh()
     double monotonicAnimationStartTime;
 
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         if (!m_scheduled)
             ++m_unscheduledFireCount;
         else
@@ -121,7 +121,7 @@ void DisplayRefreshMonitor::displayDidRefresh()
         m_clientsToBeNotified = nullptr;
 
     {
-        MutexLocker lock(m_mutex);
+        LockHolder lock(m_mutex);
         m_previousFrameDone = true;
     }
     
index bb8c961..ee09e7d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,9 +30,9 @@
 
 #include "PlatformScreen.h"
 #include <wtf/HashSet.h>
+#include <wtf/Lock.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
-#include <wtf/Threading.h>
 
 namespace WebCore {
 
@@ -72,7 +72,7 @@ public:
 
     void setMonotonicAnimationStartTime(double startTime) { m_monotonicAnimationStartTime = startTime; }
 
-    Mutex& mutex() { return m_mutex; }
+    Lock& mutex() { return m_mutex; }
 
     static RefPtr<DisplayRefreshMonitor> createDefaultDisplayRefreshMonitor(PlatformDisplayID);
 
@@ -89,7 +89,7 @@ private:
     bool m_previousFrameDone;
     int m_unscheduledFireCount; // Number of times the display link has fired with no clients.
     PlatformDisplayID m_displayID;
-    Mutex m_mutex;
+    Lock m_mutex;
 
     HashSet<DisplayRefreshMonitorClient*> m_clients;
     HashSet<DisplayRefreshMonitorClient*>* m_clientsToBeNotified;
index 4f8e8b0..e74786f 100644 (file)
@@ -735,7 +735,7 @@ void MediaPlayerPrivateAVFoundation::setPreload(MediaPlayer::Preload preload)
 
 void MediaPlayerPrivateAVFoundation::setDelayCallbacks(bool delay) const
 {
-    MutexLocker lock(m_queueMutex);
+    LockHolder lock(m_queueMutex);
     if (delay)
         ++m_delayCallbacks;
     else {
@@ -754,7 +754,7 @@ void MediaPlayerPrivateAVFoundation::mainThreadCallback(void* context)
 
 void MediaPlayerPrivateAVFoundation::clearMainThreadPendingFlag()
 {
-    MutexLocker lock(m_queueMutex);
+    LockHolder lock(m_queueMutex);
     m_mainThreadCallPending = false;
 }
 
@@ -820,7 +820,7 @@ void MediaPlayerPrivateAVFoundation::dispatchNotification()
 
     Notification notification = Notification();
     {
-        MutexLocker lock(m_queueMutex);
+        LockHolder lock(m_queueMutex);
         
         if (m_queuedNotifications.isEmpty())
             return;
index a84d377..41f309c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,6 +34,7 @@
 #include "Timer.h"
 #include <functional>
 #include <wtf/HashSet.h>
+#include <wtf/Lock.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/WeakPtr.h>
 
@@ -317,7 +318,7 @@ private:
     std::function<void()> m_pendingSeek;
 
     Vector<Notification> m_queuedNotifications;
-    mutable Mutex m_queueMutex;
+    mutable Lock m_queueMutex;
 
     mutable std::unique_ptr<PlatformTimeRanges> m_cachedLoadedTimeRanges;
 
index 6aaefcd..f4c66c7 100644 (file)
@@ -158,7 +158,7 @@ public:
 private:
     inline void* callbackContext() const { return reinterpret_cast<void*>(m_objectID); }
 
-    static Mutex& mapLock();
+    static Lock& mapLock();
     static HashMap<uintptr_t, AVFWrapper*>& map();
     static AVFWrapper* avfWrapperForCallbackContext(void*);
     void addToMap();
@@ -1404,9 +1404,9 @@ AVFWrapper::~AVFWrapper()
     m_avPlayer = 0;
 }
 
-Mutex& AVFWrapper::mapLock()
+Lock& AVFWrapper::mapLock()
 {
-    static Mutex mapLock;
+    static Lock mapLock;
     return mapLock;
 }
 
@@ -1418,7 +1418,7 @@ HashMap<uintptr_t, AVFWrapper*>& AVFWrapper::map()
 
 void AVFWrapper::addToMap()
 {
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     
     // HashMap doesn't like a key of 0, and also make sure we aren't
     // using an object ID that's already in use.
@@ -1434,7 +1434,7 @@ void AVFWrapper::removeFromMap() const
 {
     LOG(Media, "AVFWrapper::removeFromMap(%p %d)", this, m_objectID);
 
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     map().remove(m_objectID);
 }
 
@@ -1635,7 +1635,7 @@ void AVFWrapper::createPlayerItem()
 
 void AVFWrapper::periodicTimeObserverCallback(AVCFPlayerRef, CMTime cmTime, void* context)
 {
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(context);
     if (!self) {
         LOG(Media, "AVFWrapper::periodicTimeObserverCallback invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1666,7 +1666,7 @@ void AVFWrapper::processNotification(void* context)
 
     std::unique_ptr<NotificationCallbackData> notificationData { static_cast<NotificationCallbackData*>(context) };
 
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(notificationData->m_context);
     if (!self) {
         LOG(Media, "AVFWrapper::processNotification invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1721,7 +1721,7 @@ void AVFWrapper::notificationCallback(CFNotificationCenterRef, void* observer, C
 
 void AVFWrapper::loadPlayableCompletionCallback(AVCFAssetRef, void* context)
 {
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(context);
     if (!self) {
         LOG(Media, "AVFWrapper::loadPlayableCompletionCallback invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1749,7 +1749,7 @@ void AVFWrapper::checkPlayability()
 
 void AVFWrapper::loadMetadataCompletionCallback(AVCFAssetRef, void* context)
 {
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(context);
     if (!self) {
         LOG(Media, "AVFWrapper::loadMetadataCompletionCallback invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1769,7 +1769,7 @@ void AVFWrapper::beginLoadingMetadata()
 
 void AVFWrapper::seekCompletedCallback(AVCFPlayerItemRef, Boolean finished, void* context)
 {
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(context);
     if (!self) {
         LOG(Media, "AVFWrapper::seekCompletedCallback invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1812,7 +1812,7 @@ void AVFWrapper::processCue(void* context)
 
     std::unique_ptr<LegibleOutputData> legibleOutputData(reinterpret_cast<LegibleOutputData*>(context));
 
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(legibleOutputData->m_context);
     if (!self) {
         LOG(Media, "AVFWrapper::processCue invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1828,7 +1828,7 @@ void AVFWrapper::processCue(void* context)
 void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef legibleOutput, CFArrayRef attributedStrings, CFArrayRef nativeSampleBuffers, CMTime itemTime)
 {
     ASSERT(!isMainThread());
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(context);
     if (!self) {
         LOG(Media, "AVFWrapper::legibleOutputCallback invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1866,7 +1866,7 @@ void AVFWrapper::processShouldWaitForLoadingOfResource(void* context)
 
     std::unique_ptr<LoadRequestData> loadRequestData(reinterpret_cast<LoadRequestData*>(context));
 
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(loadRequestData->m_context);
     if (!self) {
         LOG(Media, "AVFWrapper::processShouldWaitForLoadingOfResource invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
@@ -1922,7 +1922,7 @@ bool AVFWrapper::shouldWaitForLoadingOfResource(AVCFAssetResourceLoadingRequestR
 Boolean AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource(AVCFAssetResourceLoaderRef resourceLoader, AVCFAssetResourceLoadingRequestRef loadingRequest, void *context)
 {
     ASSERT(dispatch_get_main_queue() != dispatch_get_current_queue());
-    MutexLocker locker(mapLock());
+    LockHolder locker(mapLock());
     AVFWrapper* self = avfWrapperForCallbackContext(context);
     if (!self) {
         LOG(Media, "AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
index 29e884b..f7170b8 100644 (file)
@@ -77,7 +77,7 @@ void InbandTextTrackPrivateGStreamer::handleSample(GRefPtr<GstSample> sample)
 {
     m_sampleTimerHandler.cancel();
     {
-        MutexLocker lock(m_sampleMutex);
+        LockHolder lock(m_sampleMutex);
         m_pendingSamples.append(sample);
     }
     m_sampleTimerHandler.schedule("[WebKit] InbandTextTrackPrivateGStreamer::notifyTrackOfSample", std::function<void()>(std::bind(&InbandTextTrackPrivateGStreamer::notifyTrackOfSample, this)));
@@ -92,7 +92,7 @@ void InbandTextTrackPrivateGStreamer::notifyTrackOfSample()
 {
     Vector<GRefPtr<GstSample> > samples;
     {
-        MutexLocker lock(m_sampleMutex);
+        LockHolder lock(m_sampleMutex);
         m_pendingSamples.swap(samples);
     }
 
index b7dffa7..36868c9 100644 (file)
@@ -31,6 +31,7 @@
 #include "GRefPtrGStreamer.h"
 #include "InbandTextTrackPrivate.h"
 #include "TrackPrivateBaseGStreamer.h"
+#include <wtf/Lock.h>
 #include <wtf/glib/GThreadSafeMainLoopSource.h>
 
 namespace WebCore {
@@ -67,7 +68,7 @@ private:
     gulong m_eventProbe;
     Vector<GRefPtr<GstSample> > m_pendingSamples;
     String m_streamId;
-    Mutex m_sampleMutex;
+    Lock m_sampleMutex;
 };
 
 } // namespace WebCore
index d91fd1e..4ae3ee9 100644 (file)
@@ -102,7 +102,7 @@ void TrackPrivateBaseGStreamer::tagsChanged()
     GRefPtr<GstTagList> tags;
     g_object_get(m_pad.get(), "tags", &tags.outPtr(), NULL);
     {
-        MutexLocker lock(m_tagMutex);
+        LockHolder lock(m_tagMutex);
         m_tags.swap(tags);
     }
 
@@ -158,7 +158,7 @@ void TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged()
 
     GRefPtr<GstTagList> tags;
     {
-        MutexLocker lock(m_tagMutex);
+        LockHolder lock(m_tagMutex);
         tags.swap(m_tags);
     }
     if (!tags)
index e3d6f41..b022c05 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(VIDEO_TRACK)
 
 #include "GRefPtrGStreamer.h"
+#include <wtf/Lock.h>
 #include <wtf/ThreadingPrimitives.h>
 #include <wtf/glib/GThreadSafeMainLoopSource.h>
 #include <wtf/text/WTFString.h>
@@ -73,7 +74,7 @@ private:
     GThreadSafeMainLoopSource m_activeTimerHandler;
     GThreadSafeMainLoopSource m_tagTimerHandler;
 
-    Mutex m_tagMutex;
+    Lock m_tagMutex;
     GRefPtr<GstTagList> m_tags;
 };
 
index 5125bb4..133666d 100644 (file)
@@ -84,14 +84,14 @@ bool DisplayRefreshMonitorMac::requestRefreshCallback()
         setIsActive(true);
     }
 
-    MutexLocker lock(mutex());
+    LockHolder lock(mutex());
     setIsScheduled(true);
     return true;
 }
 
 void DisplayRefreshMonitorMac::displayLinkFired(double nowSeconds, double outputTimeSeconds)
 {
-    MutexLocker lock(mutex());
+    LockHolder lock(mutex());
     if (!isPreviousFrameDone())
         return;
 
index 63e7c58..8383734 100644 (file)
@@ -512,21 +512,21 @@ void MediaPlayerPrivateMediaFoundation::destroyVideoWindow()
 
 void MediaPlayerPrivateMediaFoundation::addListener(MediaPlayerListener* listener)
 {
-    MutexLocker locker(m_mutexListeners);
+    LockHolder locker(m_mutexListeners);
 
     m_listeners.add(listener);
 }
 
 void MediaPlayerPrivateMediaFoundation::removeListener(MediaPlayerListener* listener)
 {
-    MutexLocker locker(m_mutexListeners);
+    LockHolder locker(m_mutexListeners);
 
     m_listeners.remove(listener);
 }
 
 void MediaPlayerPrivateMediaFoundation::notifyDeleted()
 {
-    MutexLocker locker(m_mutexListeners);
+    LockHolder locker(m_mutexListeners);
 
     for (HashSet<MediaPlayerListener*>::const_iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
         (*it)->onMediaPlayerDeleted();
@@ -704,7 +704,7 @@ HRESULT STDMETHODCALLTYPE MediaPlayerPrivateMediaFoundation::AsyncCallback::GetP
 
 HRESULT STDMETHODCALLTYPE MediaPlayerPrivateMediaFoundation::AsyncCallback::Invoke(__RPC__in_opt IMFAsyncResult *pAsyncResult)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     if (!m_mediaPlayer)
         return S_OK;
@@ -719,7 +719,7 @@ HRESULT STDMETHODCALLTYPE MediaPlayerPrivateMediaFoundation::AsyncCallback::Invo
 
 void MediaPlayerPrivateMediaFoundation::AsyncCallback::onMediaPlayerDeleted()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     m_mediaPlayer = nullptr;
 }
index 729d630..c11090b 100644 (file)
@@ -89,7 +89,7 @@ private:
 
     class MediaPlayerListener;
     HashSet<MediaPlayerListener*> m_listeners;
-    Mutex m_mutexListeners;
+    Lock m_mutexListeners;
 
     COMPtr<IMFMediaSession> m_mediaSession;
     COMPtr<IMFSourceResolver> m_sourceResolver;
@@ -149,7 +149,7 @@ private:
         ULONG m_refCount;
         MediaPlayerPrivateMediaFoundation* m_mediaPlayer;
         bool m_event;
-        Mutex m_mutex;
+        Lock m_mutex;
     };
 
 };
index 44babcc..c396c75 100644 (file)
@@ -33,6 +33,7 @@
 #include "IntRect.h"
 #include "IntSize.h"
 #include "Timer.h"
+#include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Optional.h>
 #include <wtf/PassRefPtr.h>
@@ -211,9 +212,9 @@ private:
     float m_pendingScale;
     float m_pendingZoomedOutScale;
 
-    mutable Mutex m_tileMutex;
-    mutable Mutex m_savedDisplayRectMutex;
-    mutable Mutex m_contentReplacementImageMutex;
+    mutable Lock m_tileMutex;
+    mutable Lock m_savedDisplayRectMutex;
+    mutable Lock m_contentReplacementImageMutex;
 
     bool m_tileControllerShouldUseLowScaleTiles;
 };
index 927e9a8..a71b829 100644 (file)
@@ -147,7 +147,7 @@ void LegacyTileCache::setTilesOpaque(bool opaque)
     if (m_tilesOpaque == opaque)
         return;
 
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
 
     m_tilesOpaque = opaque;
     m_zoomedOutTileGrid->updateTileOpacity();
@@ -160,7 +160,7 @@ void LegacyTileCache::doLayoutTiles()
     if (isTileCreationSuspended())
         return;
 
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     LegacyTileGrid* activeGrid = activeTileGrid();
     // Even though we aren't actually creating tiles in the inactive grid, we
     // still need to drop invalid tiles in response to a layout.
@@ -200,7 +200,7 @@ void LegacyTileCache::setCurrentScale(float scale)
     if (!keepsZoomedOutTiles() && !isTileInvalidationSuspended()) {
         // Tile invalidation is normally suspended during zooming by UIKit but some applications
         // using custom scrollviews may zoom without triggering the callbacks. Invalidate the tiles explicitly.
-        MutexLocker locker(m_tileMutex);
+        LockHolder locker(m_tileMutex);
         activeTileGrid()->dropAllTiles();
         activeTileGrid()->createTiles(CoverVisibleOnly);
     }
@@ -225,7 +225,7 @@ void LegacyTileCache::commitScaleChange()
     ASSERT(m_pendingZoomedOutScale || m_pendingScale);
     ASSERT(m_tilingMode != Disabled);
     
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
 
     if (m_pendingZoomedOutScale) {
         m_zoomedOutTileGrid->setScale(m_pendingZoomedOutScale);
@@ -314,7 +314,7 @@ void LegacyTileCache::layoutTilesNow()
     if (m_tilingMode == Zooming)
         m_tilingMode = Minimal;
 
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     LegacyTileGrid* activeGrid = activeTileGrid();
     if (activeGrid->checkDoSingleTileLayout()) {
         m_tilingMode = savedTilingMode;
@@ -327,14 +327,14 @@ void LegacyTileCache::layoutTilesNow()
 void LegacyTileCache::layoutTilesNowForRect(const IntRect& rect)
 {
     ASSERT(WebThreadIsLockedOrDisabled());
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
 
     activeTileGrid()->addTilesCoveringRect(rect);
 }
 
 void LegacyTileCache::removeAllNonVisibleTiles()
 {
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     removeAllNonVisibleTilesInternal();
 }
 
@@ -356,7 +356,7 @@ void LegacyTileCache::removeAllNonVisibleTilesInternal()
 
 void LegacyTileCache::removeAllTiles()
 {
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     m_zoomedOutTileGrid->dropAllTiles();
     if (m_zoomedInTileGrid)
         m_zoomedInTileGrid->dropAllTiles();
@@ -364,7 +364,7 @@ void LegacyTileCache::removeAllTiles()
 
 void LegacyTileCache::removeForegroundTiles()
 {
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     if (!keepsZoomedOutTiles())
         m_zoomedOutTileGrid->dropAllTiles();
     if (m_zoomedInTileGrid)
@@ -373,13 +373,13 @@ void LegacyTileCache::removeForegroundTiles()
 
 void LegacyTileCache::setContentReplacementImage(RetainPtr<CGImageRef> contentReplacementImage)
 {
-    MutexLocker locker(m_contentReplacementImageMutex);
+    LockHolder locker(m_contentReplacementImageMutex);
     m_contentReplacementImage = contentReplacementImage;
 }
 
 RetainPtr<CGImageRef> LegacyTileCache::contentReplacementImage() const
 {
-    MutexLocker locker(m_contentReplacementImageMutex);
+    LockHolder locker(m_contentReplacementImageMutex);
     return m_contentReplacementImage;
 }
 
@@ -426,7 +426,7 @@ void LegacyTileCache::tileCreationTimerFired()
 {
     if (isTileCreationSuspended())
         return;
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     createTilesInActiveGrid(CoverSpeculative);
 }
 
@@ -620,7 +620,7 @@ void LegacyTileCache::scheduleLayerFlushForPendingRepaint()
 
 void LegacyTileCache::setNeedsDisplayInRect(const IntRect& dirtyRect)
 {
-    MutexLocker locker(m_savedDisplayRectMutex);
+    LockHolder locker(m_savedDisplayRectMutex);
     bool addedFirstRect = m_savedDisplayRects.isEmpty();
     m_savedDisplayRects.append(dirtyRect);
     if (!addedFirstRect)
@@ -692,7 +692,7 @@ void LegacyTileCache::updateTilingMode()
         if (m_tilingMode == Disabled)
             return;
 
-        MutexLocker locker(m_tileMutex);
+        LockHolder locker(m_tileMutex);
         createTilesInActiveGrid(CoverVisibleOnly);
 
         if (!m_savedDisplayRects.isEmpty())
@@ -710,7 +710,7 @@ void LegacyTileCache::setTilingMode(TilingMode tilingMode)
     if ((m_pendingZoomedOutScale || m_pendingScale) && m_tilingMode != Disabled)
         commitScaleChange();
     else if (wasZooming) {
-        MutexLocker locker(m_tileMutex);
+        LockHolder locker(m_tileMutex);
         bringActiveTileGridToFront();
     }
 
@@ -753,7 +753,7 @@ void LegacyTileCache::doPendingRepaints()
         return;
     if (isTileInvalidationSuspended())
         return;
-    MutexLocker locker(m_tileMutex);
+    LockHolder locker(m_tileMutex);
     flushSavedDisplayRects();
 }
 
@@ -764,7 +764,7 @@ void LegacyTileCache::flushSavedDisplayRects()
 
     Vector<IntRect> rects;
     {
-        MutexLocker locker(m_savedDisplayRectMutex);
+        LockHolder locker(m_savedDisplayRectMutex);
         m_savedDisplayRects.swap(rects);
     }
     size_t size = rects.size();
@@ -792,7 +792,7 @@ void LegacyTileCache::prepareToDraw()
     [[m_window contentView] viewWillDraw];
 
     if (!m_savedDisplayRects.isEmpty()) {
-        MutexLocker locker(m_tileMutex);
+        LockHolder locker(m_tileMutex);
         flushSavedDisplayRects();
     }
 }
index 30fe6be..1bb2db7 100644 (file)
@@ -33,6 +33,7 @@
 #include "Timer.h"
 #include <wtf/Deque.h>
 #include <wtf/HashMap.h>
+#include <wtf/Lock.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Threading.h>
@@ -75,7 +76,7 @@ private:
     Vector<IntSize> m_sizesInPruneOrder;
     unsigned m_totalBytes;
     unsigned m_capacity;
-    Mutex m_layerPoolMutex;
+    Lock m_layerPoolMutex;
 
     double m_lastAddTime;
     bool m_needsPrune;
index dad4c83..72dde89 100644 (file)
@@ -84,7 +84,7 @@ void LegacyTileLayerPool::addLayer(const RetainPtr<LegacyTileLayer>& layer)
         return;
     }
 
-    MutexLocker locker(m_layerPoolMutex);
+    LockHolder locker(m_layerPoolMutex);
     listOfLayersWithSize(layerSize).prepend(layer);
     m_totalBytes += bytesBackingLayerWithPixelSize(layerSize);
 
@@ -96,7 +96,7 @@ RetainPtr<LegacyTileLayer> LegacyTileLayerPool::takeLayerWithSize(const IntSize&
 {
     if (!canReuseLayerWithSize(size))
         return nil;
-    MutexLocker locker(m_layerPoolMutex);
+    LockHolder locker(m_layerPoolMutex);
     LayerList& reuseList = listOfLayersWithSize(size, MarkAsUsed);
     if (reuseList.isEmpty())
         return nil;
@@ -106,7 +106,7 @@ RetainPtr<LegacyTileLayer> LegacyTileLayerPool::takeLayerWithSize(const IntSize&
 
 void LegacyTileLayerPool::setCapacity(unsigned capacity)
 {
-    MutexLocker reuseLocker(m_layerPoolMutex);
+    LockHolder reuseLocker(m_layerPoolMutex);
     if (capacity < m_capacity)
         schedulePrune();
     m_capacity = capacity;
@@ -136,7 +136,7 @@ void LegacyTileLayerPool::schedulePrune()
 
 void LegacyTileLayerPool::prune()
 {
-    MutexLocker locker(m_layerPoolMutex);
+    LockHolder locker(m_layerPoolMutex);
     ASSERT(m_needsPrune);
     m_needsPrune = false;
     unsigned shrinkTo = decayedCapacity();
@@ -163,7 +163,7 @@ void LegacyTileLayerPool::prune()
 
 void LegacyTileLayerPool::drain()
 {
-    MutexLocker reuseLocker(m_layerPoolMutex);
+    LockHolder reuseLocker(m_layerPoolMutex);
     m_reuseLists.clear();
     m_sizesInPruneOrder.clear();
     m_totalBytes = 0;
index e4d9f62..c6bfb30 100644 (file)
@@ -60,7 +60,7 @@ CurlDownloadManager::~CurlDownloadManager()
 
 bool CurlDownloadManager::add(CURL* curlHandle)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     m_pendingHandleList.append(curlHandle);
     startThreadIfNeeded();
@@ -70,7 +70,7 @@ bool CurlDownloadManager::add(CURL* curlHandle)
 
 bool CurlDownloadManager::remove(CURL* curlHandle)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     m_removedHandleList.append(curlHandle);
 
@@ -79,13 +79,13 @@ bool CurlDownloadManager::remove(CURL* curlHandle)
 
 int CurlDownloadManager::getActiveDownloadCount() const
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     return m_activeHandleList.size();
 }
 
 int CurlDownloadManager::getPendingDownloadCount() const
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     return m_pendingHandleList.size();
 }
 
@@ -111,7 +111,7 @@ void CurlDownloadManager::stopThread()
 
 void CurlDownloadManager::stopThreadIfIdle()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     if (!getActiveDownloadCount() && !getPendingDownloadCount())
         setRunThread(false);
@@ -119,7 +119,7 @@ void CurlDownloadManager::stopThreadIfIdle()
 
 void CurlDownloadManager::updateHandleList()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     // Remove curl easy handles from multi list 
     int size = m_removedHandleList.size();
@@ -245,7 +245,7 @@ CurlDownload::CurlDownload()
 
 CurlDownload::~CurlDownload()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     if (m_url)
         fastFree(m_url);
@@ -262,7 +262,7 @@ void CurlDownload::init(CurlDownloadListener* listener, const URL& url)
     if (!listener)
         return;
 
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     m_curlHandle = curl_easy_init();
 
@@ -295,7 +295,7 @@ void CurlDownload::init(CurlDownloadListener* listener, ResourceHandle*, const R
     if (!listener)
         return;
 
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     URL url(ParsedURLString, request.url());
 
@@ -317,25 +317,25 @@ bool CurlDownload::cancel()
 
 String CurlDownload::getTempPath() const
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     return m_tempPath;
 }
 
 String CurlDownload::getUrl() const
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     return String(m_url);
 }
 
 ResourceResponse CurlDownload::getResponse() const
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
     return m_response;
 }
 
 void CurlDownload::closeFile()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     if (m_tempHandle != invalidPlatformFileHandle) {
         WebCore::closeFile(m_tempHandle);
@@ -390,7 +390,7 @@ void CurlDownload::addHeaders(const ResourceRequest& request)
 
 void CurlDownload::didReceiveHeader(const String& header)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     if (header == "\r\n" || header == "\n") {
 
@@ -430,7 +430,7 @@ void CurlDownload::didReceiveHeader(const String& header)
 
 void CurlDownload::didReceiveData(void* data, int size)
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     RefPtr<CurlDownload> protectedDownload(this);
 
@@ -464,7 +464,7 @@ void CurlDownload::didFinish()
 
 void CurlDownload::didFail()
 {
-    MutexLocker locker(m_mutex);
+    LockHolder locker(m_mutex);
 
     closeFile();
 
index 64ba8a5..8775451 100644 (file)
@@ -73,7 +73,7 @@ private:
     Vector<CURL*> m_pendingHandleList;
     Vector<CURL*> m_activeHandleList;
     Vector<CURL*> m_removedHandleList;
-    mutable Mutex m_mutex;
+    mutable Lock m_mutex;
     bool m_runThread;
 };
 
@@ -140,7 +140,7 @@ private:
     WebCore::PlatformFileHandle m_tempHandle;
     WebCore::ResourceResponse m_response;
     bool m_deletesFileUponFailure;
-    mutable Mutex m_mutex;
+    mutable Lock m_mutex;
     CurlDownloadListener *m_listener;
 
     static CurlDownloadManager m_downloadManager;
index ef7e7d9..e40987e 100644 (file)
@@ -133,10 +133,11 @@ static char* cookieJarPath()
 #endif
 }
 
-static Mutex* sharedResourceMutex(curl_lock_data data) {
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, cookieMutex, ());
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, dnsMutex, ());
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, shareMutex, ());
+static Lock* sharedResourceMutex(curl_lock_data data)
+{
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, cookieMutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, dnsMutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, shareMutex, ());
 
     switch (data) {
         case CURL_LOCK_DATA_COOKIE:
@@ -190,13 +191,13 @@ static void calculateWebTimingInformations(ResourceHandleInternal* d)
 // cache.
 static void curl_lock_callback(CURL* /* handle */, curl_lock_data data, curl_lock_access /* access */, void* /* userPtr */)
 {
-    if (Mutex* mutex = sharedResourceMutex(data))
+    if (Lock* mutex = sharedResourceMutex(data))
         mutex->lock();
 }
 
 static void curl_unlock_callback(CURL* /* handle */, curl_lock_data data, void* /* userPtr */)
 {
-    if (Mutex* mutex = sharedResourceMutex(data))
+    if (Lock* mutex = sharedResourceMutex(data))
         mutex->unlock();
 }
 
index fcfd909..17ed864 100644 (file)
@@ -85,9 +85,9 @@ NSDictionary *WebCore::QLDirectoryAttributes()
     return dictionary;
 }
 
-static Mutex& qlPreviewConverterDictionaryMutex()
+static Lock& qlPreviewConverterDictionaryMutex()
 {
-    static NeverDestroyed<Mutex> mutex;
+    static NeverDestroyed<Lock> mutex;
     return mutex;
 }
 
@@ -107,7 +107,7 @@ void WebCore::addQLPreviewConverterWithFileForURL(NSURL *url, id converter, NSSt
 {
     ASSERT(url);
     ASSERT(converter);
-    MutexLocker lock(qlPreviewConverterDictionaryMutex());
+    LockHolder lock(qlPreviewConverterDictionaryMutex());
     [QLPreviewConverterDictionary() setObject:converter forKey:url];
     [QLContentDictionary() setObject:(fileName ? fileName : @"") forKey:url];
 }
@@ -121,7 +121,7 @@ NSString *WebCore::qlPreviewConverterUTIForURL(NSURL *url)
 {
     id converter = nil;
     {
-        MutexLocker lock(qlPreviewConverterDictionaryMutex());
+        LockHolder lock(qlPreviewConverterDictionaryMutex());
         converter = [QLPreviewConverterDictionary() objectForKey:url];
     }
     if (!converter)
@@ -131,7 +131,7 @@ NSString *WebCore::qlPreviewConverterUTIForURL(NSURL *url)
 
 void WebCore::removeQLPreviewConverterForURL(NSURL *url)
 {
-    MutexLocker lock(qlPreviewConverterDictionaryMutex());
+    LockHolder lock(qlPreviewConverterDictionaryMutex());
     [QLPreviewConverterDictionary() removeObjectForKey:url];
 
     // Delete the file when we remove the preview converter
@@ -166,7 +166,7 @@ const URL WebCore::safeQLURLForDocumentURLAndResourceURL(const URL& documentURL,
     id converter = nil;
     NSURL *nsDocumentURL = documentURL;
     {
-        MutexLocker lock(qlPreviewConverterDictionaryMutex());
+        LockHolder lock(qlPreviewConverterDictionaryMutex());
         converter = [QLPreviewConverterDictionary() objectForKey:nsDocumentURL];
     }
 
index 6c8eb34..c6fa58f 100644 (file)
@@ -120,7 +120,7 @@ void SQLiteDatabase::close()
         // ASSERT(currentThread() == m_openingThread);
         sqlite3* db = m_db;
         {
-            MutexLocker locker(m_databaseClosingMutex);
+            LockHolder locker(m_databaseClosingMutex);
             m_db = 0;
         }
         sqlite3_close(db);
@@ -160,7 +160,7 @@ int64_t SQLiteDatabase::maximumSize()
     int64_t maxPageCount = 0;
 
     {
-        MutexLocker locker(m_authorizerLock);
+        LockHolder locker(m_authorizerLock);
         enableAuthorizer(false);
         SQLiteStatement statement(*this, ASCIILiteral("PRAGMA max_page_count"));
         maxPageCount = statement.getColumnInt64(0);
@@ -180,7 +180,7 @@ void SQLiteDatabase::setMaximumSize(int64_t size)
     ASSERT(currentPageSize || !m_db);
     int64_t newMaxPageCount = currentPageSize ? size / currentPageSize : 0;
     
-    MutexLocker locker(m_authorizerLock);
+    LockHolder locker(m_authorizerLock);
     enableAuthorizer(false);
 
     SQLiteStatement statement(*this, "PRAGMA max_page_count = " + String::number(newMaxPageCount));
@@ -197,7 +197,7 @@ int SQLiteDatabase::pageSize()
     // Since the page size of a database is locked in at creation and therefore cannot be dynamic, 
     // we can cache the value for future use
     if (m_pageSize == -1) {
-        MutexLocker locker(m_authorizerLock);
+        LockHolder locker(m_authorizerLock);
         enableAuthorizer(false);
         
         SQLiteStatement statement(*this, ASCIILiteral("PRAGMA page_size"));
@@ -214,7 +214,7 @@ int64_t SQLiteDatabase::freeSpaceSize()
     int64_t freelistCount = 0;
 
     {
-        MutexLocker locker(m_authorizerLock);
+        LockHolder locker(m_authorizerLock);
         enableAuthorizer(false);
         // Note: freelist_count was added in SQLite 3.4.1.
         SQLiteStatement statement(*this, ASCIILiteral("PRAGMA freelist_count"));
@@ -230,7 +230,7 @@ int64_t SQLiteDatabase::totalSize()
     int64_t pageCount = 0;
 
     {
-        MutexLocker locker(m_authorizerLock);
+        LockHolder locker(m_authorizerLock);
         enableAuthorizer(false);
         SQLiteStatement statement(*this, ASCIILiteral("PRAGMA page_count"));
         pageCount = statement.getColumnInt64(0);
@@ -309,7 +309,7 @@ int SQLiteDatabase::runVacuumCommand()
 
 int SQLiteDatabase::runIncrementalVacuumCommand()
 {
-    MutexLocker locker(m_authorizerLock);
+    LockHolder locker(m_authorizerLock);
     enableAuthorizer(false);
 
     if (!executeCommand(ASCIILiteral("PRAGMA incremental_vacuum")))
@@ -450,7 +450,7 @@ void SQLiteDatabase::setAuthorizer(PassRefPtr<DatabaseAuthorizer> auth)
         return;
     }
 
-    MutexLocker locker(m_authorizerLock);
+    LockHolder locker(m_authorizerLock);
 
     m_authorizer = auth;
     
index ff09bd3..639a8a7 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <functional>
 #include <sqlite3.h>
+#include <wtf/Lock.h>
 #include <wtf/Threading.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
@@ -106,7 +107,7 @@ public:
     
     void setAuthorizer(PassRefPtr<DatabaseAuthorizer>);
 
-    Mutex& databaseMutex() { return m_lockingMutex; }
+    Lock& databaseMutex() { return m_lockingMutex; }
     bool isAutoCommitOn() const;
 
     // The SQLite AUTO_VACUUM pragma can be either NONE, FULL, or INCREMENTAL.
@@ -147,13 +148,13 @@ private:
     bool m_transactionInProgress;
     bool m_sharable;
     
-    Mutex m_authorizerLock;
+    Lock m_authorizerLock;
     RefPtr<DatabaseAuthorizer> m_authorizer;
 
-    Mutex m_lockingMutex;
+    Lock m_lockingMutex;
     ThreadIdentifier m_openingThread;
 
-    Mutex m_databaseClosingMutex;
+    Lock m_databaseClosingMutex;
 
     int m_openError;
     CString m_openErrorMessage;
index 7e094b8..135c00b 100644 (file)
@@ -59,7 +59,7 @@ int SQLiteStatement::prepare()
 {
     ASSERT(!m_isPrepared);
 
-    MutexLocker databaseLock(m_database.databaseMutex());
+    LockHolder databaseLock(m_database.databaseMutex());
 
     CString query = m_query.stripWhiteSpace().utf8();
     
@@ -86,7 +86,7 @@ int SQLiteStatement::prepare()
 
 int SQLiteStatement::step()
 {
-    MutexLocker databaseLock(m_database.databaseMutex());
+    LockHolder databaseLock(m_database.databaseMutex());
 
     if (!m_statement)
         return SQLITE_OK;
index e515552..b8d01ec 100644 (file)
@@ -122,7 +122,7 @@ WorkerThread::~WorkerThread()
 bool WorkerThread::start()
 {
     // Mutex protection is necessary to ensure that m_threadID is initialized when the thread starts.
-    MutexLocker lock(m_threadCreationMutex);
+    LockHolder lock(m_threadCreationMutex);
 
     if (m_threadID)
         return true;
@@ -145,7 +145,7 @@ void WorkerThread::workerThread()
 #endif
 
     {
-        MutexLocker lock(m_threadCreationMutex);
+        LockHolder lock(m_threadCreationMutex);
         m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType, m_startupData->m_topOrigin.release());
 
         if (m_runLoop.terminated()) {
@@ -189,7 +189,7 @@ void WorkerThread::runEventLoop()
 void WorkerThread::stop()
 {
     // Mutex protection is necessary because stop() can be called before the context is fully created.
-    MutexLocker lock(m_threadCreationMutex);
+    LockHolder lock(m_threadCreationMutex);
 
     // Ensure that tasks are being handled by thread event loop. If script execution weren't forbidden, a while(1) loop in JS could keep the thread alive forever.
     if (m_workerGlobalScope) {
index 41ea3b0..627baae 100644 (file)
@@ -89,7 +89,7 @@ namespace WebCore {
         WorkerReportingProxy& m_workerReportingProxy;
 
         RefPtr<WorkerGlobalScope> m_workerGlobalScope;
-        Mutex m_threadCreationMutex;
+        Lock m_threadCreationMutex;
 
         std::unique_ptr<WorkerThreadStartupData> m_startupData;
 
index 359b60a..c6873f7 100644 (file)
@@ -1,3 +1,33 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        * Storage/StorageAreaSync.cpp:
+        (WebCore::StorageAreaSync::syncTimerFired):
+        (WebCore::StorageAreaSync::markImported):
+        (WebCore::StorageAreaSync::blockUntilImportComplete):
+        (WebCore::StorageAreaSync::performSync):
+        * Storage/StorageAreaSync.h:
+        * Storage/StorageTracker.cpp:
+        (WebCore::StorageTracker::setDatabaseDirectoryPath):
+        (WebCore::StorageTracker::finishedImportingOriginIdentifiers):
+        (WebCore::StorageTracker::syncImportOriginIdentifiers):
+        (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase):
+        (WebCore::StorageTracker::setOriginDetails):
+        (WebCore::StorageTracker::syncSetOriginDetails):
+        (WebCore::StorageTracker::origins):
+        (WebCore::StorageTracker::deleteAllOrigins):
+        (WebCore::StorageTracker::syncDeleteAllOrigins):
+        (WebCore::StorageTracker::deleteOrigin):
+        (WebCore::StorageTracker::syncDeleteOrigin):
+        (WebCore::StorageTracker::canDeleteOrigin):
+        (WebCore::StorageTracker::cancelDeletingOrigin):
+        (WebCore::StorageTracker::diskUsageForOrigin):
+        * Storage/StorageTracker.h:
+
 2015-08-17  Alex Christensen  <achristensen@webkit.org>
 
         [Win CMake] Allow WebKitLibraries directory to be set from the command line
index ba17f18..b5ccf5b 100644 (file)
@@ -164,7 +164,7 @@ void StorageAreaSync::syncTimerFired()
 
     bool partialSync = false;
     {
-        MutexLocker locker(m_syncLock);
+        LockHolder locker(m_syncLock);
 
         // Do not schedule another sync if we're still trying to complete the
         // previous one. But, if we're shutting down, schedule it anyway.
@@ -352,9 +352,9 @@ void StorageAreaSync::performImport()
 
 void StorageAreaSync::markImported()
 {
-    MutexLocker locker(m_importLock);
+    LockHolder locker(m_importLock);
     m_importComplete = true;
-    m_importCondition.signal();
+    m_importCondition.notifyOne();
 }
 
 // FIXME: In the future, we should allow use of StorageAreas while it's importing (when safe to do so).
@@ -372,7 +372,7 @@ void StorageAreaSync::blockUntilImportComplete()
     if (!m_storageArea)
         return;
 
-    MutexLocker locker(m_importLock);
+    LockHolder locker(m_importLock);
     while (!m_importComplete)
         m_importCondition.wait(m_importLock);
     m_storageArea = nullptr;
@@ -467,7 +467,7 @@ void StorageAreaSync::performSync()
     bool clearItems;
     HashMap<String, String> items;
     {
-        MutexLocker locker(m_syncLock);
+        LockHolder locker(m_syncLock);
 
         ASSERT(m_syncScheduled);
 
@@ -482,7 +482,7 @@ void StorageAreaSync::performSync()
     sync(clearItems, items);
 
     {
-        MutexLocker locker(m_syncLock);
+        LockHolder locker(m_syncLock);
         m_syncInProgress = false;
     }
 
index 8fbf75b..b3ca89a 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <WebCore/SQLiteDatabase.h>
 #include <WebCore/Timer.h>
+#include <wtf/Condition.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/StringHash.h>
 
@@ -85,7 +86,7 @@ private:
 
     const String m_databaseIdentifier;
 
-    Mutex m_syncLock;
+    Lock m_syncLock;
     HashMap<String, String> m_itemsPendingSync;
     bool m_clearItemsWhileSyncing;
     bool m_syncScheduled;
@@ -94,8 +95,8 @@ private:
 
     bool m_syncCloseDatabase;
 
-    mutable Mutex m_importLock;
-    ThreadCondition m_importCondition;
+    mutable Lock m_importLock;
+    Condition m_importCondition;
     bool m_importComplete;
     void markImported();
     void migrateItemTableIfNeeded();
index 9fc09ba..6aae17e 100644 (file)
@@ -100,7 +100,7 @@ StorageTracker::StorageTracker(const String& storagePath)
 
 void StorageTracker::setDatabaseDirectoryPath(const String& path)
 {
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
 
     if (m_database.isOpen())
         m_database.close();
@@ -108,7 +108,7 @@ void StorageTracker::setDatabaseDirectoryPath(const String& path)
     m_storageDirectoryPath = path.isolatedCopy();
 
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         m_originSet.clear();
     }
 
@@ -185,7 +185,7 @@ void StorageTracker::importOriginIdentifiers()
 
 void StorageTracker::finishedImportingOriginIdentifiers()
 {
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
     if (m_client)
         m_client->didFinishLoadingOrigins();
 }
@@ -197,7 +197,7 @@ void StorageTracker::syncImportOriginIdentifiers()
     ASSERT(!isMainThread());
 
     {
-        MutexLocker locker(m_databaseMutex);
+        LockHolder locker(m_databaseMutex);
 
         // Don't force creation of StorageTracker's db just because a tracker
         // was initialized. It will be created if local storage dbs are found
@@ -217,7 +217,7 @@ void StorageTracker::syncImportOriginIdentifiers()
             int result;
             
             {
-                MutexLocker lockOrigins(m_originSetMutex);
+                LockHolder lockOrigins(m_originSetMutex);
                 while ((result = statement.step()) == SQLITE_ROW)
                     m_originSet.add(statement.getColumnText(0).isolatedCopy());
             }
@@ -232,10 +232,10 @@ void StorageTracker::syncImportOriginIdentifiers()
     syncFileSystemAndTrackerDatabase();
     
     {
-        MutexLocker locker(m_clientMutex);
+        LockHolder locker(m_clientMutex);
 
         if (m_client) {
-            MutexLocker locker(m_originSetMutex);
+            LockHolder locker(m_originSetMutex);
             OriginSet::const_iterator end = m_originSet.end();
             for (OriginSet::const_iterator it = m_originSet.begin(); it != end; ++it)
                 m_client->dispatchDidModifyOrigin(*it);
@@ -257,7 +257,7 @@ void StorageTracker::syncFileSystemAndTrackerDatabase()
 
     Vector<String> paths;
     {
-        MutexLocker locker(m_databaseMutex);
+        LockHolder locker(m_databaseMutex);
         paths = listDirectory(m_storageDirectoryPath, "*.localstorage");
     }
 
@@ -265,7 +265,7 @@ void StorageTracker::syncFileSystemAndTrackerDatabase()
     // deletions from disk and from m_originSet.
     OriginSet originSetCopy;
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         for (OriginSet::const_iterator it = m_originSet.begin(), end = m_originSet.end(); it != end; ++it)
             originSetCopy.add((*it).isolatedCopy());
     }
@@ -306,7 +306,7 @@ void StorageTracker::setOriginDetails(const String& originIdentifier, const Stri
         return;
 
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
 
         if (m_originSet.contains(originIdentifier))
             return;
@@ -337,7 +337,7 @@ void StorageTracker::syncSetOriginDetails(const String& originIdentifier, const
 
     SQLiteTransactionInProgressAutoCounter transactionCounter;
 
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
 
     openTrackerDatabase(true);
     
@@ -357,13 +357,13 @@ void StorageTracker::syncSetOriginDetails(const String& originIdentifier, const
         LOG_ERROR("Unable to establish origin '%s' in the tracker", originIdentifier.ascii().data());
 
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         if (!m_originSet.contains(originIdentifier))
             m_originSet.add(originIdentifier);
     }
 
     {
-        MutexLocker locker(m_clientMutex);
+        LockHolder locker(m_clientMutex);
         if (m_client)
             m_client->dispatchDidModifyOrigin(originIdentifier);
     }
@@ -376,7 +376,7 @@ void StorageTracker::origins(Vector<RefPtr<SecurityOrigin>>& result)
     if (!m_isActive)
         return;
 
-    MutexLocker locker(m_originSetMutex);
+    LockHolder locker(m_originSetMutex);
 
     for (OriginSet::const_iterator it = m_originSet.begin(), end = m_originSet.end(); it != end; ++it)
         result.append(SecurityOrigin::createFromDatabaseIdentifier(*it));
@@ -392,7 +392,7 @@ void StorageTracker::deleteAllOrigins()
         return;
 
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         willDeleteAllOrigins();
         m_originSet.clear();
     }
@@ -417,7 +417,7 @@ void StorageTracker::syncDeleteAllOrigins()
 
     SQLiteTransactionInProgressAutoCounter transactionCounter;
     
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
     
     openTrackerDatabase(false);
     if (!m_database.isOpen())
@@ -437,7 +437,7 @@ void StorageTracker::syncDeleteAllOrigins()
         deleteFile(statement.getColumnText(1));
 
         {
-            MutexLocker locker(m_clientMutex);
+            LockHolder locker(m_clientMutex);
             if (m_client)
                 m_client->dispatchDidModifyOrigin(statement.getColumnText(0));
         }
@@ -499,7 +499,7 @@ void StorageTracker::deleteOrigin(SecurityOrigin* origin)
     String originId = origin->databaseIdentifier();
     
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         willDeleteOrigin(originId);
         m_originSet.remove(originId);
     }
@@ -516,7 +516,7 @@ void StorageTracker::syncDeleteOrigin(const String& originIdentifier)
 
     SQLiteTransactionInProgressAutoCounter transactionCounter;
 
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
     
     if (!canDeleteOrigin(originIdentifier)) {
         LOG_ERROR("Attempted to delete origin '%s' while it was being created\n", originIdentifier.ascii().data());
@@ -549,7 +549,7 @@ void StorageTracker::syncDeleteOrigin(const String& originIdentifier)
     
     bool shouldDeleteTrackerFiles = false;
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         m_originSet.remove(originIdentifier);
         shouldDeleteTrackerFiles = m_originSet.isEmpty();
     }
@@ -566,7 +566,7 @@ void StorageTracker::syncDeleteOrigin(const String& originIdentifier)
     }
 
     {
-        MutexLocker locker(m_clientMutex);
+        LockHolder locker(m_clientMutex);
         if (m_client)
             m_client->dispatchDidModifyOrigin(originIdentifier);
     }
@@ -592,7 +592,7 @@ void StorageTracker::willDeleteOrigin(const String& originIdentifier)
 bool StorageTracker::canDeleteOrigin(const String& originIdentifier)
 {
     ASSERT(!m_databaseMutex.tryLock());
-    MutexLocker locker(m_originSetMutex);
+    LockHolder locker(m_originSetMutex);
     return m_originsBeingDeleted.contains(originIdentifier);
 }
 
@@ -601,9 +601,9 @@ void StorageTracker::cancelDeletingOrigin(const String& originIdentifier)
     if (!m_isActive)
         return;
 
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
     {
-        MutexLocker locker(m_originSetMutex);
+        LockHolder locker(m_originSetMutex);
         if (!m_originsBeingDeleted.isEmpty())
             m_originsBeingDeleted.remove(originIdentifier);
     }
@@ -647,7 +647,7 @@ long long StorageTracker::diskUsageForOrigin(SecurityOrigin* origin)
     if (!m_isActive)
         return 0;
 
-    MutexLocker locker(m_databaseMutex);
+    LockHolder locker(m_databaseMutex);
 
     String path = databasePathForOrigin(origin->databaseIdentifier());
     if (path.isEmpty())
index a770593..a999da2 100644 (file)
@@ -95,15 +95,15 @@ private:
     void syncImportOriginIdentifiers();
 
     // Mutex for m_database and m_storageDirectoryPath.
-    Mutex m_databaseMutex;
+    Lock m_databaseMutex;
     SQLiteDatabase m_database;
     String m_storageDirectoryPath;
 
-    Mutex m_clientMutex;
+    Lock m_clientMutex;
     StorageTrackerClient* m_client;
 
     // Guard for m_originSet and m_originsBeingDeleted.
-    Mutex m_originSetMutex;
+    Lock m_originSetMutex;
     typedef HashSet<String> OriginSet;
     OriginSet m_originSet;
     OriginSet m_originsBeingDeleted;
index d13efcc..d4a4683 100644 (file)
@@ -1,3 +1,18 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        * WebCoreSupport/WebFixedPositionContent.mm:
+        (WebFixedPositionContentDataLock):
+        (-[WebFixedPositionContent scrollOrZoomChanged:]):
+        (-[WebFixedPositionContent overflowScrollPositionForLayer:changedTo:]):
+        (-[WebFixedPositionContent setViewportConstrainedLayers:stickyContainerMap:]):
+        (-[WebFixedPositionContent hasFixedOrStickyPositionLayers]):
+        (-[WebFixedPositionContent minimumOffsetFromFixedPositionLayersToAnchorEdge:ofRect:inLayer:]):
+
 2015-08-13  Tim Horton  <timothy_horton@apple.com>
 
         Refactor and improve TextIndicator to prepare for tests
index f8b610b..d518b55 100644 (file)
@@ -48,9 +48,9 @@
 using namespace WebCore;
 using namespace std;
 
-static Mutex& WebFixedPositionContentDataLock()
+static Lock& WebFixedPositionContentDataLock()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, mutex, ());
     return mutex;
 }
 
@@ -101,7 +101,7 @@ WebFixedPositionContentData::~WebFixedPositionContentData()
 
 - (void)scrollOrZoomChanged:(CGRect)positionedObjectsRect
 {
-    MutexLocker lock(WebFixedPositionContentDataLock());
+    LockHolder lock(WebFixedPositionContentDataLock());
 
     LayerInfoMap::const_iterator end = _private->m_viewportConstrainedLayers.end();
     for (LayerInfoMap::const_iterator it = _private->m_viewportConstrainedLayers.begin(); it != end; ++it) {
@@ -140,7 +140,7 @@ WebFixedPositionContentData::~WebFixedPositionContentData()
 
 - (void)overflowScrollPositionForLayer:(CALayer *)scrollLayer changedTo:(CGPoint)scrollPosition
 {
-    MutexLocker lock(WebFixedPositionContentDataLock());
+    LockHolder lock(WebFixedPositionContentDataLock());
 
     LayerInfoMap::const_iterator end = _private->m_viewportConstrainedLayers.end();
     for (LayerInfoMap::const_iterator it = _private->m_viewportConstrainedLayers.begin(); it != end; ++it) {
@@ -173,7 +173,7 @@ WebFixedPositionContentData::~WebFixedPositionContentData()
 
 - (void)setViewportConstrainedLayers:(WTF::HashMap<CALayer *, std::unique_ptr<WebCore::ViewportConstraints>>&)layerMap stickyContainerMap:(WTF::HashMap<CALayer*, CALayer*>&)stickyContainers
 {
-    MutexLocker lock(WebFixedPositionContentDataLock());
+    LockHolder lock(WebFixedPositionContentDataLock());
 
     _private->m_viewportConstrainedLayers.clear();
 
@@ -190,7 +190,7 @@ WebFixedPositionContentData::~WebFixedPositionContentData()
 
 - (BOOL)hasFixedOrStickyPositionLayers
 {
-    MutexLocker lock(WebFixedPositionContentDataLock());
+    LockHolder lock(WebFixedPositionContentDataLock());
     return !_private->m_viewportConstrainedLayers.isEmpty();
 }
 
@@ -210,7 +210,7 @@ static ViewportConstraints::AnchorEdgeFlags anchorEdgeFlagsForAnchorEdge(WebFixe
 
 - (CGFloat)minimumOffsetFromFixedPositionLayersToAnchorEdge:(WebFixedPositionAnchorEdge)anchorEdge ofRect:(CGRect)rect inLayer:(CALayer *)layer
 {
-    MutexLocker lock(WebFixedPositionContentDataLock());
+    LockHolder lock(WebFixedPositionContentDataLock());
     ViewportConstraints::AnchorEdgeFlags anchorEdgeFlags = anchorEdgeFlagsForAnchorEdge(anchorEdge);
     CGFloat minimumOffset = CGFLOAT_MAX;
     LayerInfoMap::const_iterator end = _private->m_viewportConstrainedLayers.end();
index 08892a6..6bd955a 100644 (file)
@@ -1,3 +1,21 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        * Storage/WebDatabaseManager.mm:
+        (transactionBackgroundTaskIdentifierLock):
+        (+[WebDatabaseManager startBackgroundTask]):
+        (+[WebDatabaseManager endBackgroundTask]):
+        * WebView/WebView.mm:
+        (-[WebView _synchronizeCustomFixedPositionLayoutRect]):
+        (-[WebView _setCustomFixedPositionLayoutRectInWebThread:synchronize:]):
+        (-[WebView _setCustomFixedPositionLayoutRect:]):
+        (-[WebView _fetchCustomFixedPositionLayoutRect:]):
+        * WebView/WebViewData.h:
+
 2015-08-17  Jeff Miller  <jeffm@apple.com>
 
         Add a method to WebInspector to indicate whether the inspector is open
index aa23608..3f787c1 100644 (file)
@@ -226,9 +226,9 @@ static bool isFileHidden(NSString *file)
 #if PLATFORM(IOS)
 @implementation WebDatabaseManager (WebDatabaseManagerInternal)
 
-static Mutex& transactionBackgroundTaskIdentifierLock()
+static Lock& transactionBackgroundTaskIdentifierLock()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, mutex, ());
     return mutex;
 }
 
@@ -261,7 +261,7 @@ static WebBackgroundTaskIdentifier getTransactionBackgroundTaskIdentifier()
 
 + (void)startBackgroundTask
 {
-    MutexLocker lock(transactionBackgroundTaskIdentifierLock());
+    LockHolder lock(transactionBackgroundTaskIdentifierLock());
 
     // If there's already an existing background task going on, there's no need to start a new one.
     if (getTransactionBackgroundTaskIdentifier() != invalidWebBackgroundTaskIdentifier())
@@ -275,7 +275,7 @@ static WebBackgroundTaskIdentifier getTransactionBackgroundTaskIdentifier()
 
 + (void)endBackgroundTask
 {
-    MutexLocker lock(transactionBackgroundTaskIdentifierLock());
+    LockHolder lock(transactionBackgroundTaskIdentifierLock());
 
     // It is possible that we were unable to start the background task when the first transaction began.
     // Don't try to end the task in that case.
index 510151b..8f15db5 100644 (file)
@@ -3632,7 +3632,7 @@ static inline IMP getMethod(id o, SEL s)
 
     IntRect newRect;
     {
-        MutexLocker locker(_private->pendingFixedPositionLayoutRectMutex);
+        LockHolder locker(_private->pendingFixedPositionLayoutRectMutex);
         if (CGRectIsNull(_private->pendingFixedPositionLayoutRect))
             return;
         newRect = enclosingIntRect(_private->pendingFixedPositionLayoutRect);
@@ -3646,7 +3646,7 @@ static inline IMP getMethod(id o, SEL s)
 - (void)_setCustomFixedPositionLayoutRectInWebThread:(CGRect)rect synchronize:(BOOL)synchronize
 {
     {
-        MutexLocker locker(_private->pendingFixedPositionLayoutRectMutex);
+        LockHolder locker(_private->pendingFixedPositionLayoutRectMutex);
         _private->pendingFixedPositionLayoutRect = rect;
     }
     if (!synchronize)
@@ -3660,7 +3660,7 @@ static inline IMP getMethod(id o, SEL s)
 {
     ASSERT(WebThreadIsLocked());
     {
-        MutexLocker locker(_private->pendingFixedPositionLayoutRectMutex);
+        LockHolder locker(_private->pendingFixedPositionLayoutRectMutex);
         _private->pendingFixedPositionLayoutRect = rect;
     }
     [self _synchronizeCustomFixedPositionLayoutRect];
@@ -3668,7 +3668,7 @@ static inline IMP getMethod(id o, SEL s)
 
 - (BOOL)_fetchCustomFixedPositionLayoutRect:(NSRect*)rect
 {
-    MutexLocker locker(_private->pendingFixedPositionLayoutRectMutex);
+    LockHolder locker(_private->pendingFixedPositionLayoutRectMutex);
     if (CGRectIsNull(_private->pendingFixedPositionLayoutRect))
         return false;
 
index 31139b4..5df6d30 100644 (file)
@@ -34,6 +34,7 @@
 #import <WebCore/LayerFlushSchedulerClient.h>
 #import <WebCore/WebCoreKeyboardUIMode.h>
 #import <wtf/HashMap.h>
+#import <wtf/Lock.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/ThreadingPrimitives.h>
 #import <wtf/text/WTFString.h>
@@ -249,7 +250,7 @@ private:
     CGSize fixedLayoutSize;
     BOOL mainViewIsScrollingOrZooming;
     int32_t didDrawTiles;
-    WTF::Mutex pendingFixedPositionLayoutRectMutex;
+    WTF::Lock pendingFixedPositionLayoutRectMutex;
     CGRect pendingFixedPositionLayoutRect;
 #endif
 
index d82b55d..2f34d80 100644 (file)
@@ -1,3 +1,27 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        * Plugins/PluginMainThreadScheduler.cpp:
+        (WebCore::PluginMainThreadScheduler::scheduleCall):
+        (WebCore::PluginMainThreadScheduler::registerPlugin):
+        (WebCore::PluginMainThreadScheduler::unregisterPlugin):
+        (WebCore::PluginMainThreadScheduler::dispatchCallsForPlugin):
+        * Plugins/PluginMainThreadScheduler.h:
+        * WebIconDatabase.cpp:
+        (WebIconDatabase::didRemoveAllIcons):
+        (WebIconDatabase::didImportIconURLForPageURL):
+        (WebIconDatabase::deliverNotifications):
+        * WebIconDatabase.h:
+        * WebLocalizableStrings.cpp:
+        (mainBundleLocStrings):
+        (frameworkLocStringsMutex):
+        (findCachedString):
+        (cacheString):
+
 2015-08-17  Per Arne Vollan  <peavo@outlook.com>
 
         [WinCairo] Accelerated compositing does not respect device scale factor.
index 0ed9cce..a442e81 100644 (file)
@@ -42,7 +42,7 @@ PluginMainThreadScheduler::PluginMainThreadScheduler()
 
 void PluginMainThreadScheduler::scheduleCall(NPP npp, MainThreadFunction function, void* userData)
 {
-    MutexLocker lock(m_queueMutex);
+    LockHolder lock(m_queueMutex);
 
     CallQueueMap::iterator it = m_callQueueMap.find(npp);
     if (it == m_callQueueMap.end())
@@ -58,7 +58,7 @@ void PluginMainThreadScheduler::scheduleCall(NPP npp, MainThreadFunction functio
 
 void PluginMainThreadScheduler::registerPlugin(NPP npp)
 {
-    MutexLocker lock(m_queueMutex);
+    LockHolder lock(m_queueMutex);
 
     ASSERT(!m_callQueueMap.contains(npp));
     m_callQueueMap.set(npp, Deque<Call>());
@@ -66,7 +66,7 @@ void PluginMainThreadScheduler::registerPlugin(NPP npp)
 
 void PluginMainThreadScheduler::unregisterPlugin(NPP npp)
 {
-    MutexLocker lock(m_queueMutex);
+    LockHolder lock(m_queueMutex);
 
     ASSERT(m_callQueueMap.contains(npp));
     m_callQueueMap.remove(npp);
@@ -77,7 +77,7 @@ void PluginMainThreadScheduler::dispatchCallsForPlugin(NPP npp, const Deque<Call
     for (auto& call : calls) {
         // Check if the plug-in has been destroyed.
         {
-            MutexLocker lock(m_queueMutex);
+            LockHolder lock(m_queueMutex);
             if (!m_callQueueMap.contains(npp))
                 return;
         }
index 858e897..2577d8a 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <wtf/Deque.h>
 #include <wtf/HashMap.h>
+#include <wtf/Lock.h>
 #include <wtf/MainThread.h>
 #include <wtf/Threading.h>
 
@@ -79,7 +80,7 @@ private:
 
     bool m_callPending;
     CallQueueMap m_callQueueMap;
-    Mutex m_queueMutex;
+    Lock m_queueMutex;
 };
 
 } // namespace WebCore
index a5eb827..829a155 100644 (file)
@@ -320,14 +320,14 @@ HBITMAP WebIconDatabase::getOrCreateDefaultIconBitmap(const IntSize& size)
 void WebIconDatabase::didRemoveAllIcons()
 {
     // Queueing the empty string is a special way of saying "this queued notification is the didRemoveAllIcons notification"
-    MutexLocker locker(m_notificationMutex);
+    LockHolder locker(m_notificationMutex);
     m_notificationQueue.append(String());
     scheduleNotificationDelivery();
 }
 
 void WebIconDatabase::didImportIconURLForPageURL(const WTF::String& pageURL)
 {
-    MutexLocker locker(m_notificationMutex);
+    LockHolder locker(m_notificationMutex);
     m_notificationQueue.append(pageURL.isolatedCopy());
     scheduleNotificationDelivery();
 }
@@ -403,7 +403,7 @@ void WebIconDatabase::deliverNotifications(void*)
 
     Vector<String> queue;
     {
-        MutexLocker locker(m_sharedWebIconDatabase->m_notificationMutex);
+        LockHolder locker(m_sharedWebIconDatabase->m_notificationMutex);
         queue.swap(m_sharedWebIconDatabase->m_notificationQueue);
         m_sharedWebIconDatabase->m_deliveryRequested = false;
     }
index ee52b00..b289964 100644 (file)
@@ -31,8 +31,9 @@
 #include <WebCore/IconDatabaseClient.h>
 #include <WebCore/IntSize.h>
 #include <WebCore/IntSizeHash.h>
-#include <wtf/Vector.h>
+#include <wtf/Lock.h>
 #include <wtf/Threading.h>
+#include <wtf/Vector.h>
 
 #include <windows.h>
 
@@ -116,7 +117,7 @@ protected:
     HashMap<IntSize, HBITMAP> m_defaultIconMap;
     HashMap<IntSize, HBITMAP> m_sharedIconMap;
 
-    Mutex m_notificationMutex;
+    Lock m_notificationMutex;
     Vector<String> m_notificationQueue;
     void scheduleNotificationDelivery();
     bool m_deliveryRequested;
index c5cf29d..8ff0efc 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <wtf/Assertions.h>
 #include <wtf/HashMap.h>
+#include <wtf/Lock.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/ThreadingPrimitives.h>
@@ -44,9 +45,9 @@ WebLocalizableStringsBundle WebKitLocalizableStringsBundle = { "com.apple.WebKit
 
 typedef HashMap<String, LocalizedString*> LocalizedStringMap;
 
-static Mutex& mainBundleLocStringsMutex()
+static Lock& mainBundleLocStringsMutex()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, mutex, ());
     return mutex;
 }
 
@@ -56,9 +57,9 @@ static LocalizedStringMap& mainBundleLocStrings()
     return map;
 }
 
-static Mutex& frameworkLocStringsMutex()
+static Lock& frameworkLocStringsMutex()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, mutex, ());
     return mutex;
 }
 
@@ -175,12 +176,12 @@ static CFStringRef copyLocalizedStringFromBundle(WebLocalizableStringsBundle* st
 static LocalizedString* findCachedString(WebLocalizableStringsBundle* stringsBundle, const String& key)
 {
     if (!stringsBundle) {
-        MutexLocker lock(mainBundleLocStringsMutex());
+        LockHolder lock(mainBundleLocStringsMutex());
         return mainBundleLocStrings().get(key);
     }
 
     if (stringsBundle->bundle == WebKitLocalizableStringsBundle.bundle) {
-        MutexLocker lock(frameworkLocStringsMutex());
+        LockHolder lock(frameworkLocStringsMutex());
         return frameworkLocStrings().get(key);
     }
 
@@ -190,12 +191,12 @@ static LocalizedString* findCachedString(WebLocalizableStringsBundle* stringsBun
 static void cacheString(WebLocalizableStringsBundle* stringsBundle, const String& key, LocalizedString* value)
 {
     if (!stringsBundle) {
-        MutexLocker lock(mainBundleLocStringsMutex());
+        LockHolder lock(mainBundleLocStringsMutex());
         mainBundleLocStrings().set(key, value);
         return;
     }
 
-    MutexLocker lock(frameworkLocStringsMutex());
+    LockHolder lock(frameworkLocStringsMutex());
     frameworkLocStrings().set(key, value);
 }
 
index a866cab..fe65b99 100644 (file)
@@ -1,3 +1,59 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        * DatabaseProcess/DatabaseProcess.cpp:
+        (WebKit::DatabaseProcess::postDatabaseTask):
+        (WebKit::DatabaseProcess::performNextDatabaseTask):
+        * DatabaseProcess/DatabaseProcess.h:
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::shutdown):
+        (WebKit::UniqueIDBDatabase::postMainThreadTask):
+        (WebKit::UniqueIDBDatabase::performNextMainThreadTask):
+        (WebKit::UniqueIDBDatabase::postDatabaseTask):
+        (WebKit::UniqueIDBDatabase::performNextDatabaseTask):
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::sendSyncMessage):
+        (IPC::Connection::sendSyncMessageFromSecondaryThread):
+        (IPC::Connection::waitForSyncReply):
+        (IPC::Connection::processIncomingSyncReply):
+        (IPC::Connection::connectionDidClose):
+        * Platform/IPC/Connection.h:
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::CoordinatedGraphicsScene::appendUpdate):
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::createCompositingThread):
+        (WebKit::ThreadedCompositor::runCompositingThread):
+        (WebKit::ThreadedCompositor::terminateCompositingThread):
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm:
+        (WebKit::CustomProtocolManager::addCustomProtocol):
+        (WebKit::CustomProtocolManager::removeCustomProtocol):
+        (WebKit::CustomProtocolManager::registerScheme):
+        (WebKit::CustomProtocolManager::unregisterScheme):
+        (WebKit::CustomProtocolManager::supportsScheme):
+        (WebKit::CustomProtocolManager::protocolForID):
+        * Shared/Network/CustomProtocols/CustomProtocolManager.h:
+        * Shared/linux/SeccompFilters/SeccompBroker.cpp:
+        * WebProcess/Plugins/PluginProcessConnectionManager.cpp:
+        (WebKit::PluginProcessConnectionManager::getPluginProcessConnection):
+        (WebKit::PluginProcessConnectionManager::removePluginProcessConnection):
+        (WebKit::PluginProcessConnectionManager::pluginProcessCrashed):
+        * WebProcess/Plugins/PluginProcessConnectionManager.h:
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::addScrollingTreeForPage):
+        (WebKit::EventDispatcher::removeScrollingTreeForPage):
+        (WebKit::EventDispatcher::wheelEvent):
+        * WebProcess/WebPage/EventDispatcher.h:
+        * WebProcess/soup/WebKitSoupRequestInputStream.cpp:
+        (webkitSoupRequestInputStreamReadAsync):
+        (webkitSoupRequestInputStreamAddData):
+
 2015-08-17  Alex Christensen  <achristensen@webkit.org>
 
         Speculative GTK build fix after r188553
index 61653ca..f7611d4 100644 (file)
@@ -151,7 +151,7 @@ void DatabaseProcess::postDatabaseTask(std::unique_ptr<AsyncTask> task)
 {
     ASSERT(RunLoop::isMain());
 
-    MutexLocker locker(m_databaseTaskMutex);
+    LockHolder locker(m_databaseTaskMutex);
 
     m_databaseTasks.append(WTF::move(task));
 
@@ -166,7 +166,7 @@ void DatabaseProcess::performNextDatabaseTask()
 
     std::unique_ptr<AsyncTask> task;
     {
-        MutexLocker locker(m_databaseTaskMutex);
+        LockHolder locker(m_databaseTaskMutex);
         ASSERT(!m_databaseTasks.isEmpty());
         task = m_databaseTasks.takeFirst();
     }
index 47c6925..7ad6d68 100644 (file)
@@ -106,7 +106,7 @@ private:
     HashMap<UniqueIDBDatabaseIdentifier, RefPtr<UniqueIDBDatabase>> m_idbDatabases;
 
     Deque<std::unique_ptr<AsyncTask>> m_databaseTasks;
-    Mutex m_databaseTaskMutex;
+    Lock m_databaseTaskMutex;
 };
 
 } // namespace WebKit
index 3d2ca5b..1bdd3f9 100644 (file)
@@ -136,7 +136,7 @@ void UniqueIDBDatabase::shutdown(UniqueIDBDatabaseShutdownType type)
     ref();
 
     {
-        MutexLocker locker(m_databaseTaskMutex);
+        LockHolder locker(m_databaseTaskMutex);
         m_databaseTasks.clear();
     }
 
@@ -1125,7 +1125,7 @@ void UniqueIDBDatabase::postMainThreadTask(std::unique_ptr<AsyncTask> task, Data
     if (!m_acceptingNewRequests && taskType == DatabaseTaskType::Normal)
         return;
 
-    MutexLocker locker(m_mainThreadTaskMutex);
+    LockHolder locker(m_mainThreadTaskMutex);
 
     m_mainThreadTasks.append(WTF::move(task));
 
@@ -1143,7 +1143,7 @@ bool UniqueIDBDatabase::performNextMainThreadTask()
 
     std::unique_ptr<AsyncTask> task;
     {
-        MutexLocker locker(m_mainThreadTaskMutex);
+        LockHolder locker(m_mainThreadTaskMutex);
 
         // This database might be shutting down, in which case the task queue might be empty.
         if (m_mainThreadTasks.isEmpty())
@@ -1165,7 +1165,7 @@ void UniqueIDBDatabase::postDatabaseTask(std::unique_ptr<AsyncTask> task, Databa
     if (!m_acceptingNewRequests && taskType == DatabaseTaskType::Normal)
         return;
 
-    MutexLocker locker(m_databaseTaskMutex);
+    LockHolder locker(m_databaseTaskMutex);
 
     m_databaseTasks.append(WTF::move(task));
 
@@ -1186,7 +1186,7 @@ void UniqueIDBDatabase::performNextDatabaseTask()
 
     std::unique_ptr<AsyncTask> task;
     {
-        MutexLocker locker(m_databaseTaskMutex);
+        LockHolder locker(m_databaseTaskMutex);
 
         // This database might be shutting down on the main thread, in which case the task queue might be empty.
         if (m_databaseTasks.isEmpty())
index a204259..0a1ed96 100644 (file)
@@ -210,10 +210,10 @@ private:
     RefPtr<UniqueIDBDatabaseBackingStore> m_backingStore;
 
     Deque<std::unique_ptr<AsyncTask>> m_databaseTasks;
-    Mutex m_databaseTaskMutex;
+    Lock m_databaseTaskMutex;
 
     Deque<std::unique_ptr<AsyncTask>> m_mainThreadTasks;
-    Mutex m_mainThreadTaskMutex;
+    Lock m_mainThreadTaskMutex;
 };
 
 } // namespace WebKit
index 07a93b5..b60100b 100644 (file)
@@ -459,7 +459,7 @@ std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequest
 
     // Push the pending sync reply information on our stack.
     {
-        MutexLocker locker(m_syncReplyStateMutex);
+        LockHolder locker(m_syncReplyStateMutex);
         if (!m_shouldWaitForSyncReplies) {
             didFailToSendSyncMessage();
             return nullptr;
@@ -486,7 +486,7 @@ std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequest
 
     // Finally, pop the pending sync reply information.
     {
-        MutexLocker locker(m_syncReplyStateMutex);
+        LockHolder locker(m_syncReplyStateMutex);
         ASSERT(m_pendingSyncReplies.last().syncRequestID == syncRequestID);
         m_pendingSyncReplies.removeLast();
     }
@@ -508,7 +508,7 @@ std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(u
 
     // Push the pending sync reply information on our stack.
     {
-        MutexLocker locker(m_syncReplyStateMutex);
+        LockHolder locker(m_syncReplyStateMutex);
         if (!m_shouldWaitForSyncReplies)
             return nullptr;
 
@@ -526,7 +526,7 @@ std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(u
 
     // Finally, pop the pending sync reply information.
     {
-        MutexLocker locker(m_syncReplyStateMutex);
+        LockHolder locker(m_syncReplyStateMutex);
         ASSERT(m_secondaryThreadPendingSyncReplyMap.contains(syncRequestID));
         m_secondaryThreadPendingSyncReplyMap.remove(syncRequestID);
     }
@@ -546,7 +546,7 @@ std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncReques
         SyncMessageState::singleton().dispatchMessages(nullptr);
         
         {
-            MutexLocker locker(m_syncReplyStateMutex);
+            LockHolder locker(m_syncReplyStateMutex);
 
             // Second, check if there is a sync reply at the top of the stack.
             ASSERT(!m_pendingSyncReplies.isEmpty());
@@ -592,7 +592,7 @@ std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncReques
 
 void Connection::processIncomingSyncReply(std::unique_ptr<MessageDecoder> decoder)
 {
-    MutexLocker locker(m_syncReplyStateMutex);
+    LockHolder locker(m_syncReplyStateMutex);
 
     // Go through the stack of sync requests that have pending replies and see which one
     // this reply is for.
@@ -750,7 +750,7 @@ void Connection::connectionDidClose()
     platformInvalidate();
 
     {
-        MutexLocker locker(m_syncReplyStateMutex);
+        LockHolder locker(m_syncReplyStateMutex);
 
         ASSERT(m_shouldWaitForSyncReplies);
         m_shouldWaitForSyncReplies = false;
index 8d77cce..07fee21 100644 (file)
@@ -38,6 +38,7 @@
 #include <wtf/Deque.h>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
+#include <wtf/Lock.h>
 #include <wtf/WorkQueue.h>
 #include <wtf/text/CString.h>
 
@@ -298,7 +299,7 @@ private:
     class SyncMessageState;
     friend class SyncMessageState;
 
-    Mutex m_syncReplyStateMutex;
+    Lock m_syncReplyStateMutex;
     bool m_shouldWaitForSyncReplies;
     Vector<PendingSyncReply> m_pendingSyncReplies;
 
index 3b3fc77..deab047 100644 (file)
@@ -690,7 +690,7 @@ void CoordinatedGraphicsScene::appendUpdate(std::function<void()> function)
         return;
 
     ASSERT(isMainThread());
-    MutexLocker locker(m_renderQueueMutex);
+    LockHolder locker(m_renderQueueMutex);
     m_renderQueue.append(WTF::move(function));
 }
 
index f71719c..69065c9 100644 (file)
@@ -35,6 +35,7 @@
 #include <WebCore/Timer.h>
 #include <functional>
 #include <wtf/HashSet.h>
+#include <wtf/Lock.h>
 #include <wtf/RunLoop.h>
 #include <wtf/ThreadingPrimitives.h>
 #include <wtf/Vector.h>
@@ -145,7 +146,7 @@ private:
 
     // Render queue can be accessed ony from main thread or updatePaintNode call stack!
     Vector<std::function<void()>> m_renderQueue;
-    Mutex m_renderQueueMutex;
+    Lock m_renderQueueMutex;
 
     std::unique_ptr<WebCore::TextureMapper> m_textureMapper;
 
index c3bae6d..a6ae98a 100644 (file)
@@ -295,7 +295,7 @@ void ThreadedCompositor::createCompositingThread()
     if (m_threadIdentifier)
         return;
 
-    MutexLocker locker(m_initializeRunLoopConditionMutex);
+    LockHolder locker(m_initializeRunLoopConditionMutex);
     m_threadIdentifier = createThread(compositingThreadEntry, this, "WebCore: ThreadedCompositor");
 
     m_initializeRunLoopCondition.wait(m_initializeRunLoopConditionMutex);
@@ -304,7 +304,7 @@ void ThreadedCompositor::createCompositingThread()
 void ThreadedCompositor::runCompositingThread()
 {
     {
-        MutexLocker locker(m_initializeRunLoopConditionMutex);
+        LockHolder locker(m_initializeRunLoopConditionMutex);
 
         m_compositingRunLoop = std::make_unique<CompositingRunLoop>([&] {
             renderLayerTree();
@@ -321,7 +321,7 @@ void ThreadedCompositor::runCompositingThread()
     m_scene->purgeGLResources();
 
     {
-        MutexLocker locker(m_terminateRunLoopConditionMutex);
+        LockHolder locker(m_terminateRunLoopConditionMutex);
         m_compositingRunLoop = nullptr;
         m_context = nullptr;
         m_terminateRunLoopCondition.signal();
@@ -332,7 +332,7 @@ void ThreadedCompositor::runCompositingThread()
 
 void ThreadedCompositor::terminateCompositingThread()
 {
-    MutexLocker locker(m_terminateRunLoopConditionMutex);
+    LockHolder locker(m_terminateRunLoopConditionMutex);
 
     m_scene->detach();
     m_compositingRunLoop->runLoop().stop();
index 0d785ef..1d6c266 100644 (file)
@@ -111,9 +111,9 @@ private:
 
     ThreadIdentifier m_threadIdentifier;
     ThreadCondition m_initializeRunLoopCondition;
-    Mutex m_initializeRunLoopConditionMutex;
+    Lock m_initializeRunLoopConditionMutex;
     ThreadCondition m_terminateRunLoopCondition;
-    Mutex m_terminateRunLoopConditionMutex;
+    Lock m_terminateRunLoopConditionMutex;
 };
 
 } // namespace WebKit
index 12bb986..e388255 100644 (file)
@@ -165,28 +165,28 @@ void CustomProtocolManager::initialize(const NetworkProcessCreationParameters& p
 void CustomProtocolManager::addCustomProtocol(WKCustomProtocol *customProtocol)
 {
     ASSERT(customProtocol);
-    MutexLocker locker(m_customProtocolMapMutex);
+    LockHolder locker(m_customProtocolMapMutex);
     m_customProtocolMap.add(customProtocol.customProtocolID, customProtocol);
 }
 
 void CustomProtocolManager::removeCustomProtocol(WKCustomProtocol *customProtocol)
 {
     ASSERT(customProtocol);
-    MutexLocker locker(m_customProtocolMapMutex);
+    LockHolder locker(m_customProtocolMapMutex);
     m_customProtocolMap.remove(customProtocol.customProtocolID);
 }
     
 void CustomProtocolManager::registerScheme(const String& scheme)
 {
     ASSERT(!scheme.isNull());
-    MutexLocker locker(m_registeredSchemesMutex);
+    LockHolder locker(m_registeredSchemesMutex);
     m_registeredSchemes.add(scheme);
 }
     
 void CustomProtocolManager::unregisterScheme(const String& scheme)
 {
     ASSERT(!scheme.isNull());
-    MutexLocker locker(m_registeredSchemesMutex);
+    LockHolder locker(m_registeredSchemesMutex);
     m_registeredSchemes.remove(scheme);
 }
 
@@ -195,7 +195,7 @@ bool CustomProtocolManager::supportsScheme(const String& scheme)
     if (scheme.isNull())
         return false;
 
-    MutexLocker locker(m_registeredSchemesMutex);
+    LockHolder locker(m_registeredSchemesMutex);
     return m_registeredSchemes.contains(scheme);
 }
 
@@ -275,7 +275,7 @@ void CustomProtocolManager::wasRedirectedToRequest(uint64_t customProtocolID, co
 
 RetainPtr<WKCustomProtocol> CustomProtocolManager::protocolForID(uint64_t customProtocolID)
 {
-    MutexLocker locker(m_customProtocolMapMutex);
+    LockHolder locker(m_customProtocolMapMutex);
 
     CustomProtocolMap::const_iterator it = m_customProtocolMap.find(customProtocolID);
     if (it == m_customProtocolMap.end())
index 2761ecc..098009c 100644 (file)
@@ -102,11 +102,11 @@ private:
 
 #if PLATFORM(COCOA)
     HashSet<String> m_registeredSchemes;
-    Mutex m_registeredSchemesMutex;
+    Lock m_registeredSchemesMutex;
 
     typedef HashMap<uint64_t, RetainPtr<WKCustomProtocol>> CustomProtocolMap;
     CustomProtocolMap m_customProtocolMap;
-    Mutex m_customProtocolMapMutex;
+    Lock m_customProtocolMapMutex;
     
     // WKCustomProtocol objects can be removed from the m_customProtocolMap from multiple threads.
     // We return a RetainPtr here because it is unsafe to return a raw pointer since the object might immediately be destroyed from a different thread.
index 8f634ef..cbccf53 100644 (file)
@@ -65,7 +65,7 @@ private:
 
     int m_socket;
 
-    mutable Mutex m_socketLock;
+    mutable Lock m_socketLock;
 
     // Maps files that may be read by malloc() to open file descriptors.
     HashMap<String, int> m_fileDescriptorCache;
index 850b237..29e31b5 100644 (file)
@@ -86,7 +86,7 @@ PluginProcessConnection* PluginProcessConnectionManager::getPluginProcessConnect
     m_pluginProcessConnections.append(pluginProcessConnection);
 
     {
-        MutexLocker locker(m_tokensAndConnectionsMutex);
+        LockHolder locker(m_tokensAndConnectionsMutex);
         ASSERT(!m_tokensAndConnections.contains(pluginProcessToken));
 
         m_tokensAndConnections.set(pluginProcessToken, pluginProcessConnection->connection());
@@ -101,7 +101,7 @@ void PluginProcessConnectionManager::removePluginProcessConnection(PluginProcess
     ASSERT(vectorIndex != notFound);
 
     {
-        MutexLocker locker(m_tokensAndConnectionsMutex);
+        LockHolder locker(m_tokensAndConnectionsMutex);
         ASSERT(m_tokensAndConnections.contains(pluginProcessConnection->pluginProcessToken()));
         
         m_tokensAndConnections.remove(pluginProcessConnection->pluginProcessToken());
@@ -112,7 +112,7 @@ void PluginProcessConnectionManager::removePluginProcessConnection(PluginProcess
 
 void PluginProcessConnectionManager::pluginProcessCrashed(uint64_t pluginProcessToken)
 {
-    MutexLocker locker(m_tokensAndConnectionsMutex);
+    LockHolder locker(m_tokensAndConnectionsMutex);
     IPC::Connection* connection = m_tokensAndConnections.get(pluginProcessToken);
 
     // It's OK for connection to be null here; it will happen if this web process doesn't know
index b83266c..a023766 100644 (file)
@@ -64,7 +64,7 @@ private:
 
     Vector<RefPtr<PluginProcessConnection>> m_pluginProcessConnections;
 
-    Mutex m_tokensAndConnectionsMutex;
+    Lock m_tokensAndConnectionsMutex;
     HashMap<uint64_t, RefPtr<IPC::Connection>> m_tokensAndConnections;
 };
 
index ae3e757..3745151 100644 (file)
@@ -65,7 +65,7 @@ EventDispatcher::~EventDispatcher()
 #if ENABLE(ASYNC_SCROLLING)
 void EventDispatcher::addScrollingTreeForPage(WebPage* webPage)
 {
-    MutexLocker locker(m_scrollingTreesMutex);
+    LockHolder locker(m_scrollingTreesMutex);
 
     ASSERT(webPage->corePage()->scrollingCoordinator());
     ASSERT(!m_scrollingTrees.contains(webPage->pageID()));
@@ -76,7 +76,7 @@ void EventDispatcher::addScrollingTreeForPage(WebPage* webPage)
 
 void EventDispatcher::removeScrollingTreeForPage(WebPage* webPage)
 {
-    MutexLocker locker(m_scrollingTreesMutex);
+    LockHolder locker(m_scrollingTreesMutex);
     ASSERT(m_scrollingTrees.contains(webPage->pageID()));
 
     m_scrollingTrees.remove(webPage->pageID());
@@ -132,7 +132,7 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
 #endif
 
 #if ENABLE(ASYNC_SCROLLING)
-    MutexLocker locker(m_scrollingTreesMutex);
+    LockHolder locker(m_scrollingTreesMutex);
     if (RefPtr<ThreadedScrollingTree> scrollingTree = m_scrollingTrees.get(pageID)) {
         // FIXME: It's pretty horrible that we're updating the back/forward state here.
         // WebCore should always know the current state and know when it changes so the
index ba36239..a97ac80 100644 (file)
@@ -92,7 +92,7 @@ private:
     Ref<WorkQueue> m_queue;
 
 #if ENABLE(ASYNC_SCROLLING)
-    Mutex m_scrollingTreesMutex;
+    Lock m_scrollingTreesMutex;
     HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
 #endif
     std::unique_ptr<WebCore::WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
index 04409e1..e3f14d9 100644 (file)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "WebKitSoupRequestInputStream.h"
 
+#include <wtf/Lock.h>
 #include <wtf/Threading.h>
 #include <wtf/glib/GRefPtr.h>
 
@@ -41,7 +42,7 @@ struct _WebKitSoupRequestInputStreamPrivate {
     uint64_t bytesReceived;
     uint64_t bytesRead;
 
-    Mutex readLock;
+    Lock readLock;
     std::unique_ptr<AsyncReadData> pendingAsyncRead;
 };
 
@@ -84,7 +85,7 @@ static void webkitSoupRequestInputStreamReadAsync(GInputStream* inputStream, voi
     WebKitSoupRequestInputStream* stream = WEBKIT_SOUP_REQUEST_INPUT_STREAM(inputStream);
     GRefPtr<GTask> task = adoptGRef(g_task_new(stream, cancellable, callback, userData));
 
-    MutexLocker locker(stream->priv->readLock);
+    LockHolder locker(stream->priv->readLock);
 
     if (!webkitSoupRequestInputStreamHasDataToRead(stream) && !webkitSoupRequestInputStreamIsWaitingForData(stream)) {
         g_task_return_int(task.get(), 0);
@@ -143,7 +144,7 @@ void webkitSoupRequestInputStreamAddData(WebKitSoupRequestInputStream* stream, c
     if (webkitSoupRequestInputStreamFinished(stream))
         return;
 
-    MutexLocker locker(stream->priv->readLock);
+    LockHolder locker(stream->priv->readLock);
 
     if (dataLength) {
         // Truncate the dataLength to the contentLength if it's known.
index ddc5045..4fa3b8f 100644 (file)
@@ -1,3 +1,21 @@
+2015-08-17  Filip Pizlo  <fpizlo@apple.com>
+
+        Replace all remaining uses of WTF::Mutex with WTF::Lock
+        https://bugs.webkit.org/show_bug.cgi?id=148089
+
+        Reviewed by Geoffrey Garen.
+
+        * DumpRenderTree/JavaScriptThreading.cpp:
+        (javaScriptThreadsMutex):
+        (runJavaScriptThread):
+        (startJavaScriptThreads):
+        (stopJavaScriptThreads):
+        * TestWebKitAPI/Tests/WTF/Condition.cpp: Fixed a bug in the test that I found from turning the test into a benchmark.
+        * TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WTF/glib/WorkQueueGLib.cpp:
+        (TestWebKitAPI::TEST):
+
 2015-08-17  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r188539, r188544, r188552, and
index 70d94db..e2f9bad 100644 (file)
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 #include <wtf/Assertions.h>
 #include <wtf/HashSet.h>
+#include <wtf/Lock.h>
 #include <wtf/Threading.h>
 #include <wtf/ThreadingPrimitives.h>
 #include <wtf/Vector.h>
@@ -44,9 +45,9 @@ static const size_t javaScriptThreadsCount = 4;
 static bool javaScriptThreadsShouldTerminate;
 static JSContextGroupRef javaScriptThreadsGroup;
 
-static Mutex& javaScriptThreadsMutex()
+static Lock& javaScriptThreadsMutex()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
+    DEPRECATED_DEFINE_STATIC_LOCAL(Lock, staticMutex, ());
     return staticMutex;
 }
 
@@ -70,26 +71,26 @@ void runJavaScriptThread(void*)
 
     JSGlobalContextRef ctx;
     {
-        MutexLocker locker(javaScriptThreadsMutex());
+        LockHolder locker(javaScriptThreadsMutex());
         ctx = JSGlobalContextCreateInGroup(javaScriptThreadsGroup, 0);
     }
 
     JSStringRef scriptRef;
     {
-        MutexLocker locker(javaScriptThreadsMutex());
+        LockHolder locker(javaScriptThreadsMutex());
         scriptRef = JSStringCreateWithUTF8CString(script);
     }
 
     while (true) {
         {
-            MutexLocker locker(javaScriptThreadsMutex());
+            LockHolder locker(javaScriptThreadsMutex());
             JSValueRef exception = 0;
             JSEvaluateScript(ctx, scriptRef, 0, 0, 1, &exception);
             ASSERT(!exception);
         }
 
         {
-            MutexLocker locker(javaScriptThreadsMutex());
+            LockHolder locker(javaScriptThreadsMutex());
             const size_t valuesCount = 1024;
             JSValueRef values[valuesCount];
             for (size_t i = 0; i < valuesCount; ++i)
@@ -97,7 +98,7 @@ void runJavaScriptThread(void*)
         }
 
         {
-            MutexLocker locker(javaScriptThreadsMutex());
+            LockHolder locker(javaScriptThreadsMutex());
             if (javaScriptThreadsShouldTerminate)
                 break;
         }
@@ -106,7 +107,7 @@ void runJavaScriptThread(void*)
         if (rand() % 5)
             continue;
 
-        MutexLocker locker(javaScriptThreadsMutex());
+        LockHolder locker(javaScriptThreadsMutex());
         ThreadIdentifier thread = currentThread();
         detachThread(thread);
         javaScriptThreads().remove(thread);
@@ -114,7 +115,7 @@ void runJavaScriptThread(void*)
         break;
     }
 
-    MutexLocker locker(javaScriptThreadsMutex());
+    LockHolder locker(javaScriptThreadsMutex());
     JSStringRelease(scriptRef);
     JSGarbageCollect(ctx);
     JSGlobalContextRelease(ctx);
@@ -124,7 +125,7 @@ void startJavaScriptThreads()
 {
     javaScriptThreadsGroup = JSContextGroupCreate();
 
-    MutexLocker locker(javaScriptThreadsMutex());
+    LockHolder locker(javaScriptThreadsMutex());
 
     for (size_t i = 0; i < javaScriptThreadsCount; ++i)
         javaScriptThreads().add(createThread(&runJavaScriptThread, 0, 0));
@@ -133,13 +134,13 @@ void startJavaScriptThreads()
 void stopJavaScriptThreads()
 {
     {
-        MutexLocker locker(javaScriptThreadsMutex());
+        LockHolder locker(javaScriptThreadsMutex());
         javaScriptThreadsShouldTerminate = true;
     }
 
     Vector<ThreadIdentifier, javaScriptThreadsCount> threads;
     {
-        MutexLocker locker(javaScriptThreadsMutex());
+        LockHolder locker(javaScriptThreadsMutex());
         copyToVector(javaScriptThreads(), threads);
         ASSERT(threads.size() == javaScriptThreadsCount);
     }
@@ -148,7 +149,7 @@ void stopJavaScriptThreads()
         waitForThreadCompletion(threads[i]);
 
     {
-        MutexLocker locker(javaScriptThreadsMutex());
+        LockHolder locker(javaScriptThreadsMutex());
         javaScriptThreads().clear();
     }
 
index 411bcd4..37a3f1b 100644 (file)
@@ -112,7 +112,7 @@ void runTest(
                                 return !shouldContinue || !queue.isEmpty();
                             },
                             timeout);
-                        if (!shouldContinue)
+                        if (!shouldContinue && queue.isEmpty())
                             return;
                         shouldNotify = queue.size() == maxQueueSize;
                         result = queue.takeFirst();
index 4b03587..74f5dc2 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 
 #include "Test.h"
+#include <wtf/Condition.h>
+#include <wtf/Lock.h>
 #include <wtf/Vector.h>
 #include <wtf/WorkQueue.h>
 #include <string>
@@ -40,8 +42,8 @@ static const char* dispatchAfterLabel = "dispatchAfter";
     
 TEST(WTF_WorkQueue, Simple)
 {
-    Mutex m_lock;
-    ThreadCondition m_testCompleted;
+    Lock m_lock;
+    Condition m_testCompleted;
     Vector<std::string> m_functionCallOrder;
 
     bool calledSimpleTest = false;
@@ -56,7 +58,7 @@ TEST(WTF_WorkQueue, Simple)
     int initialRefCount = queue->refCount();
     EXPECT_EQ(1, initialRefCount);
 
-    MutexLocker locker(m_lock);
+    LockHolder locker(m_lock);
     queue->dispatch([&](void) {
         m_functionCallOrder.append(simpleTestLabel);
         calledSimpleTest = true;
@@ -69,7 +71,7 @@ TEST(WTF_WorkQueue, Simple)
     });
 
     queue->dispatch([&](void) {
-        MutexLocker locker(m_lock);
+        LockHolder locker(m_lock);
         m_functionCallOrder.append(thirdTestLabel);
         calledThirdTest = true;
 
@@ -77,7 +79,7 @@ TEST(WTF_WorkQueue, Simple)
         EXPECT_TRUE(calledLongTest);
         EXPECT_TRUE(calledThirdTest);
         
-        m_testCompleted.signal();
+        m_testCompleted.notifyOne();
     });
 
     EXPECT_GT(queue->refCount(), 1);
@@ -96,8 +98,8 @@ TEST(WTF_WorkQueue, Simple)
 
 TEST(WTF_WorkQueue, TwoQueues)
 {
-    Mutex m_lock;
-    ThreadCondition m_testQueue1Completed, m_testQueue2Completed;
+    Lock m_lock;
+    Condition m_testQueue1Completed, m_testQueue2Completed;
     Vector<std::string> m_functionCallOrder;
 
     bool calledSimpleTest = false;
@@ -110,7 +112,7 @@ TEST(WTF_WorkQueue, TwoQueues)
     EXPECT_EQ(1, queue1->refCount());
     EXPECT_EQ(1, queue2->refCount());
 
-    MutexLocker locker(m_lock);
+    LockHolder locker(m_lock);
     
     queue1->dispatch([&](void) {
         m_functionCallOrder.append(simpleTestLabel);
@@ -120,22 +122,22 @@ TEST(WTF_WorkQueue, TwoQueues)
     queue2->dispatch([&](void) {
         std::this_thread::sleep_for(std::chrono::milliseconds(50));
 
-        MutexLocker locker(m_lock);
+        LockHolder locker(m_lock);
 
         // Will fail if queue2 took the mutex before queue1.
         EXPECT_TRUE(calledThirdTest);
 
         m_functionCallOrder.append(longTestLabel);
         calledLongTest = true;
-        m_testQueue2Completed.signal();
+        m_testQueue2Completed.notifyOne();
     });
 
     queue1->dispatch([&](void) {
-        MutexLocker locker(m_lock);
+        LockHolder locker(m_lock);
         m_functionCallOrder.append(thirdTestLabel);
         calledThirdTest = true;
         
-        m_testQueue1Completed.signal();
+        m_testQueue1Completed.notifyOne();
     });
 
     m_testQueue1Completed.wait(m_lock);
@@ -158,8 +160,8 @@ TEST(WTF_WorkQueue, TwoQueues)
 
 TEST(WTF_WorkQueue, DispatchAfter)
 {
-    Mutex m_lock;
-    ThreadCondition m_testCompleted, m_dispatchAfterTestCompleted;
+    Lock m_lock;
+    Condition m_testCompleted, m_dispatchAfterTestCompleted;
     Vector<std::string> m_functionCallOrder;
 
     bool calledSimpleTest = false;
@@ -167,20 +169,20 @@ TEST(WTF_WorkQueue, DispatchAfter)
 
     auto queue = WorkQueue::create("com.apple.WebKit.Test.dispatchAfter");
 
-    MutexLocker locker(m_lock);
+    LockHolder locker(m_lock);
 
     queue->dispatch([&](void) {
-        MutexLocker locker(m_lock);
+        LockHolder locker(m_lock);
         m_functionCallOrder.append(simpleTestLabel);
         calledSimpleTest = true;
-        m_testCompleted.signal();
+        m_testCompleted.notifyOne();
     });
 
     queue->dispatchAfter(std::chrono::milliseconds(500), [&](void) {
-        MutexLocker locker(m_lock);
+        LockHolder locker(m_lock);
         m_functionCallOrder.append(dispatchAfterLabel);
         calledDispatchAfterTest = true;
-        m_dispatchAfterTestCompleted.signal();
+        m_dispatchAfterTestCompleted.notifyOne();
     });
 
     m_testCompleted.wait(m_lock);
index 28c9112..1316d8e 100644 (file)
@@ -37,7 +37,7 @@ namespace TestWebKitAPI {
 TEST(WTF_WorkQueue, AsyncIO)
 {
     struct TestingContext {
-        Mutex m_lock;
+        Lock m_lock;
         ThreadCondition m_testCompleted;
         GMainContext* m_mainContext;
     } context;
@@ -49,7 +49,7 @@ TEST(WTF_WorkQueue, AsyncIO)
     GUniquePtr<char> currentDirectory(g_get_current_dir());
     GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(currentDirectory.get()));
 
-    MutexLocker locker(context.m_lock);
+    LockHolder locker(context.m_lock);
     queue->dispatch([&](void) {
         EXPECT_TRUE(g_main_context_get_thread_default());
         EXPECT_TRUE(g_main_context_get_thread_default() != context.m_mainContext);
@@ -57,7 +57,7 @@ TEST(WTF_WorkQueue, AsyncIO)
         g_file_query_info_async(file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, nullptr,
             [](GObject*, GAsyncResult*, gpointer userData) {
                 TestingContext* context = static_cast<TestingContext*>(userData);
-                MutexLocker locker(context->m_lock);
+                LockHolder locker(context->m_lock);
                 EXPECT_EQ(g_main_context_get_thread_default(), context->m_mainContext);
                 context->m_testCompleted.signal();
             }, &context);