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

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

Issue 714123002: Use union type for NavigatorBeacon.sendBeacon()'s data argument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 1 month 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
« no previous file with comments | « Source/core/loader/BeaconLoader.h ('k') | Source/modules/beacon/NavigatorBeacon.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 AtomicString contentType; 98 AtomicString contentType;
99 const String& blobType = data->type(); 99 const String& blobType = data->type();
100 if (!blobType.isEmpty() && isValidContentType(blobType)) 100 if (!blobType.isEmpty() && isValidContentType(blobType))
101 request.setHTTPContentType(AtomicString(contentType)); 101 request.setHTTPContentType(AtomicString(contentType));
102 102
103 issueRequest(frame, request); 103 issueRequest(frame, request);
104 payloadLength = entitySize; 104 payloadLength = entitySize;
105 return true; 105 return true;
106 } 106 }
107 107
108 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, PassRefPtrWillBeRawPtr<DOMFormData>& data, int& payloadLength) 108 bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beac onURL, PassRefPtrWillBeRawPtr<DOMFormData> data, int& payloadLength)
109 { 109 {
110 ASSERT(data); 110 ASSERT(data);
111 ResourceRequest request(beaconURL); 111 ResourceRequest request(beaconURL);
112 prepareRequest(frame, request); 112 prepareRequest(frame, request);
113 113
114 RefPtr<FormData> entityBody = data->createMultiPartFormData(); 114 RefPtr<FormData> entityBody = data->createMultiPartFormData();
115 115
116 unsigned long long entitySize = entityBody->sizeInBytes(); 116 unsigned long long entitySize = entityBody->sizeInBytes();
117 if (allowance > 0 && static_cast<unsigned long long>(allowance) < entitySize ) 117 if (allowance > 0 && static_cast<unsigned long long>(allowance) < entitySize )
118 return false; 118 return false;
119 119
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
OLDNEW
« no previous file with comments | « Source/core/loader/BeaconLoader.h ('k') | Source/modules/beacon/NavigatorBeacon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698