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_APPCACHE_APPCACHE_INTERFACES_H_
6 #define WEBKIT_APPCACHE_APPCACHE_INTERFACES_H_
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/time.h"
13 #include "googleurl/src/gurl.h"
14 #include "webkit/storage/webkit_storage_export.h"
22 // Defines constants, types, and abstract classes used in the main
23 // process and in child processes.
25 static const int kNoHostId
= 0;
26 static const int64 kNoCacheId
= 0;
27 static const int64 kNoResponseId
= 0;
28 static const int64 kUnknownCacheId
= -1;
50 // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
64 struct WEBKIT_STORAGE_EXPORT AppCacheInfo
{
69 base::Time creation_time
;
70 base::Time last_update_time
;
71 base::Time last_access_time
;
79 typedef std::vector
<AppCacheInfo
> AppCacheInfoVector
;
81 // Type to hold information about a single appcache resource.
82 struct WEBKIT_STORAGE_EXPORT AppCacheResourceInfo
{
83 AppCacheResourceInfo();
84 ~AppCacheResourceInfo();
97 typedef std::vector
<AppCacheResourceInfo
> AppCacheResourceInfoVector
;
99 struct WEBKIT_STORAGE_EXPORT Namespace
{
100 Namespace(); // Type is set to FALLBACK_NAMESPACE by default.
101 Namespace(NamespaceType type
, const GURL
& url
, const GURL
& target
,
103 Namespace(NamespaceType type
, const GURL
& url
, const GURL
& target
,
104 bool is_pattern
, bool is_executable
);
107 bool IsMatch(const GURL
& url
) const;
116 typedef std::vector
<Namespace
> NamespaceVector
;
118 // Interface used by backend (browser-process) to talk to frontend (renderer).
119 class WEBKIT_STORAGE_EXPORT AppCacheFrontend
{
121 virtual void OnCacheSelected(
122 int host_id
, const appcache::AppCacheInfo
& info
) = 0;
123 virtual void OnStatusChanged(const std::vector
<int>& host_ids
,
125 virtual void OnEventRaised(const std::vector
<int>& host_ids
,
126 EventID event_id
) = 0;
127 virtual void OnProgressEventRaised(const std::vector
<int>& host_ids
,
129 int num_total
, int num_complete
) = 0;
130 virtual void OnErrorEventRaised(const std::vector
<int>& host_ids
,
131 const std::string
& message
) = 0;
132 virtual void OnContentBlocked(int host_id
,
133 const GURL
& manifest_url
) = 0;
134 virtual void OnLogMessage(int host_id
, LogLevel log_level
,
135 const std::string
& message
) = 0;
136 virtual ~AppCacheFrontend() {}
139 // Interface used by frontend (renderer) to talk to backend (browser-process).
140 class WEBKIT_STORAGE_EXPORT AppCacheBackend
{
142 virtual void RegisterHost(int host_id
) = 0;
143 virtual void UnregisterHost(int host_id
) = 0;
144 virtual void SetSpawningHostId(int host_id
, int spawning_host_id
) = 0;
145 virtual void SelectCache(int host_id
,
146 const GURL
& document_url
,
147 const int64 cache_document_was_loaded_from
,
148 const GURL
& manifest_url
) = 0;
149 virtual void SelectCacheForWorker(
151 int parent_process_id
,
152 int parent_host_id
) = 0;
153 virtual void SelectCacheForSharedWorker(
155 int64 appcache_id
) = 0;
156 virtual void MarkAsForeignEntry(int host_id
, const GURL
& document_url
,
157 int64 cache_document_was_loaded_from
) = 0;
158 virtual Status
GetStatus(int host_id
) = 0;
159 virtual bool StartUpdate(int host_id
) = 0;
160 virtual bool SwapCache(int host_id
) = 0;
161 virtual void GetResourceList(
162 int host_id
, std::vector
<AppCacheResourceInfo
>* resource_infos
) = 0;
165 virtual ~AppCacheBackend() {}
168 // Useful string constants.
169 // Note: These are also defined elsewhere in the chrome code base in
170 // url_contants.h .cc, however the appcache library doesn't not have
171 // any dependencies on the chrome library, so we can't use them in here.
172 extern const char kHttpScheme
[];
173 extern const char kHttpsScheme
[];
174 extern const char kHttpGETMethod
[];
175 extern const char kHttpHEADMethod
[];
177 // CommandLine flag to turn this experimental feature on.
178 extern const char kEnableExecutableHandlers
[];
180 WEBKIT_STORAGE_EXPORT
void AddSupportedScheme(const char* scheme
);
182 bool IsSchemeSupported(const GURL
& url
);
183 bool IsMethodSupported(const std::string
& method
);
184 bool IsSchemeAndMethodSupported(const net::URLRequest
* request
);
186 WEBKIT_STORAGE_EXPORT
extern const base::FilePath::CharType
187 kAppCacheDatabaseName
[];
191 #endif // WEBKIT_APPCACHE_APPCACHE_INTERFACES_H_