Index: Source/modules/serviceworkers/Headers.h |
diff --git a/Source/modules/serviceworkers/HeaderMap.h b/Source/modules/serviceworkers/Headers.h |
similarity index 17% |
copy from Source/modules/serviceworkers/HeaderMap.h |
copy to Source/modules/serviceworkers/Headers.h |
index 3e5b47f567df5b2a6a43bbedb306ed5034928d16..a8fe1873e0656ff735ea2d083a5fd4a800fcd29f 100644 |
--- a/Source/modules/serviceworkers/HeaderMap.h |
+++ b/Source/modules/serviceworkers/Headers.h |
@@ -2,46 +2,64 @@ |
// 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 }; |
- // 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>); |
- const HashMap<String, String>& headerMap() const { return m_headers; } |
+ void setGuard(Guard guard) { m_guard = guard; } |
+ Guard guard() const { return m_guard; } |
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*); |
falken
2014/06/27 02:08:06
nit: explicit
horo
2014/06/27 04:19:10
Done.
|
+ void forEachInternal(PassOwnPtr<HeadersForEachCallback>, ScriptValue*); |
+ |
+ void fillWith(const Headers*, ExceptionState&); |
+ void fillWith(const Dictionary&, ExceptionState&); |
- // 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 |