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 "core/loader/BeaconLoader.h" | 6 #include "core/loader/BeaconLoader.h" |
7 | 7 |
8 #include "core/FetchInitiatorTypeNames.h" | 8 #include "core/FetchInitiatorTypeNames.h" |
9 #include "core/fetch/CrossOriginAccessControl.h" | 9 #include "core/fetch/CrossOriginAccessControl.h" |
10 #include "core/fetch/FetchContext.h" | 10 #include "core/fetch/FetchContext.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return false; | 48 return false; |
49 | 49 |
50 request.setHTTPBody(entityBody); | 50 request.setHTTPBody(entityBody); |
51 request.setHTTPContentType("text/plain;charset=UTF-8"); | 51 request.setHTTPContentType("text/plain;charset=UTF-8"); |
52 | 52 |
53 issueRequest(frame, request); | 53 issueRequest(frame, request); |
54 payloadLength = entitySize; | 54 payloadLength = entitySize; |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac
onURL, PassRefPtr<ArrayBufferView>& data, int& payloadLength) | 58 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac
onURL, PassRefPtr<ArrayBufferView> data, int& payloadLength) |
59 { | 59 { |
60 ASSERT(data); | 60 ASSERT(data); |
61 unsigned long long entitySize = data->byteLength(); | 61 unsigned long long entitySize = data->byteLength(); |
62 if (allowance > 0 && static_cast<unsigned long long>(allowance) < entitySize
) | 62 if (allowance > 0 && static_cast<unsigned long long>(allowance) < entitySize
) |
63 return false; | 63 return false; |
64 | 64 |
65 ResourceRequest request(beaconURL); | 65 ResourceRequest request(beaconURL); |
66 prepareRequest(frame, request); | 66 prepareRequest(frame, request); |
67 | 67 |
68 RefPtr<FormData> entityBody = FormData::create(data->baseAddress(), data->by
teLength()); | 68 RefPtr<FormData> entityBody = FormData::create(data->baseAddress(), data->by
teLength()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 AtomicString contentType = AtomicString("multipart/form-data; boundary=", At
omicString::ConstructFromLiteral) + entityBody->boundary().data(); | 120 AtomicString contentType = AtomicString("multipart/form-data; boundary=", At
omicString::ConstructFromLiteral) + entityBody->boundary().data(); |
121 request.setHTTPBody(entityBody.release()); | 121 request.setHTTPBody(entityBody.release()); |
122 request.setHTTPContentType(contentType); | 122 request.setHTTPContentType(contentType); |
123 | 123 |
124 issueRequest(frame, request); | 124 issueRequest(frame, request); |
125 payloadLength = entitySize; | 125 payloadLength = entitySize; |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 } // namespace blink | 129 } // namespace blink |
OLD | NEW |