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;
51 // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
65 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo
{
70 base::Time creation_time
;
71 base::Time last_update_time
;
72 base::Time last_access_time
;
80 typedef std::vector
<AppCacheInfo
> AppCacheInfoVector
;
82 // Type to hold information about a single appcache resource.
83 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheResourceInfo
{
84 AppCacheResourceInfo();
85 ~AppCacheResourceInfo();
98 typedef std::vector
<AppCacheResourceInfo
> AppCacheResourceInfoVector
;
100 struct WEBKIT_STORAGE_COMMON_EXPORT Namespace
{
101 Namespace(); // Type is set to FALLBACK_NAMESPACE by default.
102 Namespace(NamespaceType type
, const GURL
& url
, const GURL
& target
,
104 Namespace(NamespaceType type
, const GURL
& url
, const GURL
& target
,
105 bool is_pattern
, bool is_executable
);
108 bool IsMatch(const GURL
& url
) const;
117 typedef std::vector
<Namespace
> NamespaceVector
;
119 // Interface used by backend (browser-process) to talk to frontend (renderer).
120 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheFrontend
{
122 virtual void OnCacheSelected(
123 int host_id
, const appcache::AppCacheInfo
& info
) = 0;
124 virtual void OnStatusChanged(const std::vector
<int>& host_ids
,
126 virtual void OnEventRaised(const std::vector
<int>& host_ids
,
127 EventID event_id
) = 0;
128 virtual void OnProgressEventRaised(const std::vector
<int>& host_ids
,
130 int num_total
, int num_complete
) = 0;
131 virtual void OnErrorEventRaised(const std::vector
<int>& host_ids
,
132 const std::string
& message
) = 0;
133 virtual void OnContentBlocked(int host_id
,
134 const GURL
& manifest_url
) = 0;
135 virtual void OnLogMessage(int host_id
, LogLevel log_level
,
136 const std::string
& message
) = 0;
137 virtual ~AppCacheFrontend() {}
140 // Interface used by frontend (renderer) to talk to backend (browser-process).
141 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheBackend
{
143 virtual void RegisterHost(int host_id
) = 0;
144 virtual void UnregisterHost(int host_id
) = 0;
145 virtual void SetSpawningHostId(int host_id
, int spawning_host_id
) = 0;
146 virtual void SelectCache(int host_id
,
147 const GURL
& document_url
,
148 const int64 cache_document_was_loaded_from
,
149 const GURL
& manifest_url
) = 0;
150 virtual void SelectCacheForWorker(
152 int parent_process_id
,
153 int parent_host_id
) = 0;
154 virtual void SelectCacheForSharedWorker(
156 int64 appcache_id
) = 0;
157 virtual void MarkAsForeignEntry(int host_id
, const GURL
& document_url
,
158 int64 cache_document_was_loaded_from
) = 0;
159 virtual Status
GetStatus(int host_id
) = 0;
160 virtual bool StartUpdate(int host_id
) = 0;
161 virtual bool SwapCache(int host_id
) = 0;
162 virtual void GetResourceList(
163 int host_id
, std::vector
<AppCacheResourceInfo
>* resource_infos
) = 0;
166 virtual ~AppCacheBackend() {}
169 // Useful string constants.
170 // Note: These are also defined elsewhere in the chrome code base in
171 // url_contants.h .cc, however the appcache library doesn't not have
172 // any dependencies on the chrome library, so we can't use them in here.
173 WEBKIT_STORAGE_COMMON_EXPORT
extern const char kHttpScheme
[];
174 WEBKIT_STORAGE_COMMON_EXPORT
extern const char kHttpsScheme
[];
175 WEBKIT_STORAGE_COMMON_EXPORT
extern const char kHttpGETMethod
[];
176 WEBKIT_STORAGE_COMMON_EXPORT
extern const char kHttpHEADMethod
[];
178 // CommandLine flag to turn this experimental feature on.
179 WEBKIT_STORAGE_COMMON_EXPORT
extern const char kEnableExecutableHandlers
[];
181 WEBKIT_STORAGE_COMMON_EXPORT
void AddSupportedScheme(const char* scheme
);
183 WEBKIT_STORAGE_COMMON_EXPORT
bool IsSchemeSupported(const GURL
& url
);
184 WEBKIT_STORAGE_COMMON_EXPORT
bool IsMethodSupported(const std::string
& method
);
185 WEBKIT_STORAGE_COMMON_EXPORT
bool IsSchemeAndMethodSupported(
186 const net::URLRequest
* request
);
188 WEBKIT_STORAGE_COMMON_EXPORT
extern const base::FilePath::CharType
189 kAppCacheDatabaseName
[];
193 #endif // WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_