1 // Copyright (c) 2012 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_COMMON_APPCACHE_APPCACHE_INTERFACES_H_
6 #define WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_
11 #include "base/basictypes.h"
12 #include "base/files/file_path.h"
13 #include "base/time/time.h"
15 #include "webkit/common/webkit_storage_common_export.h"
23 // Defines constants, types, and abstract classes used in the main
24 // process and in child processes.
26 static const int kNoHostId = 0;
27 static const int64 kNoCacheId = 0;
28 static const int64 kNoResponseId = 0;
29 static const int64 kUnknownCacheId = -1;
38 STATUS_LAST = OBSOLETE
50 EVENT_ID_LAST = OBSOLETE_EVENT
53 // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
76 ERROR_REASON_LAST = UNKNOWN_ERROR
79 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo {
84 base::Time creation_time;
85 base::Time last_update_time;
86 base::Time last_access_time;
94 typedef std::vector<AppCacheInfo> AppCacheInfoVector;
96 // Type to hold information about a single appcache resource.
97 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheResourceInfo {
98 AppCacheResourceInfo();
99 ~AppCacheResourceInfo();
112 struct WEBKIT_STORAGE_COMMON_EXPORT ErrorDetails {
114 ErrorDetails(std::string message,
118 bool is_cross_origin);
125 bool is_cross_origin;
128 typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector;
130 struct WEBKIT_STORAGE_COMMON_EXPORT Namespace {
131 Namespace(); // Type is set to FALLBACK_NAMESPACE by default.
132 Namespace(NamespaceType type, const GURL& url, const GURL& target,
134 Namespace(NamespaceType type, const GURL& url, const GURL& target,
135 bool is_pattern, bool is_executable);
138 bool IsMatch(const GURL& url) const;
147 typedef std::vector<Namespace> NamespaceVector;
149 // Interface used by backend (browser-process) to talk to frontend (renderer).
150 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheFrontend {
152 virtual void OnCacheSelected(
153 int host_id, const appcache::AppCacheInfo& info) = 0;
154 virtual void OnStatusChanged(const std::vector<int>& host_ids,
156 virtual void OnEventRaised(const std::vector<int>& host_ids,
157 EventID event_id) = 0;
158 virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
160 int num_total, int num_complete) = 0;
161 virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
162 const appcache::ErrorDetails& details) = 0;
163 virtual void OnContentBlocked(int host_id,
164 const GURL& manifest_url) = 0;
165 virtual void OnLogMessage(int host_id, LogLevel log_level,
166 const std::string& message) = 0;
167 virtual ~AppCacheFrontend() {}
170 // Interface used by frontend (renderer) to talk to backend (browser-process).
171 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheBackend {
173 virtual void RegisterHost(int host_id) = 0;
174 virtual void UnregisterHost(int host_id) = 0;
175 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0;
176 virtual void SelectCache(int host_id,
177 const GURL& document_url,
178 const int64 cache_document_was_loaded_from,
179 const GURL& manifest_url) = 0;
180 virtual void SelectCacheForWorker(
182 int parent_process_id,
183 int parent_host_id) = 0;
184 virtual void SelectCacheForSharedWorker(
186 int64 appcache_id) = 0;
187 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url,
188 int64 cache_document_was_loaded_from) = 0;
189 virtual Status GetStatus(int host_id) = 0;
190 virtual bool StartUpdate(int host_id) = 0;
191 virtual bool SwapCache(int host_id) = 0;
192 virtual void GetResourceList(
193 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0;
196 virtual ~AppCacheBackend() {}
199 // Useful string constants.
200 // Note: These are also defined elsewhere in the chrome code base in
201 // url_contants.h .cc, however the appcache library doesn't not have
202 // any dependencies on the chrome library, so we can't use them in here.
203 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpScheme[];
204 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpsScheme[];
205 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpGETMethod[];
206 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpHEADMethod[];
208 // CommandLine flag to turn this experimental feature on.
209 WEBKIT_STORAGE_COMMON_EXPORT extern const char kEnableExecutableHandlers[];
211 WEBKIT_STORAGE_COMMON_EXPORT bool IsSchemeSupported(const GURL& url);
212 WEBKIT_STORAGE_COMMON_EXPORT bool IsMethodSupported(const std::string& method);
213 WEBKIT_STORAGE_COMMON_EXPORT bool IsSchemeAndMethodSupported(
214 const net::URLRequest* request);
216 WEBKIT_STORAGE_COMMON_EXPORT extern const base::FilePath::CharType
217 kAppCacheDatabaseName[];
221 #endif // WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_