[webkit-changes] [WebKit/WebKit] 51537e: [UnifiedPDF] Prepare for thread-safe access to loa...
Simon Fraser
noreply at github.com
Fri Mar 15 10:06:06 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 51537ed487c6c33534b9aa748d8419ddbe07e355
https://github.com/WebKit/WebKit/commit/51537ed487c6c33534b9aa748d8419ddbe07e355
Author: Simon Fraser <simon.fraser at apple.com>
Date: 2024-03-15 (Fri, 15 Mar 2024)
Changed paths:
M Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.h
M Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.mm
M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm
Log Message:
-----------
[UnifiedPDF] Prepare for thread-safe access to loaded PDF data
https://bugs.webkit.org/show_bug.cgi?id=271019
rdar://124644460
Reviewed by Tim Horton.
In a future patch I will be attempting to read loaded PDF data off the main thread, rather than
using the semaphore-driven hops to the main thread.
In preparation for this, make accessing the various data members related to loaded PDF data
thread-safe. In particular, add a Lock to protect `m_data` and `m_streamedBytes`, and move
the `RangeSet<Range>>` (which represents ranges of loaded data beyond m_streamedBytes) into
PDFPluginBase to be protected by the same lock.
Now we need the "check data availability and return data pointer" blocks to be thread-safe,
so remove `haveDataForRange()`, and make callers just try to call `dataPtrForRange()` which
internally takes the lock for both the checks and the data access.
There are code paths that want to avoid checking m_validRanges (the "complete unconditionally" code path);
for them, add a CheckValidRanges enum to `dataPtrForRange()`.
* Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.mm:
(WebKit::ByteRangeRequest::completeUnconditionally):
(WebKit::PDFIncrementalLoader::dataPtrForRange const):
(WebKit::PDFIncrementalLoader::incrementalPDFStreamDidReceiveData):
(WebKit::PDFIncrementalLoader::requestCompleteIfPossible):
(WebKit::PDFIncrementalLoader::requestDidCompleteWithAccumulatedData):
(WebKit::PDFIncrementalLoader::ensureDataBufferLength): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::WTF_GUARDED_BY_LOCK):
(WebKit::PDFPluginBase::streamedBytes const): Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::teardown):
(WebKit::PDFPluginBase::originalData const):
(WebKit::PDFPluginBase::streamedBytes const):
(WebKit::PDFPluginBase::haveStreamedDataForRange const):
(WebKit::PDFPluginBase::copyDataAtPosition const):
(WebKit::PDFPluginBase::dataPtrForRange const):
(WebKit::PDFPluginBase::insertRangeRequestData):
(WebKit::PDFPluginBase::streamDidReceiveData):
(WebKit::PDFPluginBase::streamDidFail):
(WebKit::PDFPluginBase::addArchiveResource):
(WebKit::PDFPluginBase::incrementalLoaderLog):
(WebKit::PDFPluginBase::haveDataForRange const): Deleted.
Canonical link: https://commits.webkit.org/276171@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list