Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1312)

Unified Diff: Source/modules/serviceworkers/Headers.h

Issue 358573002: [ServiceWorker] Implement Headers class. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698