| 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/Headers.h" | 6 #include "modules/serviceworkers/Headers.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "core/fetch/FetchUtils.h" | 10 #include "core/fetch/FetchUtils.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (m_guard == RequestNoCORSGuard && !FetchUtils::isSimpleHeader(AtomicStrin
g(name), AtomicString(value))) | 201 if (m_guard == RequestNoCORSGuard && !FetchUtils::isSimpleHeader(AtomicStrin
g(name), AtomicString(value))) |
| 202 return; | 202 return; |
| 203 // "5. Otherwise, if guard is |response| and |name| is a forbidden response | 203 // "5. Otherwise, if guard is |response| and |name| is a forbidden response |
| 204 // header name, return." | 204 // header name, return." |
| 205 if (m_guard == ResponseGuard && FetchUtils::isForbiddenResponseHeaderName(na
me)) | 205 if (m_guard == ResponseGuard && FetchUtils::isForbiddenResponseHeaderName(na
me)) |
| 206 return; | 206 return; |
| 207 // "6. Set |name|/|value| in header list." | 207 // "6. Set |name|/|value| in header list." |
| 208 m_headerList->set(name, value); | 208 m_headerList->set(name, value); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void Headers::forEach(PassOwnPtrWillBeRawPtr<HeadersForEachCallback> callback, c
onst ScriptValue& thisArg) | 211 void Headers::forEach(HeadersForEachCallback* callback, const ScriptValue& thisA
rg) |
| 212 { | 212 { |
| 213 forEachInternal(callback, &thisArg); | 213 forEachInternal(callback, &thisArg); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void Headers::forEach(PassOwnPtrWillBeRawPtr<HeadersForEachCallback> callback) | 216 void Headers::forEach(HeadersForEachCallback* callback) |
| 217 { | 217 { |
| 218 forEachInternal(callback, 0); | 218 forEachInternal(callback, 0); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void Headers::fillWith(const Headers* object, ExceptionState& exceptionState) | 221 void Headers::fillWith(const Headers* object, ExceptionState& exceptionState) |
| 222 { | 222 { |
| 223 ASSERT(m_headerList->size() == 0); | 223 ASSERT(m_headerList->size() == 0); |
| 224 // "To fill a Headers object (|this|) with a given object (|object|), run | 224 // "To fill a Headers object (|this|) with a given object (|object|), run |
| 225 // these steps:" | 225 // these steps:" |
| 226 // "1. If |object| is a Headers object, copy its header list as | 226 // "1. If |object| is a Headers object, copy its header list as |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 , m_guard(NoneGuard) | 298 , m_guard(NoneGuard) |
| 299 { | 299 { |
| 300 } | 300 } |
| 301 | 301 |
| 302 Headers::Headers(FetchHeaderList* headerList) | 302 Headers::Headers(FetchHeaderList* headerList) |
| 303 : m_headerList(headerList) | 303 : m_headerList(headerList) |
| 304 , m_guard(NoneGuard) | 304 , m_guard(NoneGuard) |
| 305 { | 305 { |
| 306 } | 306 } |
| 307 | 307 |
| 308 void Headers::forEachInternal(PassOwnPtrWillBeRawPtr<HeadersForEachCallback> cal
lback, const ScriptValue* thisArg) | 308 void Headers::forEachInternal(HeadersForEachCallback* callback, const ScriptValu
e* thisArg) |
| 309 { | 309 { |
| 310 TrackExceptionState exceptionState; | 310 TrackExceptionState exceptionState; |
| 311 for (size_t i = 0; i < m_headerList->size(); ++i) { | 311 for (size_t i = 0; i < m_headerList->size(); ++i) { |
| 312 if (thisArg) | 312 if (thisArg) |
| 313 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); | 313 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); |
| 314 else | 314 else |
| 315 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); | 315 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); |
| 316 if (exceptionState.hadException()) | 316 if (exceptionState.hadException()) |
| 317 break; | 317 break; |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 void Headers::trace(Visitor* visitor) | 321 void Headers::trace(Visitor* visitor) |
| 322 { | 322 { |
| 323 visitor->trace(m_headerList); | 323 visitor->trace(m_headerList); |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace blink | 326 } // namespace blink |
| OLD | NEW |