| 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 // Called when creating Request. | 52 // Called when creating Request. |
| 53 PassRefPtr<Headers> Headers::create(FetchHeaderList* headerList) | 53 PassRefPtrWillBeRawPtr<Headers> Headers::create(FetchHeaderList* headerList) |
| 54 { | 54 { |
| 55 return adoptRef(new Headers(headerList)); | 55 return adoptRefWillBeNoop(new Headers(headerList)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 PassRefPtr<Headers> Headers::createCopy() const | 58 PassRefPtrWillBeRawPtr<Headers> Headers::createCopy() const |
| 59 { | 59 { |
| 60 RefPtr<FetchHeaderList> headerList = m_headerList->createCopy(); | 60 RefPtrWillBeRawPtr<FetchHeaderList> headerList = m_headerList->createCopy(); |
| 61 RefPtr<Headers> headers = create(headerList.get()); | 61 RefPtrWillBeRawPtr<Headers> headers = create(headerList.get()); |
| 62 headers->m_guard = m_guard; | 62 headers->m_guard = m_guard; |
| 63 return headers.release(); | 63 return headers.release(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 Headers::~Headers() | 66 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Headers); |
| 67 { | |
| 68 } | |
| 69 | 67 |
| 70 unsigned long Headers::size() const | 68 unsigned long Headers::size() const |
| 71 { | 69 { |
| 72 return m_headerList->size(); | 70 return m_headerList->size(); |
| 73 } | 71 } |
| 74 | 72 |
| 75 void Headers::append(const String& name, const String& value, ExceptionState& ex
ceptionState) | 73 void Headers::append(const String& name, const String& value, ExceptionState& ex
ceptionState) |
| 76 { | 74 { |
| 77 // "To append a name/value (|name|/|value|) pair to a Headers object | 75 // "To append a name/value (|name|/|value|) pair to a Headers object |
| 78 // (|headers|), run these steps:" | 76 // (|headers|), run these steps:" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 for (size_t i = 0; i < m_headerList->size(); ++i) { | 317 for (size_t i = 0; i < m_headerList->size(); ++i) { |
| 320 if (thisArg) | 318 if (thisArg) |
| 321 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); | 319 callback->handleItem(*thisArg, m_headerList->list()[i]->second, m_he
aderList->list()[i]->first, this); |
| 322 else | 320 else |
| 323 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); | 321 callback->handleItem(m_headerList->list()[i]->second, m_headerList->
list()[i]->first, this); |
| 324 if (exceptionState.hadException()) | 322 if (exceptionState.hadException()) |
| 325 break; | 323 break; |
| 326 } | 324 } |
| 327 } | 325 } |
| 328 | 326 |
| 327 void Headers::trace(Visitor* visitor) |
| 328 { |
| 329 visitor->trace(m_headerList); |
| 330 } |
| 331 |
| 329 } // namespace WebCore | 332 } // namespace WebCore |
| OLD | NEW |