| 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 "modules/fetch/Headers.h" | 5 #include "modules/fetch/Headers.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/V8IteratorResultValue.h" | 9 #include "bindings/core/v8/V8IteratorResultValue.h" |
| 10 #include "core/dom/Iterator.h" | 10 #include "core/dom/Iterator.h" |
| 11 #include "core/fetch/FetchUtils.h" | 11 #include "core/fetch/FetchUtils.h" |
| 12 #include "wtf/NotFound.h" | 12 #include "wtf/NotFound.h" |
| 13 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
| 14 #include "wtf/RefPtr.h" | 14 #include "wtf/RefPtr.h" |
| 15 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class HeadersIterationSource final | 21 class HeadersIterationSource final |
| 22 : public PairIterable<String, String>::IterationSource { | 22 : public PairIterable<String, String>::IterationSource { |
| 23 public: | 23 public: |
| 24 explicit HeadersIterationSource(FetchHeaderList* headers) | 24 explicit HeadersIterationSource(const FetchHeaderList* headers) |
| 25 : m_headers(headers), m_current(0) {} | 25 : m_headers(headers->clone()), m_current(0) { |
| 26 m_headers->sortAndCombine(); |
| 27 } |
| 26 | 28 |
| 27 bool next(ScriptState* scriptState, | 29 bool next(ScriptState* scriptState, |
| 28 String& key, | 30 String& key, |
| 29 String& value, | 31 String& value, |
| 30 ExceptionState& exception) override { | 32 ExceptionState& exception) override { |
| 31 // FIXME: This simply advances an index and returns the next value if | 33 // This simply advances an index and returns the next value if any; the |
| 32 // any, so if the iterated object is mutated values may be skipped. | 34 // iterated list is not exposed to script so it will never be mutated |
| 35 // during iteration. |
| 33 if (m_current >= m_headers->size()) | 36 if (m_current >= m_headers->size()) |
| 34 return false; | 37 return false; |
| 35 | 38 |
| 36 const FetchHeaderList::Header& header = m_headers->entry(m_current++); | 39 const FetchHeaderList::Header& header = m_headers->entry(m_current++); |
| 37 key = header.first; | 40 key = header.first; |
| 38 value = header.second; | 41 value = header.second; |
| 39 return true; | 42 return true; |
| 40 } | 43 } |
| 41 | 44 |
| 42 DEFINE_INLINE_VIRTUAL_TRACE() { | 45 DEFINE_INLINE_VIRTUAL_TRACE() { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 visitor->trace(m_headerList); | 320 visitor->trace(m_headerList); |
| 318 } | 321 } |
| 319 | 322 |
| 320 PairIterable<String, String>::IterationSource* Headers::startIteration( | 323 PairIterable<String, String>::IterationSource* Headers::startIteration( |
| 321 ScriptState*, | 324 ScriptState*, |
| 322 ExceptionState&) { | 325 ExceptionState&) { |
| 323 return new HeadersIterationSource(m_headerList); | 326 return new HeadersIterationSource(m_headerList); |
| 324 } | 327 } |
| 325 | 328 |
| 326 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |