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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef HeaderMap_h 5 #ifndef Headers_h
6 #define HeaderMap_h 6 #define Headers_h
7 7
8 #include "bindings/v8/ScriptWrappable.h" 8 #include "bindings/v8/ScriptWrappable.h"
9 #include "modules/serviceworkers/FetchHeaderList.h"
9 #include "wtf/Forward.h" 10 #include "wtf/Forward.h"
10 #include "wtf/HashMap.h" 11 #include "wtf/PassOwnPtr.h"
11 #include "wtf/RefCounted.h" 12 #include "wtf/RefCounted.h"
12 #include "wtf/text/StringHash.h"
13 13
14 namespace WebCore { 14 namespace WebCore {
15 15
16 class HeaderMapForEachCallback; 16 class Dictionary;
17 class ExceptionState;
18 class HeadersForEachCallback;
17 class ScriptValue; 19 class ScriptValue;
18 20
19 class HeaderMap FINAL : public ScriptWrappable, public RefCounted<HeaderMap> { 21 // http://fetch.spec.whatwg.org/#headers-class
22 class Headers FINAL : public ScriptWrappable, public RefCounted<Headers> {
20 public: 23 public:
21 static PassRefPtr<HeaderMap> create(); 24 enum Guard { ImmutableGuard, RequestGuard, RequestNoCORSGuard, ResponseGuard , NoneGuard };
22 static PassRefPtr<HeaderMap> create(const HashMap<String, String>& headers);
23 25
24 // HeaderMap.idl implementation. 26 static PassRefPtr<Headers> create();
27 static PassRefPtr<Headers> create(ExceptionState&);
28 static PassRefPtr<Headers> create(const Headers*, ExceptionState&);
29 static PassRefPtr<Headers> create(const Dictionary&, ExceptionState&);
30
31 ~Headers();
32
33 // Shares the FetchHeaderList. Called when creating a Request or Response.
34 static PassRefPtr<Headers> create(FetchHeaderList*);
35
36 // Headers.idl implementation.
37 void append(const String& name, const String& value, ExceptionState&);
38 void remove(const String& key, ExceptionState&);
39 String get(const String& key, ExceptionState&);
40 Vector<String> getAll(const String& key, ExceptionState&);
41 bool has(const String& key, ExceptionState&);
42 void set(const String& key, const String& value, ExceptionState&);
25 unsigned long size() const; 43 unsigned long size() const;
26 void clear(); 44 void forEach(PassOwnPtr<HeadersForEachCallback>, ScriptValue&);
27 bool remove(const String& key); 45 void forEach(PassOwnPtr<HeadersForEachCallback>);
28 String get(const String& key);
29 bool has(const String& key);
30 void set(const String& key, const String& value);
31 void forEach(PassOwnPtr<HeaderMapForEachCallback>, ScriptValue&);
32 void forEach(PassOwnPtr<HeaderMapForEachCallback>);
33 46
34 const HashMap<String, String>& headerMap() const { return m_headers; } 47 void setGuard(Guard guard) { m_guard = guard; }
48 Guard guard() const { return m_guard; }
35 49
36 private: 50 private:
37 HeaderMap(); 51 Headers();
38 explicit HeaderMap(const HashMap<String, String>& headers); 52 // Shares the FetchHeaderList. Called when creating a Request or Response.
39 void forEachInternal(PassOwnPtr<HeaderMapForEachCallback>, ScriptValue* this Arg); 53 Headers(FetchHeaderList*);
falken 2014/06/27 02:08:06 nit: explicit
horo 2014/06/27 04:19:10 Done.
54 void forEachInternal(PassOwnPtr<HeadersForEachCallback>, ScriptValue*);
40 55
41 // FIXME: this doesn't preserve ordering while ES6 Map type requires it. 56 void fillWith(const Headers*, ExceptionState&);
42 HashMap<String, String> m_headers; 57 void fillWith(const Dictionary&, ExceptionState&);
58
59 RefPtr<FetchHeaderList> m_headerList;
60 Guard m_guard;
43 }; 61 };
44 62
45 } // namespace WebCore 63 } // namespace WebCore
46 64
47 #endif // HeaderMap_h 65 #endif // Headers_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698