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 "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/core/v8/ScriptState.h" |
9 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" | 9 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" |
10 #include "core/dom/DOMArrayBufferView.h" | 10 #include "core/dom/DOMArrayBufferView.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ExceptionState& exception_state) { | 99 ExceptionState& exception_state) { |
100 return NavigatorBeacon::From(navigator).SendBeaconImpl( | 100 return NavigatorBeacon::From(navigator).SendBeaconImpl( |
101 script_state, urlstring, data, exception_state); | 101 script_state, urlstring, data, exception_state); |
102 } | 102 } |
103 | 103 |
104 bool NavigatorBeacon::SendBeaconImpl( | 104 bool NavigatorBeacon::SendBeaconImpl( |
105 ScriptState* script_state, | 105 ScriptState* script_state, |
106 const String& urlstring, | 106 const String& urlstring, |
107 const ArrayBufferViewOrBlobOrStringOrFormData& data, | 107 const ArrayBufferViewOrBlobOrStringOrFormData& data, |
108 ExceptionState& exception_state) { | 108 ExceptionState& exception_state) { |
109 ExecutionContext* context = script_state->GetExecutionContext(); | 109 ExecutionContext* context = ExecutionContext::From(script_state); |
110 KURL url = context->CompleteURL(urlstring); | 110 KURL url = context->CompleteURL(urlstring); |
111 if (!CanSendBeacon(context, url, exception_state)) | 111 if (!CanSendBeacon(context, url, exception_state)) |
112 return false; | 112 return false; |
113 | 113 |
114 int allowance = MaxAllowance(); | 114 int allowance = MaxAllowance(); |
115 size_t beacon_size = 0; | 115 size_t beacon_size = 0; |
116 bool allowed; | 116 bool allowed; |
117 | 117 |
118 if (data.isArrayBufferView()) { | 118 if (data.isArrayBufferView()) { |
119 allowed = | 119 allowed = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return false; | 151 return false; |
152 } | 152 } |
153 | 153 |
154 // Only accumulate transmission size if a limit is imposed. | 154 // Only accumulate transmission size if a limit is imposed. |
155 if (allowance >= 0) | 155 if (allowance >= 0) |
156 AddTransmittedBytes(beacon_size); | 156 AddTransmittedBytes(beacon_size); |
157 return true; | 157 return true; |
158 } | 158 } |
159 | 159 |
160 } // namespace blink | 160 } // namespace blink |
OLD | NEW |