| 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/CrossOriginAccessControl.h" | 10 #include "core/fetch/CrossOriginAccessControl.h" |
| 11 #include "core/xml/XMLHttpRequest.h" | 11 #include "core/xml/XMLHttpRequest.h" |
| 12 #include "modules/serviceworkers/HeadersForEachCallback.h" | 12 #include "modules/serviceworkers/HeadersForEachCallback.h" |
| 13 #include "wtf/NotFound.h" | 13 #include "wtf/NotFound.h" |
| 14 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
| 15 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
| 16 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
| 17 | 17 |
| 18 namespace WebCore { | 18 namespace WebCore { |
| 19 | 19 |
| 20 PassRefPtr<Headers> Headers::create() | 20 PassRefPtrWillBeRawPtr<Headers> Headers::create() |
| 21 { | 21 { |
| 22 return adoptRef(new Headers); | 22 return adoptRefWillBeNoop(new Headers); |
| 23 } | 23 } |
| 24 | 24 |
| 25 PassRefPtr<Headers> Headers::create(ExceptionState&) | 25 PassRefPtrWillBeRawPtr<Headers> Headers::create(ExceptionState&) |
| 26 { | 26 { |
| 27 return create(); | 27 return create(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 PassRefPtr<Headers> Headers::create(const Headers* init, ExceptionState& excepti
onState) | 30 PassRefPtrWillBeRawPtr<Headers> Headers::create(const Headers* init, ExceptionSt
ate& exceptionState) |
| 31 { | 31 { |
| 32 // "The Headers(|init|) constructor, when invoked, must run these steps:" | 32 // "The Headers(|init|) constructor, when invoked, must run these steps:" |
| 33 // "1. Let |headers| be a new Headers object." | 33 // "1. Let |headers| be a new Headers object." |
| 34 RefPtr<Headers> headers = create(); | 34 RefPtrWillBeRawPtr<Headers> headers = create(); |
| 35 // "2. If |init| is given, fill headers with |init|. Rethrow any exception." | 35 // "2. If |init| is given, fill headers with |init|. Rethrow any exception." |
| 36 headers->fillWith(init, exceptionState); | 36 headers->fillWith(init, exceptionState); |
| 37 // "3. Return |headers|." | 37 // "3. Return |headers|." |
| 38 return headers.release(); | 38 return headers.release(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 PassRefPtr<Headers> Headers::create(const Dictionary& init, ExceptionState& exce
ptionState) | 41 PassRefPtrWillBeRawPtr<Headers> Headers::create(const Dictionary& init, Exceptio
nState& exceptionState) |
| 42 { | 42 { |
| 43 // "The Headers(|init|) constructor, when invoked, must run these steps:" | 43 // "The Headers(|init|) constructor, when invoked, must run these steps:" |
| 44 // "1. Let |headers| be a new Headers object." | 44 // "1. Let |headers| be a new Headers object." |
| 45 RefPtr<Headers> headers = create(); | 45 RefPtrWillBeRawPtr<Headers> headers = create(); |
| 46 // "2. If |init| is given, fill headers with |init|. Rethrow any exception." | 46 // "2. If |init| is given, fill headers with |init|. Rethrow any exception." |
| 47 headers->fillWith(init, exceptionState); | 47 headers->fillWith(init, exceptionState); |
| 48 // "3. Return |headers|." | 48 // "3. Return |headers|." |
| 49 return headers.release(); | 49 return headers.release(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtr<Headers> Headers::create(FetchHeaderList* headerList) | 52 PassRefPtrWillBeRawPtr<Headers> Headers::create(FetchHeaderList* headerList) |
| 53 { | 53 { |
| 54 return adoptRef(new Headers(headerList)); | 54 return adoptRefWillBeNoop(new Headers(headerList)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 PassRefPtr<Headers> Headers::createCopy() const | 57 PassRefPtrWillBeRawPtr<Headers> Headers::createCopy() const |
| 58 { | 58 { |
| 59 RefPtr<FetchHeaderList> headerList = m_headerList->createCopy(); | 59 RefPtrWillBeRawPtr<FetchHeaderList> headerList = m_headerList->createCopy(); |
| 60 RefPtr<Headers> headers = create(headerList.get()); | 60 RefPtrWillBeRawPtr<Headers> headers = create(headerList.get()); |
| 61 headers->m_guard = m_guard; | 61 headers->m_guard = m_guard; |
| 62 return headers.release(); | 62 return headers.release(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 Headers::~Headers() | 65 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Headers); |
| 66 { | |
| 67 } | |
| 68 | 66 |
| 69 unsigned long Headers::size() const | 67 unsigned long Headers::size() const |
| 70 { | 68 { |
| 71 return m_headerList->size(); | 69 return m_headerList->size(); |
| 72 } | 70 } |
| 73 | 71 |
| 74 void Headers::append(const String& name, const String& value, ExceptionState& ex
ceptionState) | 72 void Headers::append(const String& name, const String& value, ExceptionState& ex
ceptionState) |
| 75 { | 73 { |
| 76 // "To append a name/value (|name|/|value|) pair to a Headers object | 74 // "To append a name/value (|name|/|value|) pair to a Headers object |
| 77 // (|headers|), run these steps:" | 75 // (|headers|), run these steps:" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 for (size_t i = 0; i < m_headerList->size(); ++i) { | 315 for (size_t i = 0; i < m_headerList->size(); ++i) { |
| 318 if (thisArg) | 316 if (thisArg) |
| 319 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); |
| 320 else | 318 else |
| 321 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); |
| 322 if (exceptionState.hadException()) | 320 if (exceptionState.hadException()) |
| 323 break; | 321 break; |
| 324 } | 322 } |
| 325 } | 323 } |
| 326 | 324 |
| 325 void Headers::trace(Visitor* visitor) |
| 326 { |
| 327 visitor->trace(m_headerList); |
| 328 } |
| 329 |
| 327 } // namespace WebCore | 330 } // namespace WebCore |
| OLD | NEW |