Chromium Code Reviews| Index: Source/modules/serviceworkers/Headers.h |
| diff --git a/Source/modules/serviceworkers/HeaderMap.h b/Source/modules/serviceworkers/Headers.h |
| similarity index 16% |
| copy from Source/modules/serviceworkers/HeaderMap.h |
| copy to Source/modules/serviceworkers/Headers.h |
| index 3e5b47f567df5b2a6a43bbedb306ed5034928d16..076e48f024c8d706d01f51ed49493ed5811de669 100644 |
| --- a/Source/modules/serviceworkers/HeaderMap.h |
| +++ b/Source/modules/serviceworkers/Headers.h |
| @@ -2,46 +2,67 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef HeaderMap_h |
| -#define HeaderMap_h |
| +#ifndef Headers_h |
| +#define Headers_h |
| #include "bindings/v8/ScriptWrappable.h" |
| +#include "modules/serviceworkers/FetchHeaderList.h" |
| #include "wtf/Forward.h" |
| -#include "wtf/HashMap.h" |
| +#include "wtf/PassOwnPtr.h" |
| #include "wtf/RefCounted.h" |
| -#include "wtf/text/StringHash.h" |
| namespace WebCore { |
| -class HeaderMapForEachCallback; |
| +class Dictionary; |
| +class ExceptionState; |
| +class HeadersForEachCallback; |
| class ScriptValue; |
| -class HeaderMap FINAL : public ScriptWrappable, public RefCounted<HeaderMap> { |
| +// http://fetch.spec.whatwg.org/#headers-class |
| +class Headers FINAL : public ScriptWrappable, public RefCounted<Headers> { |
| public: |
| - static PassRefPtr<HeaderMap> create(); |
| - static PassRefPtr<HeaderMap> create(const HashMap<String, String>& headers); |
| + enum Guard { ImmutableGuard, RequestGuard, RequestNoCORSGuard, ResponseGuard, NoneGuard }; |
| + typedef std::pair<String, String> Header; |
|
yhirano
2014/06/26 07:22:13
Do you need this typedef?
horo
2014/06/26 08:30:08
Done.
|
| - // HeaderMap.idl implementation. |
| + static PassRefPtr<Headers> create(); |
| + static PassRefPtr<Headers> create(ExceptionState&); |
| + static PassRefPtr<Headers> create(const Headers*, ExceptionState&); |
| + static PassRefPtr<Headers> create(const Dictionary&, ExceptionState&); |
| + |
| + ~Headers(); |
| + |
| + // Shares the FetchHeaderList. Called when creating a Request or Response. |
| + static PassRefPtr<Headers> create(FetchHeaderList*); |
| + |
| + // Headers.idl implementation. |
| + void append(const String& name, const String& value, ExceptionState&); |
| + void remove(const String& key, ExceptionState&); |
| + String get(const String& key, ExceptionState&); |
| + Vector<String> getAll(const String& key, ExceptionState&); |
| + bool has(const String& key, ExceptionState&); |
| + void set(const String& key, const String& value, ExceptionState&); |
| unsigned long size() const; |
| - void clear(); |
| - bool remove(const String& key); |
| - String get(const String& key); |
| - bool has(const String& key); |
| - void set(const String& key, const String& value); |
| - void forEach(PassOwnPtr<HeaderMapForEachCallback>, ScriptValue&); |
| - void forEach(PassOwnPtr<HeaderMapForEachCallback>); |
| + void forEach(PassOwnPtr<HeadersForEachCallback>, ScriptValue&); |
| + void forEach(PassOwnPtr<HeadersForEachCallback>); |
| + |
| + void clearHeaderList(); |
|
yhirano
2014/06/26 07:22:13
This function is never called.
horo
2014/06/26 08:30:08
deleted.
|
| + void fillWith(const Headers*, ExceptionState&); |
|
yhirano
2014/06/26 07:22:13
I think these two fillWith functions can be privat
horo
2014/06/26 08:30:08
moved to private
|
| + void fillWith(const Dictionary&, ExceptionState&); |
| - const HashMap<String, String>& headerMap() const { return m_headers; } |
| + void setGuard(Guard guard) { m_guard = guard; } |
| + Guard guard() const { return m_guard; } |
| + PassRefPtr<FetchHeaderList> list() const { return m_headerList; } |
|
yhirano
2014/06/26 07:22:13
I'm not sure if we need this function.
horo
2014/06/26 08:30:08
deleted.
|
| private: |
| - HeaderMap(); |
| - explicit HeaderMap(const HashMap<String, String>& headers); |
| - void forEachInternal(PassOwnPtr<HeaderMapForEachCallback>, ScriptValue* thisArg); |
| + Headers(); |
| + // Shares the FetchHeaderList. Called when creating a Request or Response. |
| + Headers(FetchHeaderList*); |
| + void forEachInternal(PassOwnPtr<HeadersForEachCallback>, ScriptValue*); |
| - // FIXME: this doesn't preserve ordering while ES6 Map type requires it. |
| - HashMap<String, String> m_headers; |
| + RefPtr<FetchHeaderList> m_headerList; |
| + Guard m_guard; |
| }; |
| } // namespace WebCore |
| -#endif // HeaderMap_h |
| +#endif // Headers_h |