This source file includes following definitions.
- GetHost
- OnCacheSelected
- OnStatusChanged
- OnEventRaised
- OnProgressEventRaised
- OnErrorEventRaised
- OnLogMessage
- OnContentBlocked
#include "content/child/appcache/appcache_frontend_impl.h"
#include "base/logging.h"
#include "content/child/appcache/web_application_cache_host_impl.h"
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
using blink::WebApplicationCacheHost;
using blink::WebConsoleMessage;
namespace content {
inline WebApplicationCacheHostImpl* GetHost(int id) {
return WebApplicationCacheHostImpl::FromId(id);
}
void AppCacheFrontendImpl::OnCacheSelected(int host_id,
const appcache::AppCacheInfo& info) {
WebApplicationCacheHostImpl* host = GetHost(host_id);
if (host)
host->OnCacheSelected(info);
}
void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids,
appcache::Status status) {
for (std::vector<int>::const_iterator i = host_ids.begin();
i != host_ids.end(); ++i) {
WebApplicationCacheHostImpl* host = GetHost(*i);
if (host)
host->OnStatusChanged(status);
}
}
void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids,
appcache::EventID event_id) {
DCHECK(event_id != appcache::PROGRESS_EVENT);
DCHECK(event_id != appcache::ERROR_EVENT);
for (std::vector<int>::const_iterator i = host_ids.begin();
i != host_ids.end(); ++i) {
WebApplicationCacheHostImpl* host = GetHost(*i);
if (host)
host->OnEventRaised(event_id);
}
}
void AppCacheFrontendImpl::OnProgressEventRaised(
const std::vector<int>& host_ids,
const GURL& url,
int num_total,
int num_complete) {
for (std::vector<int>::const_iterator i = host_ids.begin();
i != host_ids.end(); ++i) {
WebApplicationCacheHostImpl* host = GetHost(*i);
if (host)
host->OnProgressEventRaised(url, num_total, num_complete);
}
}
void AppCacheFrontendImpl::OnErrorEventRaised(
const std::vector<int>& host_ids,
const appcache::ErrorDetails& details) {
for (std::vector<int>::const_iterator i = host_ids.begin();
i != host_ids.end(); ++i) {
WebApplicationCacheHostImpl* host = GetHost(*i);
if (host)
host->OnErrorEventRaised(details);
}
}
void AppCacheFrontendImpl::OnLogMessage(int host_id,
appcache::LogLevel log_level,
const std::string& message) {
WebApplicationCacheHostImpl* host = GetHost(host_id);
if (host)
host->OnLogMessage(log_level, message);
}
void AppCacheFrontendImpl::OnContentBlocked(int host_id,
const GURL& manifest_url) {
WebApplicationCacheHostImpl* host = GetHost(host_id);
if (host)
host->OnContentBlocked(manifest_url);
}
COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached ==
(int)appcache::UNCACHED, Uncached);
COMPILE_ASSERT((int)WebApplicationCacheHost::Idle ==
(int)appcache::IDLE, Idle);
COMPILE_ASSERT((int)WebApplicationCacheHost::Checking ==
(int)appcache::CHECKING, Checking);
COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading ==
(int)appcache::DOWNLOADING, Downloading);
COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady ==
(int)appcache::UPDATE_READY, UpdateReady);
COMPILE_ASSERT((int)WebApplicationCacheHost::Obsolete ==
(int)appcache::OBSOLETE, Obsolete);
COMPILE_ASSERT((int)WebApplicationCacheHost::CheckingEvent ==
(int)appcache::CHECKING_EVENT, CheckingEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::ErrorEvent ==
(int)appcache::ERROR_EVENT, ErrorEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::NoUpdateEvent ==
(int)appcache::NO_UPDATE_EVENT, NoUpdateEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::DownloadingEvent ==
(int)appcache::DOWNLOADING_EVENT, DownloadingEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent ==
(int)appcache::PROGRESS_EVENT, ProgressEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent ==
(int)appcache::UPDATE_READY_EVENT, UpdateReadyEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent ==
(int)appcache::CACHED_EVENT, CachedEvent);
COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent ==
(int)appcache::OBSOLETE_EVENT, ObsoleteEvent);
COMPILE_ASSERT((int)WebConsoleMessage::LevelDebug ==
(int)appcache::LOG_DEBUG, LevelDebug);
COMPILE_ASSERT((int)WebConsoleMessage::LevelLog ==
(int)appcache::LOG_INFO, LevelLog);
COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning ==
(int)appcache::LOG_WARNING, LevelWarning);
COMPILE_ASSERT((int)WebConsoleMessage::LevelError ==
(int)appcache::LOG_ERROR, LevelError);
COMPILE_ASSERT((int)WebApplicationCacheHost::ManifestError ==
(int)appcache::MANIFEST_ERROR,
ManifestError);
COMPILE_ASSERT((int)WebApplicationCacheHost::SignatureError ==
(int)appcache::SIGNATURE_ERROR,
SignatureError);
COMPILE_ASSERT((int)WebApplicationCacheHost::ResourceError ==
(int)appcache::RESOURCE_ERROR,
ResourceError);
COMPILE_ASSERT((int)WebApplicationCacheHost::ChangedError ==
(int)appcache::CHANGED_ERROR,
ChangedError);
COMPILE_ASSERT((int)WebApplicationCacheHost::AbortError ==
(int)appcache::ABORT_ERROR,
AbortError);
COMPILE_ASSERT((int)WebApplicationCacheHost::QuotaError ==
(int)appcache::QUOTA_ERROR,
QuotaError);
COMPILE_ASSERT((int)WebApplicationCacheHost::PolicyError ==
(int)appcache::POLICY_ERROR,
PolicyError);
COMPILE_ASSERT((int)WebApplicationCacheHost::UnknownError ==
(int)appcache::UNKNOWN_ERROR,
UnknownError);
}