| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (m_guard == RequestNoCORSGuard && !FetchUtils::isSimpleHeader(AtomicStrin
g(name), AtomicString(value))) | 203 if (m_guard == RequestNoCORSGuard && !FetchUtils::isSimpleHeader(AtomicStrin
g(name), AtomicString(value))) |
| 204 return; | 204 return; |
| 205 // "5. Otherwise, if guard is |response| and |name| is a forbidden response | 205 // "5. Otherwise, if guard is |response| and |name| is a forbidden response |
| 206 // header name, return." | 206 // header name, return." |
| 207 if (m_guard == ResponseGuard && FetchUtils::isForbiddenResponseHeaderName(na
me)) | 207 if (m_guard == ResponseGuard && FetchUtils::isForbiddenResponseHeaderName(na
me)) |
| 208 return; | 208 return; |
| 209 // "6. Set |name|/|value| in header list." | 209 // "6. Set |name|/|value| in header list." |
| 210 m_headerList->set(name, value); | 210 m_headerList->set(name, value); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void Headers::forEach(PassOwnPtr<HeadersForEachCallback> callback, ScriptValue&
thisArg) | 213 void Headers::forEach(PassOwnPtr<HeadersForEachCallback> callback, const Optiona
l<ScriptValue>& thisArg) |
| 214 { | 214 { |
| 215 forEachInternal(callback, &thisArg); | 215 TrackExceptionState exceptionState; |
| 216 } | 216 for (size_t i = 0; i < m_headerList->size(); ++i) { |
| 217 | 217 if (thisArg.isMissing()) |
| 218 void Headers::forEach(PassOwnPtr<HeadersForEachCallback> callback) | 218 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); |
| 219 { | 219 else |
| 220 forEachInternal(callback, 0); | 220 callback->handleItem(thisArg.get(), m_headerList->list()[i]->second,
m_headerList->list()[i]->first, this); |
| 221 if (exceptionState.hadException()) |
| 222 break; |
| 223 } |
| 221 } | 224 } |
| 222 | 225 |
| 223 void Headers::fillWith(const Headers* object, ExceptionState& exceptionState) | 226 void Headers::fillWith(const Headers* object, ExceptionState& exceptionState) |
| 224 { | 227 { |
| 225 ASSERT(m_headerList->size() == 0); | 228 ASSERT(m_headerList->size() == 0); |
| 226 // "To fill a Headers object (|this|) with a given object (|object|), run | 229 // "To fill a Headers object (|this|) with a given object (|object|), run |
| 227 // these steps:" | 230 // these steps:" |
| 228 // "1. If |object| is a Headers object, copy its header list as | 231 // "1. If |object| is a Headers object, copy its header list as |
| 229 // |headerListCopy| and then for each |header| in |headerListCopy|, | 232 // |headerListCopy| and then for each |header| in |headerListCopy|, |
| 230 // retaining order, append header's |name|/|header|'s value to | 233 // retaining order, append header's |name|/|header|'s value to |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 ScriptWrappable::init(this); | 305 ScriptWrappable::init(this); |
| 303 } | 306 } |
| 304 | 307 |
| 305 Headers::Headers(FetchHeaderList* headerList) | 308 Headers::Headers(FetchHeaderList* headerList) |
| 306 : m_headerList(headerList) | 309 : m_headerList(headerList) |
| 307 , m_guard(NoneGuard) | 310 , m_guard(NoneGuard) |
| 308 { | 311 { |
| 309 ScriptWrappable::init(this); | 312 ScriptWrappable::init(this); |
| 310 } | 313 } |
| 311 | 314 |
| 312 void Headers::forEachInternal(PassOwnPtr<HeadersForEachCallback> callback, Scrip
tValue* thisArg) | |
| 313 { | |
| 314 TrackExceptionState exceptionState; | |
| 315 for (size_t i = 0; i < m_headerList->size(); ++i) { | |
| 316 if (thisArg) | |
| 317 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); | |
| 318 else | |
| 319 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); | |
| 320 if (exceptionState.hadException()) | |
| 321 break; | |
| 322 } | |
| 323 } | |
| 324 | |
| 325 void Headers::trace(Visitor* visitor) | 315 void Headers::trace(Visitor* visitor) |
| 326 { | 316 { |
| 327 visitor->trace(m_headerList); | 317 visitor->trace(m_headerList); |
| 328 } | 318 } |
| 329 | 319 |
| 330 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |