Home | History | Annotate | Download | only in events
      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 #include "config.h"
      6 #include "core/events/ApplicationCacheErrorEvent.h"
      7 
      8 namespace WebCore {
      9 
     10 static const String& errorReasonToString(blink::WebApplicationCacheHost::ErrorReason reason)
     11 {
     12     DEFINE_STATIC_LOCAL(String, errorManifest, ("manifest"));
     13     DEFINE_STATIC_LOCAL(String, errorSignature, ("signature"));
     14     DEFINE_STATIC_LOCAL(String, errorResource, ("resource"));
     15     DEFINE_STATIC_LOCAL(String, errorChanged, ("changed"));
     16     DEFINE_STATIC_LOCAL(String, errorAbort, ("abort"));
     17     DEFINE_STATIC_LOCAL(String, errorQuota, ("quota"));
     18     DEFINE_STATIC_LOCAL(String, errorPolicy, ("policy"));
     19     DEFINE_STATIC_LOCAL(String, errorUnknown, ("unknown"));
     20 
     21     switch (reason) {
     22     case blink::WebApplicationCacheHost::ManifestError:
     23         return errorManifest;
     24     case blink::WebApplicationCacheHost::SignatureError:
     25         return errorSignature;
     26     case blink::WebApplicationCacheHost::ResourceError:
     27         return errorResource;
     28     case blink::WebApplicationCacheHost::ChangedError:
     29         return errorChanged;
     30     case blink::WebApplicationCacheHost::AbortError:
     31         return errorAbort;
     32     case blink::WebApplicationCacheHost::QuotaError:
     33         return errorQuota;
     34     case blink::WebApplicationCacheHost::PolicyError:
     35         return errorPolicy;
     36     case blink::WebApplicationCacheHost::UnknownError:
     37         return errorUnknown;
     38     }
     39     ASSERT_NOT_REACHED();
     40     return emptyString();
     41 }
     42 
     43 ApplicationCacheErrorEventInit::ApplicationCacheErrorEventInit()
     44     : status(0)
     45 {
     46 }
     47 
     48 ApplicationCacheErrorEvent::ApplicationCacheErrorEvent()
     49 {
     50     ScriptWrappable::init(this);
     51 }
     52 
     53 ApplicationCacheErrorEvent::ApplicationCacheErrorEvent(blink::WebApplicationCacheHost::ErrorReason reason, const String& url, int status, const String& message)
     54     : Event(EventTypeNames::error, false, false)
     55     , m_reason(errorReasonToString(reason))
     56     , m_url(url)
     57     , m_status(status)
     58     , m_message(message)
     59 {
     60     ScriptWrappable::init(this);
     61 }
     62 
     63 ApplicationCacheErrorEvent::ApplicationCacheErrorEvent(const AtomicString& eventType, const ApplicationCacheErrorEventInit& initializer)
     64     : Event(eventType, initializer)
     65     , m_reason(initializer.reason)
     66     , m_url(initializer.url)
     67     , m_status(initializer.status)
     68     , m_message(initializer.message)
     69 {
     70     ScriptWrappable::init(this);
     71 }
     72 
     73 ApplicationCacheErrorEvent::~ApplicationCacheErrorEvent()
     74 {
     75 }
     76 
     77 void ApplicationCacheErrorEvent::trace(Visitor* visitor)
     78 {
     79     Event::trace(visitor);
     80 }
     81 
     82 } // namespace WebCore
     83