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 WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
6 #define WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ | 6 #define WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 namespace appcache { | 21 namespace appcache { |
22 | 22 |
23 // Defines constants, types, and abstract classes used in the main | 23 // Defines constants, types, and abstract classes used in the main |
24 // process and in child processes. | 24 // process and in child processes. |
25 | 25 |
26 static const int kNoHostId = 0; | 26 static const int kNoHostId = 0; |
27 static const int64 kNoCacheId = 0; | 27 static const int64 kNoCacheId = 0; |
28 static const int64 kNoResponseId = 0; | 28 static const int64 kNoResponseId = 0; |
29 static const int64 kUnknownCacheId = -1; | 29 static const int64 kUnknownCacheId = -1; |
30 | 30 |
31 enum Status { | 31 enum AppCacheStatus { |
32 UNCACHED, | 32 UNCACHED, |
jam
2014/06/12 19:46:37
ideally all the values would be renamed as well, a
| |
33 IDLE, | 33 IDLE, |
34 CHECKING, | 34 CHECKING, |
35 DOWNLOADING, | 35 DOWNLOADING, |
36 UPDATE_READY, | 36 UPDATE_READY, |
37 OBSOLETE, | 37 OBSOLETE, |
38 STATUS_LAST = OBSOLETE | 38 STATUS_LAST = OBSOLETE |
39 }; | 39 }; |
40 | 40 |
41 enum EventID { | 41 enum AppCacheEventID { |
42 CHECKING_EVENT, | 42 CHECKING_EVENT, |
43 ERROR_EVENT, | 43 ERROR_EVENT, |
44 NO_UPDATE_EVENT, | 44 NO_UPDATE_EVENT, |
45 DOWNLOADING_EVENT, | 45 DOWNLOADING_EVENT, |
46 PROGRESS_EVENT, | 46 PROGRESS_EVENT, |
47 UPDATE_READY_EVENT, | 47 UPDATE_READY_EVENT, |
48 CACHED_EVENT, | 48 CACHED_EVENT, |
49 OBSOLETE_EVENT, | 49 OBSOLETE_EVENT, |
50 EVENT_ID_LAST = OBSOLETE_EVENT | 50 EVENT_ID_LAST = OBSOLETE_EVENT |
51 }; | 51 }; |
52 | 52 |
53 // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit | 53 // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit |
54 enum LogLevel { | 54 enum AppCacheLogLevel { |
55 LOG_DEBUG = 4, | 55 LOG_DEBUG = 4, |
56 LOG_INFO = 1, | 56 LOG_INFO = 1, |
57 LOG_WARNING = 2, | 57 LOG_WARNING = 2, |
58 LOG_ERROR = 3, | 58 LOG_ERROR = 3, |
59 }; | 59 }; |
60 | 60 |
61 enum NamespaceType { | 61 enum AppCacheNamespaceType { |
62 FALLBACK_NAMESPACE, | 62 FALLBACK_NAMESPACE, |
63 INTERCEPT_NAMESPACE, | 63 INTERCEPT_NAMESPACE, |
64 NETWORK_NAMESPACE | 64 NETWORK_NAMESPACE |
65 }; | 65 }; |
66 | 66 |
67 enum ErrorReason { | 67 enum AppCacheErrorReason { |
68 MANIFEST_ERROR, | 68 MANIFEST_ERROR, |
69 SIGNATURE_ERROR, | 69 SIGNATURE_ERROR, |
70 RESOURCE_ERROR, | 70 RESOURCE_ERROR, |
71 CHANGED_ERROR, | 71 CHANGED_ERROR, |
72 ABORT_ERROR, | 72 ABORT_ERROR, |
73 QUOTA_ERROR, | 73 QUOTA_ERROR, |
74 POLICY_ERROR, | 74 POLICY_ERROR, |
75 UNKNOWN_ERROR, | 75 UNKNOWN_ERROR, |
76 ERROR_REASON_LAST = UNKNOWN_ERROR | 76 ERROR_REASON_LAST = UNKNOWN_ERROR |
77 }; | 77 }; |
78 | 78 |
79 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo { | 79 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo { |
80 AppCacheInfo(); | 80 AppCacheInfo(); |
81 ~AppCacheInfo(); | 81 ~AppCacheInfo(); |
82 | 82 |
83 GURL manifest_url; | 83 GURL manifest_url; |
84 base::Time creation_time; | 84 base::Time creation_time; |
85 base::Time last_update_time; | 85 base::Time last_update_time; |
86 base::Time last_access_time; | 86 base::Time last_access_time; |
87 int64 cache_id; | 87 int64 cache_id; |
88 int64 group_id; | 88 int64 group_id; |
89 Status status; | 89 AppCacheStatus status; |
90 int64 size; | 90 int64 size; |
91 bool is_complete; | 91 bool is_complete; |
92 }; | 92 }; |
93 | 93 |
94 typedef std::vector<AppCacheInfo> AppCacheInfoVector; | 94 typedef std::vector<AppCacheInfo> AppCacheInfoVector; |
95 | 95 |
96 // Type to hold information about a single appcache resource. | 96 // Type to hold information about a single appcache resource. |
97 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheResourceInfo { | 97 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheResourceInfo { |
98 AppCacheResourceInfo(); | 98 AppCacheResourceInfo(); |
99 ~AppCacheResourceInfo(); | 99 ~AppCacheResourceInfo(); |
100 | 100 |
101 GURL url; | 101 GURL url; |
102 int64 size; | 102 int64 size; |
103 bool is_master; | 103 bool is_master; |
104 bool is_manifest; | 104 bool is_manifest; |
105 bool is_intercept; | 105 bool is_intercept; |
106 bool is_fallback; | 106 bool is_fallback; |
107 bool is_foreign; | 107 bool is_foreign; |
108 bool is_explicit; | 108 bool is_explicit; |
109 int64 response_id; | 109 int64 response_id; |
110 }; | 110 }; |
111 | 111 |
112 struct WEBKIT_STORAGE_COMMON_EXPORT ErrorDetails { | 112 struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheErrorDetails { |
113 ErrorDetails(); | 113 AppCacheErrorDetails(); |
114 ErrorDetails(std::string message, | 114 AppCacheErrorDetails(std::string message, |
115 ErrorReason reason, | 115 AppCacheErrorReason reason, |
116 GURL url, | 116 GURL url, |
117 int status, | 117 int status, |
118 bool is_cross_origin); | 118 bool is_cross_origin); |
119 ~ErrorDetails(); | 119 ~AppCacheErrorDetails(); |
120 | 120 |
121 std::string message; | 121 std::string message; |
122 ErrorReason reason; | 122 AppCacheErrorReason reason; |
123 GURL url; | 123 GURL url; |
124 int status; | 124 int status; |
125 bool is_cross_origin; | 125 bool is_cross_origin; |
126 }; | 126 }; |
127 | 127 |
128 typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector; | 128 typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector; |
129 | 129 |
130 struct WEBKIT_STORAGE_COMMON_EXPORT Namespace { | 130 struct WEBKIT_STORAGE_COMMON_EXPORT Namespace { |
131 Namespace(); // Type is set to FALLBACK_NAMESPACE by default. | 131 Namespace(); // Type is set to FALLBACK_NAMESPACE by default. |
132 Namespace(NamespaceType type, const GURL& url, const GURL& target, | 132 Namespace(AppCacheNamespaceType type, const GURL& url, const GURL& target, |
133 bool is_pattern); | 133 bool is_pattern); |
134 Namespace(NamespaceType type, const GURL& url, const GURL& target, | 134 Namespace(AppCacheNamespaceType type, const GURL& url, const GURL& target, |
135 bool is_pattern, bool is_executable); | 135 bool is_pattern, bool is_executable); |
136 ~Namespace(); | 136 ~Namespace(); |
137 | 137 |
138 bool IsMatch(const GURL& url) const; | 138 bool IsMatch(const GURL& url) const; |
139 | 139 |
140 NamespaceType type; | 140 AppCacheNamespaceType type; |
141 GURL namespace_url; | 141 GURL namespace_url; |
142 GURL target_url; | 142 GURL target_url; |
143 bool is_pattern; | 143 bool is_pattern; |
144 bool is_executable; | 144 bool is_executable; |
145 }; | 145 }; |
146 | 146 |
147 typedef std::vector<Namespace> NamespaceVector; | 147 typedef std::vector<Namespace> NamespaceVector; |
148 | 148 |
149 // Interface used by backend (browser-process) to talk to frontend (renderer). | 149 // Interface used by backend (browser-process) to talk to frontend (renderer). |
150 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheFrontend { | 150 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheFrontend { |
151 public: | 151 public: |
152 virtual void OnCacheSelected( | 152 virtual void OnCacheSelected( |
153 int host_id, const appcache::AppCacheInfo& info) = 0; | 153 int host_id, const appcache::AppCacheInfo& info) = 0; |
154 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 154 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
155 Status status) = 0; | 155 AppCacheStatus status) = 0; |
156 virtual void OnEventRaised(const std::vector<int>& host_ids, | 156 virtual void OnEventRaised(const std::vector<int>& host_ids, |
157 EventID event_id) = 0; | 157 AppCacheEventID event_id) = 0; |
158 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, | 158 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
159 const GURL& url, | 159 const GURL& url, |
160 int num_total, int num_complete) = 0; | 160 int num_total, int num_complete) = 0; |
161 virtual void OnErrorEventRaised(const std::vector<int>& host_ids, | 161 virtual void OnErrorEventRaised( |
162 const appcache::ErrorDetails& details) = 0; | 162 const std::vector<int>& host_ids, |
163 const appcache::AppCacheErrorDetails& details) = 0; | |
163 virtual void OnContentBlocked(int host_id, | 164 virtual void OnContentBlocked(int host_id, |
164 const GURL& manifest_url) = 0; | 165 const GURL& manifest_url) = 0; |
165 virtual void OnLogMessage(int host_id, LogLevel log_level, | 166 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level, |
166 const std::string& message) = 0; | 167 const std::string& message) = 0; |
167 virtual ~AppCacheFrontend() {} | 168 virtual ~AppCacheFrontend() {} |
168 }; | 169 }; |
169 | 170 |
170 // Interface used by frontend (renderer) to talk to backend (browser-process). | 171 // Interface used by frontend (renderer) to talk to backend (browser-process). |
171 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheBackend { | 172 class WEBKIT_STORAGE_COMMON_EXPORT AppCacheBackend { |
172 public: | 173 public: |
173 virtual void RegisterHost(int host_id) = 0; | 174 virtual void RegisterHost(int host_id) = 0; |
174 virtual void UnregisterHost(int host_id) = 0; | 175 virtual void UnregisterHost(int host_id) = 0; |
175 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0; | 176 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0; |
176 virtual void SelectCache(int host_id, | 177 virtual void SelectCache(int host_id, |
177 const GURL& document_url, | 178 const GURL& document_url, |
178 const int64 cache_document_was_loaded_from, | 179 const int64 cache_document_was_loaded_from, |
179 const GURL& manifest_url) = 0; | 180 const GURL& manifest_url) = 0; |
180 virtual void SelectCacheForWorker( | 181 virtual void SelectCacheForWorker( |
181 int host_id, | 182 int host_id, |
182 int parent_process_id, | 183 int parent_process_id, |
183 int parent_host_id) = 0; | 184 int parent_host_id) = 0; |
184 virtual void SelectCacheForSharedWorker( | 185 virtual void SelectCacheForSharedWorker( |
185 int host_id, | 186 int host_id, |
186 int64 appcache_id) = 0; | 187 int64 appcache_id) = 0; |
187 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, | 188 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, |
188 int64 cache_document_was_loaded_from) = 0; | 189 int64 cache_document_was_loaded_from) = 0; |
189 virtual Status GetStatus(int host_id) = 0; | 190 virtual AppCacheStatus GetStatus(int host_id) = 0; |
190 virtual bool StartUpdate(int host_id) = 0; | 191 virtual bool StartUpdate(int host_id) = 0; |
191 virtual bool SwapCache(int host_id) = 0; | 192 virtual bool SwapCache(int host_id) = 0; |
192 virtual void GetResourceList( | 193 virtual void GetResourceList( |
193 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0; | 194 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0; |
194 | 195 |
195 protected: | 196 protected: |
196 virtual ~AppCacheBackend() {} | 197 virtual ~AppCacheBackend() {} |
197 }; | 198 }; |
198 | 199 |
199 // Useful string constants. | 200 // Useful string constants. |
(...skipping 12 matching lines...) Expand all Loading... | |
212 WEBKIT_STORAGE_COMMON_EXPORT bool IsMethodSupported(const std::string& method); | 213 WEBKIT_STORAGE_COMMON_EXPORT bool IsMethodSupported(const std::string& method); |
213 WEBKIT_STORAGE_COMMON_EXPORT bool IsSchemeAndMethodSupported( | 214 WEBKIT_STORAGE_COMMON_EXPORT bool IsSchemeAndMethodSupported( |
214 const net::URLRequest* request); | 215 const net::URLRequest* request); |
215 | 216 |
216 WEBKIT_STORAGE_COMMON_EXPORT extern const base::FilePath::CharType | 217 WEBKIT_STORAGE_COMMON_EXPORT extern const base::FilePath::CharType |
217 kAppCacheDatabaseName[]; | 218 kAppCacheDatabaseName[]; |
218 | 219 |
219 } // namespace | 220 } // namespace |
220 | 221 |
221 #endif // WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ | 222 #endif // WEBKIT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
OLD | NEW |