| 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/fetch/Headers.h" | 6 #include "modules/fetch/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 "bindings/core/v8/V8IteratorResultValue.h" | 10 #include "bindings/core/v8/V8IteratorResultValue.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 { | 63 { |
| 64 // "The Headers(|init|) constructor, when invoked, must run these steps:" | 64 // "The Headers(|init|) constructor, when invoked, must run these steps:" |
| 65 // "1. Let |headers| be a new Headers object." | 65 // "1. Let |headers| be a new Headers object." |
| 66 Headers* headers = create(); | 66 Headers* headers = create(); |
| 67 // "2. If |init| is given, fill headers with |init|. Rethrow any exception." | 67 // "2. If |init| is given, fill headers with |init|. Rethrow any exception." |
| 68 headers->fillWith(init, exceptionState); | 68 headers->fillWith(init, exceptionState); |
| 69 // "3. Return |headers|." | 69 // "3. Return |headers|." |
| 70 return headers; | 70 return headers; |
| 71 } | 71 } |
| 72 | 72 |
| 73 Headers* Headers::create(const Vector<Vector<String> >& init, ExceptionState& ex
ceptionState) | 73 Headers* Headers::create(const Vector<Vector<String>>& init, ExceptionState& exc
eptionState) |
| 74 { | 74 { |
| 75 // The same steps as above. | 75 // The same steps as above. |
| 76 Headers* headers = create(); | 76 Headers* headers = create(); |
| 77 headers->fillWith(init, exceptionState); | 77 headers->fillWith(init, exceptionState); |
| 78 return headers; | 78 return headers; |
| 79 } | 79 } |
| 80 | 80 |
| 81 Headers* Headers::create(const Dictionary& init, ExceptionState& exceptionState) | 81 Headers* Headers::create(const Dictionary& init, ExceptionState& exceptionState) |
| 82 { | 82 { |
| 83 // "The Headers(|init|) constructor, when invoked, must run these steps:" | 83 // "The Headers(|init|) constructor, when invoked, must run these steps:" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // |headerListCopy| and then for each |header| in |headerListCopy|, | 252 // |headerListCopy| and then for each |header| in |headerListCopy|, |
| 253 // retaining order, append header's |name|/|header|'s value to | 253 // retaining order, append header's |name|/|header|'s value to |
| 254 // |headers|. Rethrow any exception." | 254 // |headers|. Rethrow any exception." |
| 255 for (size_t i = 0; i < object->m_headerList->list().size(); ++i) { | 255 for (size_t i = 0; i < object->m_headerList->list().size(); ++i) { |
| 256 append(object->m_headerList->list()[i]->first, object->m_headerList->lis
t()[i]->second, exceptionState); | 256 append(object->m_headerList->list()[i]->first, object->m_headerList->lis
t()[i]->second, exceptionState); |
| 257 if (exceptionState.hadException()) | 257 if (exceptionState.hadException()) |
| 258 return; | 258 return; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 void Headers::fillWith(const Vector<Vector<String> >& object, ExceptionState& ex
ceptionState) | 262 void Headers::fillWith(const Vector<Vector<String>>& object, ExceptionState& exc
eptionState) |
| 263 { | 263 { |
| 264 ASSERT(!m_headerList->size()); | 264 ASSERT(!m_headerList->size()); |
| 265 // "2. Otherwise, if |object| is a sequence, then for each |header| in | 265 // "2. Otherwise, if |object| is a sequence, then for each |header| in |
| 266 // |object|, run these substeps: | 266 // |object|, run these substeps: |
| 267 // 1. If |header| does not contain exactly two items, throw a | 267 // 1. If |header| does not contain exactly two items, throw a |
| 268 // TypeError. | 268 // TypeError. |
| 269 // 2. Append |header|'s first item/|header|'s second item to | 269 // 2. Append |header|'s first item/|header|'s second item to |
| 270 // |headers|. Rethrow any exception." | 270 // |headers|. Rethrow any exception." |
| 271 for (size_t i = 0; i < object.size(); ++i) { | 271 for (size_t i = 0; i < object.size(); ++i) { |
| 272 if (object[i].size() != 2) { | 272 if (object[i].size() != 2) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 { | 322 { |
| 323 visitor->trace(m_headerList); | 323 visitor->trace(m_headerList); |
| 324 } | 324 } |
| 325 | 325 |
| 326 PairIterable<String, String>::IterationSource* Headers::startIteration(ScriptSta
te*, ExceptionState&) | 326 PairIterable<String, String>::IterationSource* Headers::startIteration(ScriptSta
te*, ExceptionState&) |
| 327 { | 327 { |
| 328 return new HeadersIterationSource(m_headerList); | 328 return new HeadersIterationSource(m_headerList); |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace blink | 331 } // namespace blink |
| OLD | NEW |