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/FetchUtils.h" | 10 #include "core/fetch/FetchUtils.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 blink { | 18 namespace blink { |
19 | 19 |
20 PassRefPtrWillBeRawPtr<Headers> Headers::create() | 20 Headers* Headers::create() |
21 { | 21 { |
22 return adoptRefWillBeNoop(new Headers); | 22 return new Headers; |
23 } | 23 } |
24 | 24 |
25 PassRefPtrWillBeRawPtr<Headers> Headers::create(ExceptionState&) | 25 Headers* Headers::create(ExceptionState&) |
26 { | 26 { |
27 return create(); | 27 return create(); |
28 } | 28 } |
29 | 29 |
30 PassRefPtrWillBeRawPtr<Headers> Headers::create(const Headers* init, ExceptionSt
ate& exceptionState) | 30 Headers* Headers::create(const Headers* init, ExceptionState& 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 RefPtrWillBeRawPtr<Headers> headers = create(); | 34 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; |
39 } | 39 } |
40 | 40 |
41 PassRefPtrWillBeRawPtr<Headers> Headers::create(const Dictionary& init, Exceptio
nState& exceptionState) | 41 Headers* Headers::create(const Dictionary& init, ExceptionState& 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 RefPtrWillBeRawPtr<Headers> headers = create(); | 45 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; |
50 } | 50 } |
51 | 51 |
52 PassRefPtrWillBeRawPtr<Headers> Headers::create(FetchHeaderList* headerList) | 52 Headers* Headers::create(FetchHeaderList* headerList) |
53 { | 53 { |
54 return adoptRefWillBeNoop(new Headers(headerList)); | 54 return new Headers(headerList); |
55 } | 55 } |
56 | 56 |
57 PassRefPtrWillBeRawPtr<Headers> Headers::createCopy() const | 57 Headers* Headers::createCopy() const |
58 { | 58 { |
59 RefPtrWillBeRawPtr<FetchHeaderList> headerList = m_headerList->createCopy(); | 59 FetchHeaderList* headerList = m_headerList->createCopy(); |
60 RefPtrWillBeRawPtr<Headers> headers = create(headerList.get()); | 60 Headers* headers = create(headerList); |
61 headers->m_guard = m_guard; | 61 headers->m_guard = m_guard; |
62 return headers.release(); | 62 return headers; |
63 } | 63 } |
64 | 64 |
65 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Headers); | |
66 | |
67 unsigned long Headers::size() const | 65 unsigned long Headers::size() const |
68 { | 66 { |
69 return m_headerList->size(); | 67 return m_headerList->size(); |
70 } | 68 } |
71 | 69 |
72 void Headers::append(const String& name, const String& value, ExceptionState& ex
ceptionState) | 70 void Headers::append(const String& name, const String& value, ExceptionState& ex
ceptionState) |
73 { | 71 { |
74 // "To append a name/value (|name|/|value|) pair to a Headers object | 72 // "To append a name/value (|name|/|value|) pair to a Headers object |
75 // (|headers|), run these steps:" | 73 // (|headers|), run these steps:" |
76 // "1. If |name| is not a name or |value| is not a value, throw a | 74 // "1. If |name| is not a name or |value| is not a value, throw a |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 break; | 319 break; |
322 } | 320 } |
323 } | 321 } |
324 | 322 |
325 void Headers::trace(Visitor* visitor) | 323 void Headers::trace(Visitor* visitor) |
326 { | 324 { |
327 visitor->trace(m_headerList); | 325 visitor->trace(m_headerList); |
328 } | 326 } |
329 | 327 |
330 } // namespace blink | 328 } // namespace blink |
OLD | NEW |