Bug 133392 - HTTPHeaderMap should not derive from HashMap
Summary: HTTPHeaderMap should not derive from HashMap
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-29 16:26 PDT by Anders Carlsson
Modified: 2014-06-09 23:49 PDT (History)
13 users (show)

See Also:


Attachments
Patch (15.84 KB, patch)
2014-05-29 16:27 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2 (524.64 KB, application/zip)
2014-05-29 17:47 PDT, Build Bot
no flags Details
Patch (16.68 KB, patch)
2014-06-04 10:56 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (16.67 KB, patch)
2014-06-04 11:28 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (16.67 KB, patch)
2014-06-04 13:58 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (17.98 KB, patch)
2014-06-07 12:11 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (18.47 KB, patch)
2014-06-07 12:22 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Carlsson 2014-05-29 16:26:22 PDT
HTTPHeaderMap should not derive from HashMap
Comment 1 Anders Carlsson 2014-05-29 16:27:44 PDT
Created attachment 232269 [details]
Patch
Comment 2 Geoffrey Garen 2014-05-29 16:31:06 PDT
Comment on attachment 232269 [details]
Patch

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

r=me

> Source/WebCore/loader/DocumentLoader.cpp:608
> -    DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, xFrameOptionHeader, ("x-frame-options", AtomicString::ConstructFromLiteral));
> -
> -    auto it = response.httpHeaderFields().find(xFrameOptionHeader);
> +    auto it = response.httpHeaderFields().find("x-frame-options");
>      if (it != response.httpHeaderFields().end()) {

Why don't we like static local AtomicString here?
Comment 3 Build Bot 2014-05-29 17:47:46 PDT
Comment on attachment 232269 [details]
Patch

Attachment 232269 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4631480315674624

New failing tests:
media/W3C/video/preload/preload_property_exists.html
Comment 4 Build Bot 2014-05-29 17:47:48 PDT
Created attachment 232275 [details]
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-16  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 5 Anders Carlsson 2014-06-04 10:56:30 PDT
Created attachment 232486 [details]
Patch
Comment 6 Anders Carlsson 2014-06-04 11:28:57 PDT
Created attachment 232487 [details]
Patch
Comment 7 Anders Carlsson 2014-06-04 13:58:05 PDT
Created attachment 232499 [details]
Patch
Comment 8 Darin Adler 2014-06-04 17:13:31 PDT
Comment on attachment 232499 [details]
Patch

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

> Source/WebCore/platform/network/HTTPHeaderMap.cpp:62
> +        m_headers.set(std::move(header.first), std::move(header.second));

Should use add instead of set here.

> Source/WebCore/platform/network/HTTPHeaderMap.cpp:104
>  String HTTPHeaderMap::get(const char* name) const
>  {
> -    const_iterator i = find<CaseFoldingCStringTranslator>(name);
> -    if (i == end())
> +    auto it = find(name);
> +    if (it == end())
>          return String();
> -    return i->value;
> +    return it->value;
>  }

Seems like we should make this one inline.

> Source/WebCore/platform/network/HTTPHeaderMap.cpp:109
>  bool HTTPHeaderMap::contains(const char* name) const
>  {
> -    return find<CaseFoldingCStringTranslator>(name) != end();
> +    return find(name) != end();
> +}

Seems like we want to make this one inline.

> Source/WebCore/platform/network/HTTPHeaderMap.h:49
> +    HTTPHeaderMap();
> +    ~HTTPHeaderMap();

Why are we declaring/defining these? To make sure they aren’t inlined perhaps?

> Source/WebCore/platform/network/HTTPHeaderMap.h:88
> +    friend bool operator!=(const HTTPHeaderMap& a, const HTTPHeaderMap& b)
> +    {
> +        return !(a == b);
> +    }

This doesn’t need to be a friend.

> Source/WebCore/platform/network/HTTPHeaderMap.h:91
>      // FIXME: Not every header fits into a map. Notably, multiple Set-Cookie header fields are needed to set multiple cookies.

Seems like this comment belongs before the class, not in the private section.

> Source/WebCore/platform/network/ResourceRequestBase.h:36
>  #include <wtf/OwnPtr.h>

Why are we keeping this?

> Source/WebCore/platform/network/ResourceRequestBase.h:37
> +#include <wtf/PassOwnPtr.h>

Why are we adding this?

> Source/WebKit/win/WebURLResponse.cpp:363
> +    HashMap<String, String, CaseFoldingHash> fields;

1>..\..\win\WebURLResponse.cpp(367): error C2664: 'COMPropertyBag<WTF::String,WTF::AtomicString,WTF::CaseFoldingHash> *COMPropertyBag<WTF::String,WTF::AtomicString,WTF::CaseFoldingHash>::adopt(WTF::HashMap<WTF::AtomicString,WTF::String,WTF::CaseFoldingHash,WTF::HashTraits<WTF::AtomicString>,WTF::HashTraits<WTF::String>> &)' : cannot convert argument 1 from 'WTF::HashMap<WTF::String,WTF::String,WTF::CaseFoldingHash,WTF::HashTraits<WTF::String>,WTF::HashTraits<WTF::String>>' to 'WTF::HashMap<WTF::AtomicString,WTF::String,WTF::CaseFoldingHash,WTF::HashTraits<WTF::AtomicString>,WTF::HashTraits<WTF::String>> &'

> Source/WebKit/win/WebURLResponse.cpp:365
> +        fields.set(keyValuePair.key, keyValuePair.value);

Should use add instead of set here.
Comment 9 Anders Carlsson 2014-06-07 09:52:06 PDT
(In reply to comment #8)
> (From update of attachment 232499 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=232499&action=review
> 
> > Source/WebCore/platform/network/HTTPHeaderMap.cpp:104
> >  String HTTPHeaderMap::get(const char* name) const
> >  {
> > -    const_iterator i = find<CaseFoldingCStringTranslator>(name);
> > -    if (i == end())
> > +    auto it = find(name);
> > +    if (it == end())
> >          return String();
> > -    return i->value;
> > +    return it->value;
> >  }
> 
> Seems like we should make this one inline.

I didn't want to move this since it's going to be replaced with a version that takes an enum.

> Seems like we want to make this one inline.

Same thing here.

> 
> > Source/WebCore/platform/network/HTTPHeaderMap.h:49
> > +    HTTPHeaderMap();
> > +    ~HTTPHeaderMap();
> 
> Why are we declaring/defining these? To make sure they aren’t inlined perhaps?

Yup.

> 
> > Source/WebCore/platform/network/HTTPHeaderMap.h:88
> > +    friend bool operator!=(const HTTPHeaderMap& a, const HTTPHeaderMap& b)
> > +    {
> > +        return !(a == b);
> > +    }
> 
> This doesn’t need to be a friend.

I want it to be inside the class, so it does need to be a friend.
Comment 10 Anders Carlsson 2014-06-07 12:11:57 PDT
Created attachment 232664 [details]
Patch
Comment 11 Anders Carlsson 2014-06-07 12:22:08 PDT
Created attachment 232665 [details]
Patch
Comment 12 Anders Carlsson 2014-06-07 13:17:49 PDT
Committed r169679: <http://trac.webkit.org/changeset/169679>
Comment 13 Csaba Osztrogonác 2014-06-09 23:49:00 PDT
(In reply to comment #12)
> Committed r169679: <http://trac.webkit.org/changeset/169679>

It broke the WinCairo build:
   1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\loader\FrameLoadRequest.cpp)
     1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\loader\ResourceLoader.cpp)
     1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\loader\NetscapePlugInStreamLoader.cpp)
     1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\loader\CrossOriginAccessControl.cpp)
     1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\loader\DocumentThreadableLoader.cpp)
     1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\loader\ImageLoader.cpp)
     1>C:\Projects\BuildSlave\win-cairo-release\build\Source\WebCore\platform\network\curl\ResourceRequest.h(81): error C2027: use of undefined type 'WTF::PassOwnPtr<WebCore::CrossThreadResourceRequestData>' (..\page\DragController.cpp)
  
...

cc-ing WinCairo maintainers