Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / beacon / NavigatorBeacon.h
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 blink {
13
14 class Blob;
15 class DOMArrayBufferView;
16 class DOMFormData;
17 class ExceptionState;
18 class ExecutionContext;
19 class KURL;
20
21 class NavigatorBeacon final : public NoBaseWillBeGarbageCollected<NavigatorBeacon>, public WillBeHeapSupplement<Navigator> {
22     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorBeacon);
23 public:
24     static NavigatorBeacon& from(Navigator&);
25
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&);
30
31 private:
32     explicit NavigatorBeacon(Navigator&);
33
34     static const char* supplementName();
35
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&);
40
41     bool canSendBeacon(ExecutionContext*, const KURL&, ExceptionState&);
42     int maxAllowance() const;
43     bool beaconResult(ExecutionContext*, bool allowed, int sentBytes);
44
45     int m_transmittedBytes;
46     Navigator& m_navigator;
47 };
48
49 } // namespace blink
50
51 #endif // NavigatorBeacon_h