OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ | 5 #ifndef CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
6 #define WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ | 6 #define CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
10 | 9 |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
13 #include "base/time/time.h" | 12 #include "content/public/common/appcache_info.h" |
14 #include "url/gurl.h" | |
15 #include "webkit/common/webkit_storage_common_export.h" | |
16 | 13 |
17 namespace net { | 14 namespace net { |
18 class URLRequest; | 15 class URLRequest; |
19 } | 16 } |
20 | 17 |
21 namespace appcache { | 18 namespace content { |
22 | 19 |
23 // Defines constants, types, and abstract classes used in the main | 20 // Defines constants, types, and abstract classes used in the main |
24 // process and in child processes. | 21 // process and in child processes. |
25 | 22 |
26 static const int kAppCacheNoHostId = 0; | |
27 static const int64 kAppCacheNoCacheId = 0; | |
28 static const int64 kAppCacheNoResponseId = 0; | |
29 static const int64 kAppCacheUnknownCacheId = -1; | |
30 | |
31 enum AppCacheStatus { | |
32 APPCACHE_STATUS_UNCACHED, | |
33 APPCACHE_STATUS_IDLE, | |
34 APPCACHE_STATUS_CHECKING, | |
35 APPCACHE_STATUS_DOWNLOADING, | |
36 APPCACHE_STATUS_UPDATE_READY, | |
37 APPCACHE_STATUS_OBSOLETE, | |
38 APPCACHE_STATUS_LAST = APPCACHE_STATUS_OBSOLETE | |
39 }; | |
40 | |
41 enum AppCacheEventID { | 23 enum AppCacheEventID { |
42 APPCACHE_CHECKING_EVENT, | 24 APPCACHE_CHECKING_EVENT, |
43 APPCACHE_ERROR_EVENT, | 25 APPCACHE_ERROR_EVENT, |
44 APPCACHE_NO_UPDATE_EVENT, | 26 APPCACHE_NO_UPDATE_EVENT, |
45 APPCACHE_DOWNLOADING_EVENT, | 27 APPCACHE_DOWNLOADING_EVENT, |
46 APPCACHE_PROGRESS_EVENT, | 28 APPCACHE_PROGRESS_EVENT, |
47 APPCACHE_UPDATE_READY_EVENT, | 29 APPCACHE_UPDATE_READY_EVENT, |
48 APPCACHE_CACHED_EVENT, | 30 APPCACHE_CACHED_EVENT, |
49 APPCACHE_OBSOLETE_EVENT, | 31 APPCACHE_OBSOLETE_EVENT, |
50 APPCACHE_EVENT_ID_LAST = APPCACHE_OBSOLETE_EVENT | 32 APPCACHE_EVENT_ID_LAST = APPCACHE_OBSOLETE_EVENT |
(...skipping 18 matching lines...) Expand all Loading... |
69 APPCACHE_SIGNATURE_ERROR, | 51 APPCACHE_SIGNATURE_ERROR, |
70 APPCACHE_RESOURCE_ERROR, | 52 APPCACHE_RESOURCE_ERROR, |
71 APPCACHE_CHANGED_ERROR, | 53 APPCACHE_CHANGED_ERROR, |
72 APPCACHE_ABORT_ERROR, | 54 APPCACHE_ABORT_ERROR, |
73 APPCACHE_QUOTA_ERROR, | 55 APPCACHE_QUOTA_ERROR, |
74 APPCACHE_POLICY_ERROR, | 56 APPCACHE_POLICY_ERROR, |
75 APPCACHE_UNKNOWN_ERROR, | 57 APPCACHE_UNKNOWN_ERROR, |
76 APPCACHE_ERROR_REASON_LAST = APPCACHE_UNKNOWN_ERROR | 58 APPCACHE_ERROR_REASON_LAST = APPCACHE_UNKNOWN_ERROR |
77 }; | 59 }; |
78 | 60 |
79 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo { | |
80 AppCacheInfo(); | |
81 ~AppCacheInfo(); | |
82 | |
83 GURL manifest_url; | |
84 base::Time creation_time; | |
85 base::Time last_update_time; | |
86 base::Time last_access_time; | |
87 int64 cache_id; | |
88 int64 group_id; | |
89 AppCacheStatus status; | |
90 int64 size; | |
91 bool is_complete; | |
92 }; | |
93 | |
94 typedef std::vector<AppCacheInfo> AppCacheInfoVector; | |
95 | |
96 // Type to hold information about a single appcache resource. | 61 // Type to hold information about a single appcache resource. |
97 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheResourceInfo { | 62 struct CONTENT_EXPORT AppCacheResourceInfo { |
98 AppCacheResourceInfo(); | 63 AppCacheResourceInfo(); |
99 ~AppCacheResourceInfo(); | 64 ~AppCacheResourceInfo(); |
100 | 65 |
101 GURL url; | 66 GURL url; |
102 int64 size; | 67 int64 size; |
103 bool is_master; | 68 bool is_master; |
104 bool is_manifest; | 69 bool is_manifest; |
105 bool is_intercept; | 70 bool is_intercept; |
106 bool is_fallback; | 71 bool is_fallback; |
107 bool is_foreign; | 72 bool is_foreign; |
108 bool is_explicit; | 73 bool is_explicit; |
109 int64 response_id; | 74 int64 response_id; |
110 }; | 75 }; |
111 | 76 |
112 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheErrorDetails { | 77 struct CONTENT_EXPORT AppCacheErrorDetails { |
113 AppCacheErrorDetails(); | 78 AppCacheErrorDetails(); |
114 AppCacheErrorDetails(std::string message, | 79 AppCacheErrorDetails(std::string message, |
115 AppCacheErrorReason reason, | 80 AppCacheErrorReason reason, |
116 GURL url, | 81 GURL url, |
117 int status, | 82 int status, |
118 bool is_cross_origin); | 83 bool is_cross_origin); |
119 ~AppCacheErrorDetails(); | 84 ~AppCacheErrorDetails(); |
120 | 85 |
121 std::string message; | 86 std::string message; |
122 AppCacheErrorReason reason; | 87 AppCacheErrorReason reason; |
123 GURL url; | 88 GURL url; |
124 int status; | 89 int status; |
125 bool is_cross_origin; | 90 bool is_cross_origin; |
126 }; | 91 }; |
127 | 92 |
128 typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector; | 93 typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector; |
129 | 94 |
130 struct WEBKIT_STORAGE_COMMON_EXPORT Namespace { | 95 struct CONTENT_EXPORT AppCacheNamespace { |
131 Namespace(); // Type is set to APPCACHE_FALLBACK_NAMESPACE by default. | 96 AppCacheNamespace(); // Type is APPCACHE_FALLBACK_NAMESPACE by default. |
132 Namespace(AppCacheNamespaceType type, const GURL& url, const GURL& target, | 97 AppCacheNamespace(AppCacheNamespaceType type, const GURL& url, |
133 bool is_pattern); | 98 const GURL& target, bool is_pattern); |
134 Namespace(AppCacheNamespaceType type, const GURL& url, const GURL& target, | 99 AppCacheNamespace(AppCacheNamespaceType type, const GURL& url, |
135 bool is_pattern, bool is_executable); | 100 const GURL& target, bool is_pattern, bool is_executable); |
136 ~Namespace(); | 101 ~AppCacheNamespace(); |
137 | 102 |
138 bool IsMatch(const GURL& url) const; | 103 bool IsMatch(const GURL& url) const; |
139 | 104 |
140 AppCacheNamespaceType type; | 105 AppCacheNamespaceType type; |
141 GURL namespace_url; | 106 GURL namespace_url; |
142 GURL target_url; | 107 GURL target_url; |
143 bool is_pattern; | 108 bool is_pattern; |
144 bool is_executable; | 109 bool is_executable; |
145 }; | 110 }; |
146 | 111 |
147 typedef std::vector<Namespace> NamespaceVector; | 112 typedef std::vector<AppCacheNamespace> AppCacheNamespaceVector; |
148 | 113 |
149 // Interface used by backend (browser-process) to talk to frontend (renderer). | 114 // Interface used by backend (browser-process) to talk to frontend (renderer). |
150 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheFrontend { | 115 class CONTENT_EXPORT AppCacheFrontend { |
151 public: | 116 public: |
152 virtual void OnCacheSelected( | 117 virtual void OnCacheSelected( |
153 int host_id, const appcache::AppCacheInfo& info) = 0; | 118 int host_id, const AppCacheInfo& info) = 0; |
154 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 119 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
155 AppCacheStatus status) = 0; | 120 AppCacheStatus status) = 0; |
156 virtual void OnEventRaised(const std::vector<int>& host_ids, | 121 virtual void OnEventRaised(const std::vector<int>& host_ids, |
157 AppCacheEventID event_id) = 0; | 122 AppCacheEventID event_id) = 0; |
158 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, | 123 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
159 const GURL& url, | 124 const GURL& url, |
160 int num_total, int num_complete) = 0; | 125 int num_total, int num_complete) = 0; |
161 virtual void OnErrorEventRaised( | 126 virtual void OnErrorEventRaised( |
162 const std::vector<int>& host_ids, | 127 const std::vector<int>& host_ids, |
163 const appcache::AppCacheErrorDetails& details) = 0; | 128 const AppCacheErrorDetails& details) = 0; |
164 virtual void OnContentBlocked(int host_id, | 129 virtual void OnContentBlocked(int host_id, |
165 const GURL& manifest_url) = 0; | 130 const GURL& manifest_url) = 0; |
166 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level, | 131 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level, |
167 const std::string& message) = 0; | 132 const std::string& message) = 0; |
168 virtual ~AppCacheFrontend() {} | 133 virtual ~AppCacheFrontend() {} |
169 }; | 134 }; |
170 | 135 |
171 // Interface used by frontend (renderer) to talk to backend (browser-process). | 136 // Interface used by frontend (renderer) to talk to backend (browser-process). |
172 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheBackend { | 137 class CONTENT_EXPORT AppCacheBackend { |
173 public: | 138 public: |
174 virtual void RegisterHost(int host_id) = 0; | 139 virtual void RegisterHost(int host_id) = 0; |
175 virtual void UnregisterHost(int host_id) = 0; | 140 virtual void UnregisterHost(int host_id) = 0; |
176 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0; | 141 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0; |
177 virtual void SelectCache(int host_id, | 142 virtual void SelectCache(int host_id, |
178 const GURL& document_url, | 143 const GURL& document_url, |
179 const int64 cache_document_was_loaded_from, | 144 const int64 cache_document_was_loaded_from, |
180 const GURL& manifest_url) = 0; | 145 const GURL& manifest_url) = 0; |
181 virtual void SelectCacheForWorker( | 146 virtual void SelectCacheForWorker( |
182 int host_id, | 147 int host_id, |
183 int parent_process_id, | 148 int parent_process_id, |
184 int parent_host_id) = 0; | 149 int parent_host_id) = 0; |
185 virtual void SelectCacheForSharedWorker( | 150 virtual void SelectCacheForSharedWorker( |
186 int host_id, | 151 int host_id, |
187 int64 appcache_id) = 0; | 152 int64 appcache_id) = 0; |
188 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, | 153 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, |
189 int64 cache_document_was_loaded_from) = 0; | 154 int64 cache_document_was_loaded_from) = 0; |
190 virtual AppCacheStatus GetStatus(int host_id) = 0; | 155 virtual AppCacheStatus GetStatus(int host_id) = 0; |
191 virtual bool StartUpdate(int host_id) = 0; | 156 virtual bool StartUpdate(int host_id) = 0; |
192 virtual bool SwapCache(int host_id) = 0; | 157 virtual bool SwapCache(int host_id) = 0; |
193 virtual void GetResourceList( | 158 virtual void GetResourceList( |
194 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0; | 159 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0; |
195 | 160 |
196 protected: | 161 protected: |
197 virtual ~AppCacheBackend() {} | 162 virtual ~AppCacheBackend() {} |
198 }; | 163 }; |
199 | 164 |
200 // Useful string constants. | 165 // Useful string constants. |
201 // Note: These are also defined elsewhere in the chrome code base in | 166 // Note: These are also defined elsewhere in the chrome code base in |
202 // url_contants.h .cc, however the appcache library doesn't not have | 167 // url_contants.h .cc, however the content library can not have |
203 // any dependencies on the chrome library, so we can't use them in here. | 168 // any dependencies on the chrome library, so we can't use them in here. |
204 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpScheme[]; | 169 CONTENT_EXPORT extern const char kHttpScheme[]; |
205 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpsScheme[]; | 170 CONTENT_EXPORT extern const char kHttpsScheme[]; |
206 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpGETMethod[]; | 171 CONTENT_EXPORT extern const char kHttpGETMethod[]; |
207 WEBKIT_STORAGE_COMMON_EXPORT extern const char kHttpHEADMethod[]; | 172 CONTENT_EXPORT extern const char kHttpHEADMethod[]; |
208 | 173 |
209 // CommandLine flag to turn this experimental feature on. | 174 // CommandLine flag to turn this experimental feature on. |
210 WEBKIT_STORAGE_COMMON_EXPORT extern const char kEnableExecutableHandlers[]; | 175 CONTENT_EXPORT extern const char kEnableExecutableHandlers[]; |
211 | 176 |
212 WEBKIT_STORAGE_COMMON_EXPORT bool IsSchemeSupported(const GURL& url); | 177 CONTENT_EXPORT bool IsSchemeSupportedForAppCache(const GURL& url); |
213 WEBKIT_STORAGE_COMMON_EXPORT bool IsMethodSupported(const std::string& method); | 178 CONTENT_EXPORT bool IsMethodSupportedForAppCache( |
214 WEBKIT_STORAGE_COMMON_EXPORT bool IsSchemeAndMethodSupported( | 179 const std::string& method); |
| 180 CONTENT_EXPORT bool IsSchemeAndMethodSupportedForAppCache( |
215 const net::URLRequest* request); | 181 const net::URLRequest* request); |
216 | 182 |
217 WEBKIT_STORAGE_COMMON_EXPORT extern const base::FilePath::CharType | 183 CONTENT_EXPORT extern const base::FilePath::CharType |
218 kAppCacheDatabaseName[]; | 184 kAppCacheDatabaseName[]; |
219 | 185 |
220 } // namespace | 186 } // namespace |
221 | 187 |
222 #endif // WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ | 188 #endif // CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
OLD | NEW |