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

Side by Side Diff: third_party/WebKit/Source/modules/beacon/NavigatorBeacon.cpp

Issue 2610903002: Replace [CallWith=ExecutionContext] with [CallWith=ScriptState] (Closed)
Patch Set: Created 3 years, 11 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 "modules/beacon/NavigatorBeacon.h" 5 #include "modules/beacon/NavigatorBeacon.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" 9 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h"
9 #include "core/dom/DOMArrayBufferView.h" 10 #include "core/dom/DOMArrayBufferView.h"
10 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
11 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
12 #include "core/fetch/FetchUtils.h" 13 #include "core/fetch/FetchUtils.h"
13 #include "core/fileapi/Blob.h" 14 #include "core/fileapi/Blob.h"
14 #include "core/frame/LocalFrame.h" 15 #include "core/frame/LocalFrame.h"
15 #include "core/frame/Settings.h" 16 #include "core/frame/Settings.h"
16 #include "core/frame/UseCounter.h" 17 #include "core/frame/UseCounter.h"
17 #include "core/frame/csp/ContentSecurityPolicy.h" 18 #include "core/frame/csp/ContentSecurityPolicy.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 88 }
88 return m_transmittedBytes; 89 return m_transmittedBytes;
89 } 90 }
90 91
91 void NavigatorBeacon::addTransmittedBytes(int sentBytes) { 92 void NavigatorBeacon::addTransmittedBytes(int sentBytes) {
92 DCHECK_GE(sentBytes, 0); 93 DCHECK_GE(sentBytes, 0);
93 m_transmittedBytes += sentBytes; 94 m_transmittedBytes += sentBytes;
94 } 95 }
95 96
96 bool NavigatorBeacon::sendBeacon( 97 bool NavigatorBeacon::sendBeacon(
97 ExecutionContext* context, 98 ScriptState* scriptState,
98 Navigator& navigator, 99 Navigator& navigator,
99 const String& urlstring, 100 const String& urlstring,
100 const ArrayBufferViewOrBlobOrStringOrFormData& data, 101 const ArrayBufferViewOrBlobOrStringOrFormData& data,
101 ExceptionState& exceptionState) { 102 ExceptionState& exceptionState) {
102 NavigatorBeacon& impl = NavigatorBeacon::from(navigator); 103 NavigatorBeacon& impl = NavigatorBeacon::from(navigator);
103 104
105 ExecutionContext* context = scriptState->getExecutionContext();
104 KURL url = context->completeURL(urlstring); 106 KURL url = context->completeURL(urlstring);
105 if (!impl.canSendBeacon(context, url, exceptionState)) 107 if (!impl.canSendBeacon(context, url, exceptionState))
106 return false; 108 return false;
107 109
108 int allowance = impl.maxAllowance(); 110 int allowance = impl.maxAllowance();
109 int bytes = 0; 111 int bytes = 0;
110 bool allowed; 112 bool allowed;
111 113
112 if (data.isArrayBufferView()) { 114 if (data.isArrayBufferView()) {
113 allowed = PingLoader::sendBeacon(impl.frame(), allowance, url, 115 allowed = PingLoader::sendBeacon(impl.frame(), allowance, url,
(...skipping 27 matching lines...) Expand all
141 if (allowed) { 143 if (allowed) {
142 impl.addTransmittedBytes(bytes); 144 impl.addTransmittedBytes(bytes);
143 return true; 145 return true;
144 } 146 }
145 147
146 UseCounter::count(context, UseCounter::SendBeaconQuotaExceeded); 148 UseCounter::count(context, UseCounter::SendBeaconQuotaExceeded);
147 return false; 149 return false;
148 } 150 }
149 151
150 } // namespace blink 152 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698