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 "modules/beacon/NavigatorBeacon.h" | 6 #include "modules/beacon/NavigatorBeacon.h" |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/dom/DOMArrayBufferView.h" |
9 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
10 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
11 #include "core/fileapi/Blob.h" | 12 #include "core/fileapi/Blob.h" |
12 #include "core/frame/LocalFrame.h" | 13 #include "core/frame/LocalFrame.h" |
13 #include "core/frame/Settings.h" | 14 #include "core/frame/Settings.h" |
14 #include "core/frame/UseCounter.h" | 15 #include "core/frame/UseCounter.h" |
15 #include "core/frame/csp/ContentSecurityPolicy.h" | 16 #include "core/frame/csp/ContentSecurityPolicy.h" |
16 #include "core/html/DOMFormData.h" | 17 #include "core/html/DOMFormData.h" |
17 #include "core/loader/BeaconLoader.h" | 18 #include "core/loader/BeaconLoader.h" |
18 #include "wtf/ArrayBufferView.h" | |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 | 21 |
22 NavigatorBeacon::NavigatorBeacon(Navigator& navigator) | 22 NavigatorBeacon::NavigatorBeacon(Navigator& navigator) |
23 : m_transmittedBytes(0) | 23 : m_transmittedBytes(0) |
24 , m_navigator(navigator) | 24 , m_navigator(navigator) |
25 { | 25 { |
26 } | 26 } |
27 | 27 |
28 const char* NavigatorBeacon::supplementName() | 28 const char* NavigatorBeacon::supplementName() |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 { | 97 { |
98 KURL url = context->completeURL(urlstring); | 98 KURL url = context->completeURL(urlstring); |
99 if (!canSendBeacon(context, url, exceptionState)) | 99 if (!canSendBeacon(context, url, exceptionState)) |
100 return false; | 100 return false; |
101 | 101 |
102 int bytes = 0; | 102 int bytes = 0; |
103 bool result = BeaconLoader::sendBeacon(m_navigator.frame(), maxAllowance(),
url, data, bytes); | 103 bool result = BeaconLoader::sendBeacon(m_navigator.frame(), maxAllowance(),
url, data, bytes); |
104 return beaconResult(context, result, bytes); | 104 return beaconResult(context, result, bytes); |
105 } | 105 } |
106 | 106 |
107 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, Navigator& navigator
, const String& urlstring, PassRefPtr<ArrayBufferView> data, ExceptionState& exc
eptionState) | 107 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, Navigator& navigator
, const String& urlstring, PassRefPtr<DOMArrayBufferView> data, ExceptionState&
exceptionState) |
108 { | 108 { |
109 return NavigatorBeacon::from(navigator).sendBeacon(context, urlstring, data,
exceptionState); | 109 return NavigatorBeacon::from(navigator).sendBeacon(context, urlstring, data,
exceptionState); |
110 } | 110 } |
111 | 111 |
112 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, const String& urlstr
ing, PassRefPtr<ArrayBufferView> data, ExceptionState& exceptionState) | 112 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, const String& urlstr
ing, PassRefPtr<DOMArrayBufferView> data, ExceptionState& exceptionState) |
113 { | 113 { |
114 KURL url = context->completeURL(urlstring); | 114 KURL url = context->completeURL(urlstring); |
115 if (!canSendBeacon(context, url, exceptionState)) | 115 if (!canSendBeacon(context, url, exceptionState)) |
116 return false; | 116 return false; |
117 | 117 |
118 int bytes = 0; | 118 int bytes = 0; |
119 bool result = BeaconLoader::sendBeacon(m_navigator.frame(), maxAllowance(),
url, data, bytes); | 119 bool result = BeaconLoader::sendBeacon(m_navigator.frame(), maxAllowance(),
url, data->view(), bytes); |
120 return beaconResult(context, result, bytes); | 120 return beaconResult(context, result, bytes); |
121 } | 121 } |
122 | 122 |
123 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, Navigator& navigator
, const String& urlstring, Blob* data, ExceptionState& exceptionState) | 123 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, Navigator& navigator
, const String& urlstring, Blob* data, ExceptionState& exceptionState) |
124 { | 124 { |
125 return NavigatorBeacon::from(navigator).sendBeacon(context, urlstring, data,
exceptionState); | 125 return NavigatorBeacon::from(navigator).sendBeacon(context, urlstring, data,
exceptionState); |
126 } | 126 } |
127 | 127 |
128 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, const String& urlstr
ing, Blob* data, ExceptionState& exceptionState) | 128 bool NavigatorBeacon::sendBeacon(ExecutionContext* context, const String& urlstr
ing, Blob* data, ExceptionState& exceptionState) |
129 { | 129 { |
(...skipping 16 matching lines...) Expand all Loading... |
146 KURL url = context->completeURL(urlstring); | 146 KURL url = context->completeURL(urlstring); |
147 if (!canSendBeacon(context, url, exceptionState)) | 147 if (!canSendBeacon(context, url, exceptionState)) |
148 return false; | 148 return false; |
149 | 149 |
150 int bytes = 0; | 150 int bytes = 0; |
151 bool result = BeaconLoader::sendBeacon(m_navigator.frame(), maxAllowance(),
url, data, bytes); | 151 bool result = BeaconLoader::sendBeacon(m_navigator.frame(), maxAllowance(),
url, data, bytes); |
152 return beaconResult(context, result, bytes); | 152 return beaconResult(context, result, bytes); |
153 } | 153 } |
154 | 154 |
155 } // namespace blink | 155 } // namespace blink |
OLD | NEW |