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 "bindings/modules/v8/UnionTypesModules.h" | 9 #include "bindings/modules/v8/UnionTypesModules.h" |
10 #include "core/dom/DOMArrayBufferView.h" | 10 #include "core/dom/DOMArrayBufferView.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace blink { | 21 namespace blink { |
22 | 22 |
23 NavigatorBeacon::NavigatorBeacon(Navigator& navigator) | 23 NavigatorBeacon::NavigatorBeacon(Navigator& navigator) |
24 : m_transmittedBytes(0) | 24 : m_transmittedBytes(0) |
25 , m_navigator(navigator) | 25 , m_navigator(navigator) |
26 { | 26 { |
27 } | 27 } |
28 | 28 |
29 DEFINE_TRACE(NavigatorBeacon) | 29 DEFINE_TRACE(NavigatorBeacon) |
30 { | 30 { |
31 WillBeHeapSupplement<Navigator>::trace(visitor); | 31 HeapSupplement<Navigator>::trace(visitor); |
32 } | 32 } |
33 | 33 |
34 const char* NavigatorBeacon::supplementName() | 34 const char* NavigatorBeacon::supplementName() |
35 { | 35 { |
36 return "NavigatorBeacon"; | 36 return "NavigatorBeacon"; |
37 } | 37 } |
38 | 38 |
39 NavigatorBeacon& NavigatorBeacon::from(Navigator& navigator) | 39 NavigatorBeacon& NavigatorBeacon::from(Navigator& navigator) |
40 { | 40 { |
41 NavigatorBeacon* supplement = static_cast<NavigatorBeacon*>(WillBeHeapSupple
ment<Navigator>::from(navigator, supplementName())); | 41 NavigatorBeacon* supplement = static_cast<NavigatorBeacon*>(HeapSupplement<N
avigator>::from(navigator, supplementName())); |
42 if (!supplement) { | 42 if (!supplement) { |
43 supplement = new NavigatorBeacon(navigator); | 43 supplement = new NavigatorBeacon(navigator); |
44 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | 44 provideTo(navigator, supplementName(), supplement); |
45 } | 45 } |
46 return *supplement; | 46 return *supplement; |
47 } | 47 } |
48 | 48 |
49 bool NavigatorBeacon::canSendBeacon(ExecutionContext* context, const KURL& url,
ExceptionState& exceptionState) | 49 bool NavigatorBeacon::canSendBeacon(ExecutionContext* context, const KURL& url,
ExceptionState& exceptionState) |
50 { | 50 { |
51 if (!url.isValid()) { | 51 if (!url.isValid()) { |
52 exceptionState.throwDOMException(SyntaxError, "The URL argument is ill-f
ormed or unsupported."); | 52 exceptionState.throwDOMException(SyntaxError, "The URL argument is ill-f
ormed or unsupported."); |
53 return false; | 53 return false; |
54 } | 54 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, da
ta.getAsString(), bytes); | 114 allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, da
ta.getAsString(), bytes); |
115 else if (data.isFormData()) | 115 else if (data.isFormData()) |
116 allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, da
ta.getAsFormData(), bytes); | 116 allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, da
ta.getAsFormData(), bytes); |
117 else | 117 else |
118 allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, St
ring(), bytes); | 118 allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, St
ring(), bytes); |
119 | 119 |
120 return impl.beaconResult(context, allowed, bytes); | 120 return impl.beaconResult(context, allowed, bytes); |
121 } | 121 } |
122 | 122 |
123 } // namespace blink | 123 } // namespace blink |
OLD | NEW |