Bug 196042 - Stop storing raw pointers to Documents
Summary: Stop storing raw pointers to Documents
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-03-20 16:12 PDT by Alex Christensen
Modified: 2019-03-25 14:23 PDT (History)
4 users (show)

See Also:


Attachments
Patch (19.07 KB, patch)
2019-03-20 16:13 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (18.50 KB, patch)
2019-03-20 16:55 PDT, Alex Christensen
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2019-03-20 16:12:25 PDT
Stop storing raw pointers to Documents
Comment 1 Alex Christensen 2019-03-20 16:13:29 PDT
Created attachment 365427 [details]
Patch
Comment 2 Chris Dumez 2019-03-20 16:14:38 PDT
Comment on attachment 365427 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=365427&action=review

> Source/WebCore/Modules/websockets/WebSocketChannel.cpp:372
> +        didCloseSocketStream(handle);

Did you mean to include this?
Comment 3 Geoffrey Garen 2019-03-20 16:53:11 PDT
Comment on attachment 365427 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=365427&action=review

r=me

>> Source/WebCore/Modules/websockets/WebSocketChannel.cpp:372
>> +        didCloseSocketStream(handle);
> 
> Did you mean to include this?

Plz delete.
Comment 4 Alex Christensen 2019-03-20 16:55:34 PDT
Created attachment 365440 [details]
Patch
Comment 5 Daniel Bates 2019-03-20 18:46:19 PDT
Comment on attachment 365440 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=365440&action=review

> Source/WebCore/loader/MediaResourceLoader.h:55
> +    Document* document() const { return m_document.get(); }

Why? To fix the build? :D  If so, what's the caller that needs this? If not, this code is correct as-is and you're making it wrong.
Comment 6 Daniel Bates 2019-03-20 18:47:19 PDT
(In reply to Daniel Bates from comment #5)
> Comment on attachment 365440 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=365440&action=review
> 
> > Source/WebCore/loader/MediaResourceLoader.h:55
> > +    Document* document() const { return m_document.get(); }
> 
> Why? To fix the build? :D  If so, what's the caller that needs this? If not,
> this code is correct as-is and you're making it wrong.

Talk to me in person if you need to know why it's wrong.
Comment 7 Alex Christensen 2019-03-22 10:12:48 PDT
Comment on attachment 365440 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=365440&action=review

>>> Source/WebCore/loader/MediaResourceLoader.h:55
>>> +    Document* document() const { return m_document.get(); }
>> 
>> Why? To fix the build? :D  If so, what's the caller that needs this? If not, this code is correct as-is and you're making it wrong.
> 
> Talk to me in person if you need to know why it's wrong.

I'm not sure what you're referring to.  I'm adding const because I can and because it's an accessor that doesn't modify the object.  I'm adding the .get() because m_document is now a WeakPtr and this function returns a pointer, so I need the .get().
Comment 8 Geoffrey Garen 2019-03-22 10:34:56 PDT
Comment on attachment 365440 [details]
Patch

r=me, seems worth following up with Dan to understand why he though const was "wrong"
Comment 9 Chris Dumez 2019-03-22 10:40:21 PDT
Comment on attachment 365440 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=365440&action=review

>>>> Source/WebCore/loader/MediaResourceLoader.h:55
>>>> +    Document* document() const { return m_document.get(); }
>>> 
>>> Why? To fix the build? :D  If so, what's the caller that needs this? If not, this code is correct as-is and you're making it wrong.
>> 
>> Talk to me in person if you need to know why it's wrong.
> 
> I'm not sure what you're referring to.  I'm adding const because I can and because it's an accessor that doesn't modify the object.  I'm adding the .get() because m_document is now a WeakPtr and this function returns a pointer, so I need the .get().

I think people have different views about what const-correct means. I personally think the new code is less const correct since it is returning a non const data member in a const method.
Comment 10 Daniel Bates 2019-03-22 13:46:28 PDT
(In reply to Chris Dumez from comment #9)

> I
> personally think the new code is less const correct since it is returning a
> non const data member in a const method.

Bingo! 👍
Comment 11 Alex Christensen 2019-03-25 14:22:21 PDT
Removed the controversial const and committed to http://trac.webkit.org/r243459
Comment 12 Radar WebKit Bug Importer 2019-03-25 14:23:45 PDT
<rdar://problem/49229100>