| OLD | NEW |
| 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 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/HeaderMap.h" | 6 #include "modules/serviceworkers/HeaderMap.h" |
| 7 | 7 |
| 8 #include "bindings/v8/ExceptionState.h" | 8 #include "bindings/v8/ExceptionState.h" |
| 9 #include "modules/serviceworkers/HeaderMapForEachCallback.h" | 9 #include "modules/serviceworkers/HeaderMapForEachCallback.h" |
| 10 #include "wtf/PassRefPtr.h" | 10 #include "wtf/PassRefPtr.h" |
| 11 #include "wtf/RefPtr.h" | 11 #include "wtf/RefPtr.h" |
| 12 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
| 13 | 13 |
| 14 namespace WebCore { | 14 namespace WebCore { |
| 15 | 15 |
| 16 PassRefPtr<HeaderMap> HeaderMap::create() | 16 PassRefPtr<HeaderMap> HeaderMap::create() |
| 17 { | 17 { |
| 18 return adoptRef(new HeaderMap); | 18 return adoptRef(new HeaderMap); |
| 19 } | 19 } |
| 20 | 20 |
| 21 PassRefPtr<HeaderMap> HeaderMap::create(const HashMap<String, String>& headers) |
| 22 { |
| 23 return adoptRef(new HeaderMap(headers)); |
| 24 } |
| 25 |
| 21 unsigned long HeaderMap::size() const | 26 unsigned long HeaderMap::size() const |
| 22 { | 27 { |
| 23 return m_headers.size(); | 28 return m_headers.size(); |
| 24 } | 29 } |
| 25 | 30 |
| 26 void HeaderMap::clear() | 31 void HeaderMap::clear() |
| 27 { | 32 { |
| 28 m_headers.clear(); | 33 m_headers.clear(); |
| 29 } | 34 } |
| 30 | 35 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 59 void HeaderMap::forEach(PassOwnPtr<HeaderMapForEachCallback> callback) | 64 void HeaderMap::forEach(PassOwnPtr<HeaderMapForEachCallback> callback) |
| 60 { | 65 { |
| 61 forEachInternal(callback, 0); | 66 forEachInternal(callback, 0); |
| 62 } | 67 } |
| 63 | 68 |
| 64 HeaderMap::HeaderMap() | 69 HeaderMap::HeaderMap() |
| 65 { | 70 { |
| 66 ScriptWrappable::init(this); | 71 ScriptWrappable::init(this); |
| 67 } | 72 } |
| 68 | 73 |
| 74 HeaderMap::HeaderMap(const HashMap<String, String>& headers) |
| 75 : m_headers(headers) |
| 76 { |
| 77 ScriptWrappable::init(this); |
| 78 } |
| 79 |
| 69 void HeaderMap::forEachInternal(PassOwnPtr<HeaderMapForEachCallback> callback, S
criptValue* thisArg) | 80 void HeaderMap::forEachInternal(PassOwnPtr<HeaderMapForEachCallback> callback, S
criptValue* thisArg) |
| 70 { | 81 { |
| 71 TrackExceptionState exceptionState; | 82 TrackExceptionState exceptionState; |
| 72 for (HashMap<String, String>::const_iterator it = m_headers.begin(); it != m
_headers.end(); ++it) { | 83 for (HashMap<String, String>::const_iterator it = m_headers.begin(); it != m
_headers.end(); ++it) { |
| 73 if (thisArg) | 84 if (thisArg) |
| 74 callback->handleItem(*thisArg, it->value, it->key, this); | 85 callback->handleItem(*thisArg, it->value, it->key, this); |
| 75 else | 86 else |
| 76 callback->handleItem(it->value, it->key, this); | 87 callback->handleItem(it->value, it->key, this); |
| 77 if (exceptionState.hadException()) | 88 if (exceptionState.hadException()) |
| 78 break; | 89 break; |
| 79 } | 90 } |
| 80 } | 91 } |
| 81 | 92 |
| 82 } // namespace WebCore | 93 } // namespace WebCore |
| OLD | NEW |