Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / appcache / web_application_cache_host_impl.h
blobd855d95fdbb30be5c6f70c90ed5b410ca0577648
1 // Copyright (c) 2011 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.
5 #ifndef WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
6 #define WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
8 #include <string>
10 #include "googleurl/src/gurl.h"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebApplicationCacheHostClient.h"
14 #include "webkit/appcache/appcache_interfaces.h"
15 #include "webkit/storage/webkit_storage_export.h"
17 namespace WebKit {
18 class WebFrame;
21 namespace appcache {
23 class WEBKIT_STORAGE_EXPORT WebApplicationCacheHostImpl
24 : NON_EXPORTED_BASE(public WebKit::WebApplicationCacheHost) {
25 public:
26 // Returns the host having given id or NULL if there is no such host.
27 static WebApplicationCacheHostImpl* FromId(int id);
29 // Returns the host associated with the current document in frame.
30 static WebApplicationCacheHostImpl* FromFrame(const WebKit::WebFrame* frame);
32 WebApplicationCacheHostImpl(WebKit::WebApplicationCacheHostClient* client,
33 AppCacheBackend* backend);
34 virtual ~WebApplicationCacheHostImpl();
36 int host_id() const { return host_id_; }
37 AppCacheBackend* backend() const { return backend_; }
38 WebKit::WebApplicationCacheHostClient* client() const { return client_; }
40 virtual void OnCacheSelected(const appcache::AppCacheInfo& info);
41 void OnStatusChanged(appcache::Status);
42 void OnEventRaised(appcache::EventID);
43 void OnProgressEventRaised(const GURL& url, int num_total, int num_complete);
44 void OnErrorEventRaised(const std::string& message);
45 virtual void OnLogMessage(LogLevel log_level, const std::string& message) {}
46 virtual void OnContentBlocked(const GURL& manifest_url) {}
48 // WebApplicationCacheHost methods
49 virtual void willStartMainResourceRequest(WebKit::WebURLRequest&,
50 const WebKit::WebFrame*);
51 virtual void willStartSubResourceRequest(WebKit::WebURLRequest&);
52 virtual void selectCacheWithoutManifest();
53 virtual bool selectCacheWithManifest(const WebKit::WebURL& manifestURL);
54 virtual void didReceiveResponseForMainResource(const WebKit::WebURLResponse&);
55 virtual void didReceiveDataForMainResource(const char* data, int len);
56 virtual void didFinishLoadingMainResource(bool success);
57 virtual WebKit::WebApplicationCacheHost::Status status();
58 virtual bool startUpdate();
59 virtual bool swapCache();
60 virtual void getResourceList(WebKit::WebVector<ResourceInfo>* resources);
61 virtual void getAssociatedCacheInfo(CacheInfo* info);
63 private:
64 enum IsNewMasterEntry {
65 MAYBE,
66 YES,
70 WebKit::WebApplicationCacheHostClient* client_;
71 AppCacheBackend* backend_;
72 int host_id_;
73 appcache::Status status_;
74 WebKit::WebURLResponse document_response_;
75 GURL document_url_;
76 bool is_scheme_supported_;
77 bool is_get_method_;
78 IsNewMasterEntry is_new_master_entry_;
79 appcache::AppCacheInfo cache_info_;
80 GURL original_main_resource_url_; // Used to detect redirection.
81 bool was_select_cache_called_;
84 } // namespace
86 #endif // WEBKIT_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_