1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/events/ApplicationCacheErrorEvent.h"
namespace blink {
static const String& errorReasonToString(
WebApplicationCacheHost::ErrorReason reason) {
DEFINE_STATIC_LOCAL(String, errorManifest, ("manifest"));
DEFINE_STATIC_LOCAL(String, errorSignature, ("signature"));
DEFINE_STATIC_LOCAL(String, errorResource, ("resource"));
DEFINE_STATIC_LOCAL(String, errorChanged, ("changed"));
DEFINE_STATIC_LOCAL(String, errorAbort, ("abort"));
DEFINE_STATIC_LOCAL(String, errorQuota, ("quota"));
DEFINE_STATIC_LOCAL(String, errorPolicy, ("policy"));
DEFINE_STATIC_LOCAL(String, errorUnknown, ("unknown"));
switch (reason) {
case WebApplicationCacheHost::ManifestError:
return errorManifest;
case WebApplicationCacheHost::SignatureError:
return errorSignature;
case WebApplicationCacheHost::ResourceError:
return errorResource;
case WebApplicationCacheHost::ChangedError:
return errorChanged;
case WebApplicationCacheHost::AbortError:
return errorAbort;
case WebApplicationCacheHost::QuotaError:
return errorQuota;
case WebApplicationCacheHost::PolicyError:
return errorPolicy;
case WebApplicationCacheHost::UnknownError:
return errorUnknown;
}
NOTREACHED();
return emptyString();
}
ApplicationCacheErrorEvent::ApplicationCacheErrorEvent(
WebApplicationCacheHost::ErrorReason reason,
const String& url,
int status,
const String& message)
: Event(EventTypeNames::error, false, false),
m_reason(errorReasonToString(reason)),
m_url(url),
m_status(status),
m_message(message) {}
ApplicationCacheErrorEvent::ApplicationCacheErrorEvent(
const AtomicString& eventType,
const ApplicationCacheErrorEventInit& initializer)
: Event(eventType, initializer), m_status(0) {
if (initializer.hasReason())
m_reason = initializer.reason();
if (initializer.hasURL())
m_url = initializer.url();
if (initializer.hasStatus())
m_status = initializer.status();
if (initializer.hasMessage())
m_message = initializer.message();
}
ApplicationCacheErrorEvent::~ApplicationCacheErrorEvent() {}
DEFINE_TRACE(ApplicationCacheErrorEvent) {
Event::trace(visitor);
}
} // namespace blink
|