| 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 ScriptV
alue& thisArg) |
| 214 { | 214 { |
| 215 forEachInternal(callback, &thisArg); | 215 forEachInternal(callback, &thisArg); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void Headers::forEach(PassOwnPtr<HeadersForEachCallback> callback) | 218 void Headers::forEach(PassOwnPtr<HeadersForEachCallback> callback) |
| 219 { | 219 { |
| 220 forEachInternal(callback, 0); | 220 forEachInternal(callback, 0); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void Headers::fillWith(const Headers* object, ExceptionState& exceptionState) | 223 void Headers::fillWith(const Headers* object, ExceptionState& exceptionState) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 ScriptWrappable::init(this); | 302 ScriptWrappable::init(this); |
| 303 } | 303 } |
| 304 | 304 |
| 305 Headers::Headers(FetchHeaderList* headerList) | 305 Headers::Headers(FetchHeaderList* headerList) |
| 306 : m_headerList(headerList) | 306 : m_headerList(headerList) |
| 307 , m_guard(NoneGuard) | 307 , m_guard(NoneGuard) |
| 308 { | 308 { |
| 309 ScriptWrappable::init(this); | 309 ScriptWrappable::init(this); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void Headers::forEachInternal(PassOwnPtr<HeadersForEachCallback> callback, Scrip
tValue* thisArg) | 312 void Headers::forEachInternal(PassOwnPtr<HeadersForEachCallback> callback, const
ScriptValue* thisArg) |
| 313 { | 313 { |
| 314 TrackExceptionState exceptionState; | 314 TrackExceptionState exceptionState; |
| 315 for (size_t i = 0; i < m_headerList->size(); ++i) { | 315 for (size_t i = 0; i < m_headerList->size(); ++i) { |
| 316 if (thisArg) | 316 if (thisArg) |
| 317 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); | 317 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); |
| 318 else | 318 else |
| 319 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); | 319 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); |
| 320 if (exceptionState.hadException()) | 320 if (exceptionState.hadException()) |
| 321 break; | 321 break; |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 void Headers::trace(Visitor* visitor) | 325 void Headers::trace(Visitor* visitor) |
| 326 { | 326 { |
| 327 visitor->trace(m_headerList); | 327 visitor->trace(m_headerList); |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace blink | 330 } // namespace blink |
| OLD | NEW |