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
3 // found in the LICENSE file.
5 #ifndef NavigatorBeacon_h
6 #define NavigatorBeacon_h
8 #include "core/frame/Navigator.h"
9 #include "platform/Supplementable.h"
10 #include "platform/heap/Handle.h"
15 class DOMArrayBufferView;
18 class ExecutionContext;
21 class NavigatorBeacon final : public NoBaseWillBeGarbageCollected<NavigatorBeacon>, public WillBeHeapSupplement<Navigator> {
22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorBeacon);
24 static NavigatorBeacon& from(Navigator&);
26 static bool sendBeacon(ExecutionContext*, Navigator&, const String&, const String&, ExceptionState&);
27 static bool sendBeacon(ExecutionContext*, Navigator&, const String&, PassRefPtr<DOMArrayBufferView>, ExceptionState&);
28 static bool sendBeacon(ExecutionContext*, Navigator&, const String&, Blob*, ExceptionState&);
29 static bool sendBeacon(ExecutionContext*, Navigator&, const String&, PassRefPtrWillBeRawPtr<DOMFormData>, ExceptionState&);
32 explicit NavigatorBeacon(Navigator&);
34 static const char* supplementName();
36 bool sendBeacon(ExecutionContext*, const String&, const String&, ExceptionState&);
37 bool sendBeacon(ExecutionContext*, const String&, PassRefPtr<DOMArrayBufferView>, ExceptionState&);
38 bool sendBeacon(ExecutionContext*, const String&, Blob*, ExceptionState&);
39 bool sendBeacon(ExecutionContext*, const String&, PassRefPtrWillBeRawPtr<DOMFormData>, ExceptionState&);
41 bool canSendBeacon(ExecutionContext*, const KURL&, ExceptionState&);
42 int maxAllowance() const;
43 bool beaconResult(ExecutionContext*, bool allowed, int sentBytes);
45 int m_transmittedBytes;
46 Navigator& m_navigator;
51 #endif // NavigatorBeacon_h