WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
69877
Make CachedResourceClientWalker templated and have it do checked casts.
https://bugs.webkit.org/show_bug.cgi?id=69877
Summary
Make CachedResourceClientWalker templated and have it do checked casts.
Nate Chapin
Reported
2011-10-11 15:54:35 PDT
Followup to
https://bugs.webkit.org/show_bug.cgi?id=69790
, which introduced a bunch of unchecked casts that rely on CachedResource subtypes and CachedResourceClient subtypes matching each other correctly. As written, it will fail dangerously in the event of a programmer error.
Attachments
patch
(20.37 KB, patch)
2011-10-11 15:56 PDT
,
Nate Chapin
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Nate Chapin
Comment 1
2011-10-11 15:56:51 PDT
Created
attachment 110597
[details]
patch
WebKit Review Bot
Comment 2
2011-10-11 17:11:37 PDT
Comment on
attachment 110597
[details]
patch Clearing flags on attachment: 110597 Committed
r97199
: <
http://trac.webkit.org/changeset/97199
>
WebKit Review Bot
Comment 3
2011-10-11 17:11:42 PDT
All reviewed patches have been landed. Closing bug.
Antti Koivisto
Comment 4
2011-10-12 01:03:51 PDT
Comment on
attachment 110597
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=110597&action=review
> Source/WebCore/loader/cache/CachedResourceClientWalker.h:54 > + if (m_clientSet.contains(next) && (T::expectedType() == CachedResourceClient::expectedType() || next->type() == T::expectedType())) > + return static_cast<T*>(next);
What is the purpose of T::expectedType() == CachedResourceClient::expectedType()? Could this assert the correct type instead?
Nate Chapin
Comment 5
2011-10-12 08:52:44 PDT
(In reply to
comment #4
)
> (From update of
attachment 110597
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=110597&action=review
> > > Source/WebCore/loader/cache/CachedResourceClientWalker.h:54 > > + if (m_clientSet.contains(next) && (T::expectedType() == CachedResourceClient::expectedType() || next->type() == T::expectedType())) > > + return static_cast<T*>(next); > > What is the purpose of T::expectedType() == CachedResourceClient::expectedType()? > > Could this assert the correct type instead?
The purpose is to handle the notifyFinished() callback correctly. notifyFinished() is called for all CachedResourceClient types, and is templated with the base class rather than a subclass. I suppose we could assert instead of just skipping clients of the wrong type. I don't have a strong opinion.
Antti Koivisto
Comment 6
2011-10-12 10:50:02 PDT
I suspect that all cases where there are unexpected types on the list are bugs so assert would be the right choice.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug