Chromium Code Reviews| Index: Source/modules/fetch/Headers.cpp |
| diff --git a/Source/modules/fetch/Headers.cpp b/Source/modules/fetch/Headers.cpp |
| index db5461a94002cee02b06e7c04feaaee618883569..0c8118617c06bc3bd368f03be8935c011e9e3474 100644 |
| --- a/Source/modules/fetch/Headers.cpp |
| +++ b/Source/modules/fetch/Headers.cpp |
| @@ -19,53 +19,31 @@ namespace blink { |
| namespace { |
| -class HeadersIterator final : public Iterator { |
| +class HeadersIterationSource final : public PairIterable<String, String>::IterationSource { |
| public: |
| - // Only KeyValue is currently used; the other types are to support |
| - // Map-like iteration with entries(), keys() and values(), but this has |
| - // not yet been added to any spec. |
| - enum IterationType { KeyValue, Key, Value }; |
| + HeadersIterationSource(FetchHeaderList* headers) : m_headers(headers), m_current(0) { } |
| - HeadersIterator(FetchHeaderList* headers, IterationType type) : m_headers(headers), m_type(type), m_current(0) { } |
| - |
| - virtual ScriptValue next(ScriptState* scriptState, ExceptionState& exception) override |
| + virtual bool next(ScriptState* scriptState, String& key, String& value, ExceptionState& exception) override |
| { |
| // FIXME: This simply advances an index and returns the next value if |
| // any, so if the iterated object is mutated values may be skipped. |
| if (m_current >= m_headers->size()) |
| - return v8IteratorResultDone(scriptState); |
| + return false; |
| const FetchHeaderList::Header& header = m_headers->entry(m_current++); |
| - switch (m_type) { |
| - case KeyValue: { |
| - Vector<String> pair; |
| - pair.append(header.first); |
| - pair.append(header.second); |
| - return v8IteratorResult(scriptState, pair); |
| - } |
| - case Key: |
| - return v8IteratorResult(scriptState, header.first); |
| - case Value: |
| - return v8IteratorResult(scriptState, header.second); |
| - } |
| - ASSERT_NOT_REACHED(); |
| - return ScriptValue(); |
| - } |
| - |
| - virtual ScriptValue next(ScriptState* scriptState, ScriptValue, ExceptionState& exceptionState) override |
| - { |
| - return next(scriptState, exceptionState); |
| + key = header.first; |
| + value = header.second; |
| + return true; |
| } |
| virtual void trace(Visitor* visitor) |
| { |
| - Iterator::trace(visitor); |
| + PairIterable<String, String>::IterationSource::trace(visitor); |
| visitor->trace(m_headers); |
| } |
| private: |
| const Member<FetchHeaderList> m_headers; |
| - const IterationType m_type; |
| size_t m_current; |
|
jsbell
2015/01/12 17:14:08
Why not use m_index here?
Jens Widell
2015/01/12 17:24:14
There is no m_index in scope here, since we're inh
|
| }; |
| @@ -340,14 +318,14 @@ Headers::Headers(FetchHeaderList* headerList) |
| { |
| } |
| -Iterator* Headers::iterator(ScriptState*, ExceptionState&) |
| +void Headers::trace(Visitor* visitor) |
| { |
| - return new HeadersIterator(m_headerList, HeadersIterator::KeyValue); |
| + visitor->trace(m_headerList); |
| } |
| -void Headers::trace(Visitor* visitor) |
| +PairIterable<String, String>::IterationSource* Headers::startIteration(ScriptState*, ExceptionState&) |
| { |
| - visitor->trace(m_headerList); |
| + return new HeadersIterationSource(m_headerList); |
| } |
| } // namespace blink |