#ifndef CONTENT_CHILD_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
#define CONTENT_CHILD_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
#include <string>
#include "third_party/WebKit/public/platform/WebApplicationCacheHost.h"
#include "third_party/WebKit/public/platform/WebApplicationCacheHostClient.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/platform/WebVector.h"
#include "url/gurl.h"
#include "webkit/common/appcache/appcache_interfaces.h"
namespace content {
class WebApplicationCacheHostImpl
: NON_EXPORTED_BASE(public blink::WebApplicationCacheHost) {
public:
static WebApplicationCacheHostImpl* FromId(int id);
WebApplicationCacheHostImpl(blink::WebApplicationCacheHostClient* client,
appcache::AppCacheBackend* backend);
virtual ~WebApplicationCacheHostImpl();
int host_id() const { return host_id_; }
appcache::AppCacheBackend* backend() const { return backend_; }
blink::WebApplicationCacheHostClient* client() const { return client_; }
virtual void OnCacheSelected(const appcache::AppCacheInfo& info);
void OnStatusChanged(appcache::Status);
void OnEventRaised(appcache::EventID);
void OnProgressEventRaised(const GURL& url, int num_total, int num_complete);
void OnErrorEventRaised(const appcache::ErrorDetails& details);
virtual void OnLogMessage(appcache::LogLevel log_level,
const std::string& message) {}
virtual void OnContentBlocked(const GURL& manifest_url) {}
virtual void willStartMainResourceRequest(
blink::WebURLRequest&, const blink::WebApplicationCacheHost*);
virtual void willStartSubResourceRequest(blink::WebURLRequest&);
virtual void selectCacheWithoutManifest();
virtual bool selectCacheWithManifest(const blink::WebURL& manifestURL);
virtual void didReceiveResponseForMainResource(const blink::WebURLResponse&);
virtual void didReceiveDataForMainResource(const char* data, int len);
virtual void didFinishLoadingMainResource(bool success);
virtual blink::WebApplicationCacheHost::Status status();
virtual bool startUpdate();
virtual bool swapCache();
virtual void getResourceList(blink::WebVector<ResourceInfo>* resources);
virtual void getAssociatedCacheInfo(CacheInfo* info);
private:
enum IsNewMasterEntry {
MAYBE,
YES,
NO
};
blink::WebApplicationCacheHostClient* client_;
appcache::AppCacheBackend* backend_;
int host_id_;
appcache::Status status_;
blink::WebURLResponse document_response_;
GURL document_url_;
bool is_scheme_supported_;
bool is_get_method_;
IsNewMasterEntry is_new_master_entry_;
appcache::AppCacheInfo cache_info_;
GURL original_main_resource_url_;
bool was_select_cache_called_;
};
}
#endif