Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: third_party/WebKit/Source/core/loader/BeaconLoader.cpp

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/loader/BeaconLoader.h" 5 #include "core/loader/BeaconLoader.h"
6 6
7 #include "core/dom/DOMArrayBufferView.h" 7 #include "core/dom/DOMArrayBufferView.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.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 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 29
30 class Beacon { 30 class Beacon {
31 public: 31 public:
32 virtual bool serialize(ResourceRequest&, int, int&) const = 0; 32 virtual bool serialize(ResourceRequest&, int, int&) const = 0;
33 virtual unsigned long long size() const = 0; 33 virtual unsigned long long size() const = 0;
34 34
35 protected: 35 protected:
36 static unsigned long long beaconSize(const String&); 36 static unsigned long long beaconSize(const String&);
37 static unsigned long long beaconSize(Blob*); 37 static unsigned long long beaconSize(Blob*);
38 static unsigned long long beaconSize(PassRefPtr<DOMArrayBufferView>); 38 static unsigned long long beaconSize(DOMArrayBufferView*);
39 static unsigned long long beaconSize(FormData*); 39 static unsigned long long beaconSize(FormData*);
40 40
41 static bool serialize(const String&, ResourceRequest&, int, int&); 41 static bool serialize(const String&, ResourceRequest&, int, int&);
42 static bool serialize(Blob*, ResourceRequest&, int, int&); 42 static bool serialize(Blob*, ResourceRequest&, int, int&);
43 static bool serialize(PassRefPtr<DOMArrayBufferView>, ResourceRequest&, int, int&); 43 static bool serialize(DOMArrayBufferView*, ResourceRequest&, int, int&);
44 static bool serialize(FormData*, ResourceRequest&, int, int&); 44 static bool serialize(FormData*, ResourceRequest&, int, int&);
45 }; 45 };
46 46
47 template<typename Payload> 47 template<typename Payload>
48 class BeaconData final : public Beacon { 48 class BeaconData final : public Beacon {
49 public: 49 public:
50 BeaconData(const Payload& data) 50 BeaconData(const Payload& data)
51 : m_data(data) 51 : m_data(data)
52 { 52 {
53 } 53 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return true; 103 return true;
104 } 104 }
105 }; 105 };
106 106
107 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, const String& data, int& payloadLength) 107 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, const String& data, int& payloadLength)
108 { 108 {
109 BeaconData<String> beacon(data); 109 BeaconData<String> beacon(data);
110 return Sender::send(frame, allowance, beaconURL, beacon, payloadLength); 110 return Sender::send(frame, allowance, beaconURL, beacon, payloadLength);
111 } 111 }
112 112
113 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, PassRefPtr<DOMArrayBufferView> data, int& payloadLength) 113 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, DOMArrayBufferView* data, int& payloadLength)
114 { 114 {
115 BeaconData<decltype(data)> beacon(data); 115 BeaconData<decltype(data)> beacon(data);
116 return Sender::send(frame, allowance, beaconURL, beacon, payloadLength); 116 return Sender::send(frame, allowance, beaconURL, beacon, payloadLength);
117 } 117 }
118 118
119 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, FormData* data, int& payloadLength) 119 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, FormData* data, int& payloadLength)
120 { 120 {
121 BeaconData<decltype(data)> beacon(data); 121 BeaconData<decltype(data)> beacon(data);
122 return Sender::send(frame, allowance, beaconURL, beacon, payloadLength); 122 return Sender::send(frame, allowance, beaconURL, beacon, payloadLength);
123 } 123 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 request.setHTTPBody(entityBody.release()); 191 request.setHTTPBody(entityBody.release());
192 192
193 const String& blobType = data->type(); 193 const String& blobType = data->type();
194 if (!blobType.isEmpty() && isValidContentType(blobType)) 194 if (!blobType.isEmpty() && isValidContentType(blobType))
195 request.setHTTPContentType(AtomicString(blobType)); 195 request.setHTTPContentType(AtomicString(blobType));
196 196
197 return true; 197 return true;
198 } 198 }
199 199
200 unsigned long long Beacon::beaconSize(PassRefPtr<DOMArrayBufferView> data) 200 unsigned long long Beacon::beaconSize(DOMArrayBufferView* data)
201 { 201 {
202 return data->byteLength(); 202 return data->byteLength();
203 } 203 }
204 204
205 bool Beacon::serialize(PassRefPtr<DOMArrayBufferView> data, ResourceRequest& req uest, int, int&) 205 bool Beacon::serialize(DOMArrayBufferView* data, ResourceRequest& request, int, int&)
206 { 206 {
207 ASSERT(data); 207 ASSERT(data);
208 RefPtr<EncodedFormData> entityBody = EncodedFormData::create(data->baseAddre ss(), data->byteLength()); 208 RefPtr<EncodedFormData> entityBody = EncodedFormData::create(data->baseAddre ss(), data->byteLength());
209 request.setHTTPBody(entityBody.release()); 209 request.setHTTPBody(entityBody.release());
210 210
211 // FIXME: a reasonable choice, but not in the spec; should it give a default ? 211 // FIXME: a reasonable choice, but not in the spec; should it give a default ?
212 AtomicString contentType = AtomicString("application/octet-stream"); 212 AtomicString contentType = AtomicString("application/octet-stream");
213 request.setHTTPContentType(contentType); 213 request.setHTTPContentType(contentType);
214 214
215 return true; 215 return true;
(...skipping 17 matching lines...) Expand all
233 request.setHTTPBody(entityBody.release()); 233 request.setHTTPBody(entityBody.release());
234 request.setHTTPContentType(contentType); 234 request.setHTTPContentType(contentType);
235 235
236 payloadLength = entitySize; 236 payloadLength = entitySize;
237 return true; 237 return true;
238 } 238 }
239 239
240 } // namespace 240 } // namespace
241 241
242 } // namespace blink 242 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698