Home | History | Annotate | Download | only in beacon
      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.
      4 
      5 #ifndef NavigatorBeacon_h
      6 #define NavigatorBeacon_h
      7 
      8 #include "core/frame/Navigator.h"
      9 #include "platform/Supplementable.h"
     10 #include "platform/heap/Handle.h"
     11 
     12 namespace WTF {
     13 class ArrayBufferView;
     14 }
     15 
     16 namespace blink {
     17 
     18 class Blob;
     19 class DOMFormData;
     20 class ExceptionState;
     21 class ExecutionContext;
     22 class KURL;
     23 
     24 class NavigatorBeacon FINAL : public NoBaseWillBeGarbageCollected<NavigatorBeacon>, public WillBeHeapSupplement<Navigator> {
     25     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorBeacon);
     26 public:
     27     static NavigatorBeacon& from(Navigator&);
     28 
     29     static bool sendBeacon(ExecutionContext*, Navigator&, const String&, const String&, ExceptionState&);
     30     static bool sendBeacon(ExecutionContext*, Navigator&, const String&, PassRefPtr<WTF::ArrayBufferView>, ExceptionState&);
     31     static bool sendBeacon(ExecutionContext*, Navigator&, const String&, PassRefPtrWillBeRawPtr<Blob>, ExceptionState&);
     32     static bool sendBeacon(ExecutionContext*, Navigator&, const String&, PassRefPtrWillBeRawPtr<DOMFormData>, ExceptionState&);
     33 
     34 private:
     35     explicit NavigatorBeacon(Navigator&);
     36 
     37     static const char* supplementName();
     38 
     39     bool sendBeacon(ExecutionContext*, const String&, const String&, ExceptionState&);
     40     bool sendBeacon(ExecutionContext*, const String&, PassRefPtr<WTF::ArrayBufferView>, ExceptionState&);
     41     bool sendBeacon(ExecutionContext*, const String&, PassRefPtrWillBeRawPtr<Blob>, ExceptionState&);
     42     bool sendBeacon(ExecutionContext*, const String&, PassRefPtrWillBeRawPtr<DOMFormData>, ExceptionState&);
     43 
     44     bool canSendBeacon(ExecutionContext*, const KURL&, ExceptionState&);
     45     int maxAllowance() const;
     46     bool beaconResult(ExecutionContext*, bool allowed, int sentBytes);
     47 
     48     int m_transmittedBytes;
     49     Navigator& m_navigator;
     50 };
     51 
     52 } // namespace blink
     53 
     54 #endif // NavigatorBeacon_h
     55