Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / child / appcache / web_application_cache_host_impl.h
1 // Copyright 2013 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 #ifndef CONTENT_CHILD_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
6 #define CONTENT_CHILD_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_
7
8 #include <string>
9
10 #include "third_party/WebKit/public/platform/WebApplicationCacheHost.h"
11 #include "third_party/WebKit/public/platform/WebApplicationCacheHostClient.h"
12 #include "third_party/WebKit/public/platform/WebURLResponse.h"
13 #include "third_party/WebKit/public/platform/WebVector.h"
14 #include "url/gurl.h"
15 #include "webkit/common/appcache/appcache_interfaces.h"
16
17 namespace content {
18
19 class WebApplicationCacheHostImpl
20     : NON_EXPORTED_BASE(public blink::WebApplicationCacheHost) {
21  public:
22   // Returns the host having given id or NULL if there is no such host.
23   static WebApplicationCacheHostImpl* FromId(int id);
24
25   WebApplicationCacheHostImpl(blink::WebApplicationCacheHostClient* client,
26                               appcache::AppCacheBackend* backend);
27   virtual ~WebApplicationCacheHostImpl();
28
29   int host_id() const { return host_id_; }
30   appcache::AppCacheBackend* backend() const { return backend_; }
31   blink::WebApplicationCacheHostClient* client() const { return client_; }
32
33   virtual void OnCacheSelected(const appcache::AppCacheInfo& info);
34   void OnStatusChanged(appcache::Status);
35   void OnEventRaised(appcache::EventID);
36   void OnProgressEventRaised(const GURL& url, int num_total, int num_complete);
37   void OnErrorEventRaised(const appcache::ErrorDetails& details);
38   virtual void OnLogMessage(appcache::LogLevel log_level,
39                             const std::string& message) {}
40   virtual void OnContentBlocked(const GURL& manifest_url) {}
41
42   // blink::WebApplicationCacheHost:
43   virtual void willStartMainResourceRequest(
44       blink::WebURLRequest&, const blink::WebApplicationCacheHost*);
45   virtual void willStartSubResourceRequest(blink::WebURLRequest&);
46   virtual void selectCacheWithoutManifest();
47   virtual bool selectCacheWithManifest(const blink::WebURL& manifestURL);
48   virtual void didReceiveResponseForMainResource(const blink::WebURLResponse&);
49   virtual void didReceiveDataForMainResource(const char* data, int len);
50   virtual void didFinishLoadingMainResource(bool success);
51   virtual blink::WebApplicationCacheHost::Status status();
52   virtual bool startUpdate();
53   virtual bool swapCache();
54   virtual void getResourceList(blink::WebVector<ResourceInfo>* resources);
55   virtual void getAssociatedCacheInfo(CacheInfo* info);
56
57  private:
58   enum IsNewMasterEntry {
59     MAYBE,
60     YES,
61     NO
62   };
63
64   blink::WebApplicationCacheHostClient* client_;
65   appcache::AppCacheBackend* backend_;
66   int host_id_;
67   appcache::Status status_;
68   blink::WebURLResponse document_response_;
69   GURL document_url_;
70   bool is_scheme_supported_;
71   bool is_get_method_;
72   IsNewMasterEntry is_new_master_entry_;
73   appcache::AppCacheInfo cache_info_;
74   GURL original_main_resource_url_;  // Used to detect redirection.
75   bool was_select_cache_called_;
76 };
77
78 }  // namespace content
79
80 #endif  // CONTENT_CHILD_APPCACHE_WEB_APPLICATION_CACHE_HOST_IMPL_H_