WebKit Bugzilla
Attachment 373397 Details for
Bug 199456
: Use smarter pointers in WKDownloadProgress
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199456-20190703101730.patch (text/plain), 6.66 KB, created by
Alex Christensen
on 2019-07-03 10:17:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-07-03 10:17:31 PDT
Size:
6.66 KB
patch
obsolete
>Subversion Revision: 247022 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 2c148bdb2f0c7c4c6f84237daf29e68a3c8d359d..3fb30e235b3f181062be97609509c519e2e1600a 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,22 @@ >+2019-07-03 Alex Christensen <achristensen@webkit.org> >+ >+ Use smarter pointers in WKDownloadProgress >+ https://bugs.webkit.org/show_bug.cgi?id=199456 >+ <rdar://problem/51392926> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ There's still a problem related to our use of raw pointers. Let's just not use raw pointers. >+ >+ * NetworkProcess/Downloads/Download.h: >+ * NetworkProcess/Downloads/cocoa/DownloadCocoa.mm: >+ (WebKit::Download::publishProgress): >+ * NetworkProcess/Downloads/cocoa/WKDownloadProgress.h: >+ * NetworkProcess/Downloads/cocoa/WKDownloadProgress.mm: >+ (-[WKDownloadProgress performCancel]): >+ (-[WKDownloadProgress initWithDownloadTask:download:URL:sandboxExtension:]): >+ (-[WKDownloadProgress progressCancelled]): Deleted. >+ > 2019-07-01 Alex Christensen <achristensen@webkit.org> > > Deprecate but still call _webView:showCustomSheetForElement: after transition to UIContextMenuInteraction >diff --git a/Source/WebKit/NetworkProcess/Downloads/Download.h b/Source/WebKit/NetworkProcess/Downloads/Download.h >index f720c012b397c338d8fc520cb850b2be279c2e45..8265a7e3de6cc03738229384a8a77ab01298d5f1 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/Download.h >+++ b/Source/WebKit/NetworkProcess/Downloads/Download.h >@@ -37,6 +37,7 @@ > #include <pal/SessionID.h> > #include <wtf/Noncopyable.h> > #include <wtf/RetainPtr.h> >+#include <wtf/WeakPtr.h> > > #if PLATFORM(COCOA) > OBJC_CLASS NSProgress; >@@ -64,7 +65,7 @@ class NetworkDataTask; > class NetworkSession; > class WebPage; > >-class Download : public IPC::MessageSender { >+class Download : public IPC::MessageSender, public CanMakeWeakPtr<Download> { > WTF_MAKE_NONCOPYABLE(Download); WTF_MAKE_FAST_ALLOCATED; > public: > Download(DownloadManager&, DownloadID, NetworkDataTask&, const PAL::SessionID& sessionID, const String& suggestedFilename = { }); >diff --git a/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm b/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm >index c7c514b7e170fff3edfe81a757b1ef59cb4eb1d4..4956133f4a0a2ddccc250c9863946a9b3dd83734 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm >+++ b/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm >@@ -111,7 +111,7 @@ void Download::publishProgress(const URL& url, SandboxExtension::Handle&& sandbo > if (!sandboxExtension) > return; > >- m_progress = adoptNS([[WKDownloadProgress alloc] initWithDownloadTask:m_downloadTask.get() download:this URL:(NSURL *)url sandboxExtension:sandboxExtension]); >+ m_progress = adoptNS([[WKDownloadProgress alloc] initWithDownloadTask:m_downloadTask.get() download:*this URL:(NSURL *)url sandboxExtension:sandboxExtension]); > #if USE(NSPROGRESS_PUBLISHING_SPI) > [m_progress _publish]; > #else >diff --git a/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.h b/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.h >index 8ca4f5d22a39f52837d8b12b848b573665b651c4..50a7f38256c55dc13f3f4b3db70717b3ceafd527 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.h >+++ b/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.h >@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN > > @interface WKDownloadProgress : NSProgress > >-- (instancetype)initWithDownloadTask:(NSURLSessionDownloadTask *)task download:(WebKit::Download*)download URL:(NSURL *)fileURL sandboxExtension:(RefPtr<WebKit::SandboxExtension>)sandboxExtension; >+- (instancetype)initWithDownloadTask:(NSURLSessionDownloadTask *)task download:(WebKit::Download&)download URL:(NSURL *)fileURL sandboxExtension:(RefPtr<WebKit::SandboxExtension>)sandboxExtension; > > @end > >diff --git a/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.mm b/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.mm >index 1b93b6698a943e0cc2b56982965f181866cffd94..898dd6f4fc10c90882d188d4be95bca42fa7a851 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.mm >+++ b/Source/WebKit/NetworkProcess/Downloads/cocoa/WKDownloadProgress.mm >@@ -39,36 +39,24 @@ static NSString * const countOfBytesReceivedKeyPath = @"countOfBytesReceived"; > > @implementation WKDownloadProgress { > RetainPtr<NSURLSessionDownloadTask> m_task; >- WebKit::Download* m_download; >+ WeakPtr<WebKit::Download> m_download; > RefPtr<WebKit::SandboxExtension> m_sandboxExtension; >- std::once_flag m_progressCancelOnce; > } > > - (void)performCancel > { > if (m_download) > m_download->cancel(); >+ m_download = nullptr; > } > >-- (void)progressCancelled >-{ >- std::call_once(m_progressCancelOnce, [self] { >- if (!isMainThread()) { >- [self performSelectorOnMainThread:@selector(performCancel) withObject:nil waitUntilDone:NO]; >- return; >- } >- >- [self performCancel]; >- }); >-} >- >-- (instancetype)initWithDownloadTask:(NSURLSessionDownloadTask *)task download:(WebKit::Download*)download URL:(NSURL *)fileURL sandboxExtension:(RefPtr<WebKit::SandboxExtension>)sandboxExtension >+- (instancetype)initWithDownloadTask:(NSURLSessionDownloadTask *)task download:(WebKit::Download&)download URL:(NSURL *)fileURL sandboxExtension:(RefPtr<WebKit::SandboxExtension>)sandboxExtension > { > if (!(self = [self initWithParent:nil userInfo:nil])) > return nil; > > m_task = task; >- m_download = download; >+ m_download = makeWeakPtr(download); > > [task addObserver:self forKeyPath:countOfBytesExpectedToReceiveKeyPath options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial context:WKDownloadProgressBytesExpectedToReceiveCountContext]; > [task addObserver:self forKeyPath:countOfBytesReceivedKeyPath options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial context:WKDownloadProgressBytesReceivedContext]; >@@ -84,8 +72,14 @@ static NSString * const countOfBytesReceivedKeyPath = @"countOfBytesReceived"; > m_sandboxExtension = sandboxExtension; > > self.cancellable = YES; >- self.cancellationHandler = makeBlockPtr([weakSelf = WeakObjCPtr<WKDownloadProgress> { self }] { >- [weakSelf.get() progressCancelled]; >+ self.cancellationHandler = makeBlockPtr([weakSelf = WeakObjCPtr<WKDownloadProgress> { self }] () mutable { >+ if (!isMainThread()) { >+ RunLoop::main().dispatch([weakSelf = WTFMove(weakSelf)] { >+ [weakSelf performCancel]; >+ }); >+ return; >+ } >+ [weakSelf performCancel]; > }).get(); > > return self;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199456
:
373397
|
373408