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 ApplicationCacheErrorEvent_h
6#define ApplicationCacheErrorEvent_h
7
8#include "core/events/Event.h"
9#include "core/loader/appcache/ApplicationCacheHost.h"
10#include "public/platform/WebApplicationCacheHostClient.h"
11
12namespace blink {
13
14class ApplicationCacheErrorEvent;
15
16struct ApplicationCacheErrorEventInit : public EventInit {
17    ApplicationCacheErrorEventInit();
18
19    String reason;
20    String url;
21    int status;
22    String message;
23};
24
25class ApplicationCacheErrorEvent FINAL : public Event {
26    DEFINE_WRAPPERTYPEINFO();
27public:
28    virtual ~ApplicationCacheErrorEvent();
29
30    static PassRefPtrWillBeRawPtr<ApplicationCacheErrorEvent> create()
31    {
32        return adoptRefWillBeNoop(new ApplicationCacheErrorEvent);
33    }
34
35    static PassRefPtrWillBeRawPtr<ApplicationCacheErrorEvent> create(blink::WebApplicationCacheHost::ErrorReason reason, const String& url, int status, const String& message)
36    {
37        return adoptRefWillBeNoop(new ApplicationCacheErrorEvent(reason, url, status, message));
38    }
39
40    static PassRefPtrWillBeRawPtr<ApplicationCacheErrorEvent> create(const AtomicString& eventType, const ApplicationCacheErrorEventInit& initializer)
41    {
42        return adoptRefWillBeNoop(new ApplicationCacheErrorEvent(eventType, initializer));
43    }
44
45    const String& reason() const { return m_reason; }
46    const String& url() const { return m_url; }
47    int status() const { return m_status; }
48    const String& message() const { return m_message; }
49
50    virtual const AtomicString& interfaceName() const OVERRIDE { return EventNames::ApplicationCacheErrorEvent; }
51
52    virtual void trace(Visitor*) OVERRIDE;
53
54private:
55    ApplicationCacheErrorEvent();
56    ApplicationCacheErrorEvent(blink::WebApplicationCacheHost::ErrorReason, const String& url, int status, const String& message);
57    ApplicationCacheErrorEvent(const AtomicString& eventType, const ApplicationCacheErrorEventInit& initializer);
58
59    String m_reason;
60    String m_url;
61    int m_status;
62    String m_message;
63};
64
65} // namespace blink
66
67#endif // ApplicationCacheErrorEvent_h
68