[email protected] | 7ee2e88 | 2012-06-04 08:54:10 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 5 | #ifndef CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
| 6 | #define CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 7 | |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 8 | #include <string> |
[email protected] | ad67777 | 2013-06-29 14:18:38 | [diff] [blame] | 9 | |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 10 | #include "base/basictypes.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 11 | #include "base/files/file_path.h" |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 12 | #include "content/public/common/appcache_info.h" |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 13 | |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 14 | namespace net { |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 15 | class URLRequest; |
[email protected] | ad67777 | 2013-06-29 14:18:38 | [diff] [blame] | 16 | } |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 17 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 18 | namespace content { |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 19 | |
| 20 | // Defines constants, types, and abstract classes used in the main |
| 21 | // process and in child processes. |
| 22 | |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 23 | enum AppCacheEventID { |
[email protected] | 10f110fa | 2014-06-15 23:32:46 | [diff] [blame] | 24 | APPCACHE_CHECKING_EVENT, |
| 25 | APPCACHE_ERROR_EVENT, |
| 26 | APPCACHE_NO_UPDATE_EVENT, |
| 27 | APPCACHE_DOWNLOADING_EVENT, |
| 28 | APPCACHE_PROGRESS_EVENT, |
| 29 | APPCACHE_UPDATE_READY_EVENT, |
| 30 | APPCACHE_CACHED_EVENT, |
| 31 | APPCACHE_OBSOLETE_EVENT, |
| 32 | APPCACHE_EVENT_ID_LAST = APPCACHE_OBSOLETE_EVENT |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 33 | }; |
| 34 | |
[email protected] | 653889b | 2013-02-18 15:42:43 | [diff] [blame] | 35 | // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 36 | enum AppCacheLogLevel { |
[email protected] | 10f110fa | 2014-06-15 23:32:46 | [diff] [blame] | 37 | APPCACHE_LOG_DEBUG = 4, |
| 38 | APPCACHE_LOG_INFO = 1, |
| 39 | APPCACHE_LOG_WARNING = 2, |
| 40 | APPCACHE_LOG_ERROR = 3, |
[email protected] | 53c570b | 2010-06-18 02:02:05 | [diff] [blame] | 41 | }; |
| 42 | |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 43 | enum AppCacheNamespaceType { |
[email protected] | 10f110fa | 2014-06-15 23:32:46 | [diff] [blame] | 44 | APPCACHE_FALLBACK_NAMESPACE, |
| 45 | APPCACHE_INTERCEPT_NAMESPACE, |
| 46 | APPCACHE_NETWORK_NAMESPACE |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 47 | }; |
| 48 | |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 49 | enum AppCacheErrorReason { |
[email protected] | 10f110fa | 2014-06-15 23:32:46 | [diff] [blame] | 50 | APPCACHE_MANIFEST_ERROR, |
| 51 | APPCACHE_SIGNATURE_ERROR, |
| 52 | APPCACHE_RESOURCE_ERROR, |
| 53 | APPCACHE_CHANGED_ERROR, |
| 54 | APPCACHE_ABORT_ERROR, |
| 55 | APPCACHE_QUOTA_ERROR, |
| 56 | APPCACHE_POLICY_ERROR, |
| 57 | APPCACHE_UNKNOWN_ERROR, |
| 58 | APPCACHE_ERROR_REASON_LAST = APPCACHE_UNKNOWN_ERROR |
[email protected] | 46aede5 | 2014-04-01 01:35:44 | [diff] [blame] | 59 | }; |
| 60 | |
[email protected] | 20f0487a | 2010-09-30 20:06:30 | [diff] [blame] | 61 | // Type to hold information about a single appcache resource. |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 62 | struct CONTENT_EXPORT AppCacheResourceInfo { |
[email protected] | 20f0487a | 2010-09-30 20:06:30 | [diff] [blame] | 63 | AppCacheResourceInfo(); |
| 64 | ~AppCacheResourceInfo(); |
| 65 | |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 66 | GURL url; |
| 67 | int64 size; |
| 68 | bool is_master; |
| 69 | bool is_manifest; |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 70 | bool is_intercept; |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 71 | bool is_fallback; |
| 72 | bool is_foreign; |
| 73 | bool is_explicit; |
[email protected] | 5e5bbf40 | 2011-07-12 23:34:12 | [diff] [blame] | 74 | int64 response_id; |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 75 | }; |
| 76 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 77 | struct CONTENT_EXPORT AppCacheErrorDetails { |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 78 | AppCacheErrorDetails(); |
| 79 | AppCacheErrorDetails(std::string message, |
| 80 | AppCacheErrorReason reason, |
[email protected] | 46aede5 | 2014-04-01 01:35:44 | [diff] [blame] | 81 | GURL url, |
| 82 | int status, |
| 83 | bool is_cross_origin); |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 84 | ~AppCacheErrorDetails(); |
[email protected] | 46aede5 | 2014-04-01 01:35:44 | [diff] [blame] | 85 | |
| 86 | std::string message; |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 87 | AppCacheErrorReason reason; |
[email protected] | 46aede5 | 2014-04-01 01:35:44 | [diff] [blame] | 88 | GURL url; |
| 89 | int status; |
| 90 | bool is_cross_origin; |
| 91 | }; |
| 92 | |
[email protected] | 5e5bbf40 | 2011-07-12 23:34:12 | [diff] [blame] | 93 | typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector; |
| 94 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 95 | struct CONTENT_EXPORT AppCacheNamespace { |
| 96 | AppCacheNamespace(); // Type is APPCACHE_FALLBACK_NAMESPACE by default. |
| 97 | AppCacheNamespace(AppCacheNamespaceType type, const GURL& url, |
| 98 | const GURL& target, bool is_pattern); |
| 99 | AppCacheNamespace(AppCacheNamespaceType type, const GURL& url, |
| 100 | const GURL& target, bool is_pattern, bool is_executable); |
| 101 | ~AppCacheNamespace(); |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 102 | |
[email protected] | 34e7dc6 | 2013-03-30 00:32:42 | [diff] [blame] | 103 | bool IsMatch(const GURL& url) const; |
| 104 | |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 105 | AppCacheNamespaceType type; |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 106 | GURL namespace_url; |
| 107 | GURL target_url; |
[email protected] | 34e7dc6 | 2013-03-30 00:32:42 | [diff] [blame] | 108 | bool is_pattern; |
[email protected] | 8fb8eeb9 | 2013-04-17 18:50:43 | [diff] [blame] | 109 | bool is_executable; |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 110 | }; |
| 111 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 112 | typedef std::vector<AppCacheNamespace> AppCacheNamespaceVector; |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 113 | |
[email protected] | 19251af | 2010-05-13 18:24:46 | [diff] [blame] | 114 | // Interface used by backend (browser-process) to talk to frontend (renderer). |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 115 | class CONTENT_EXPORT AppCacheFrontend { |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 116 | public: |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 117 | virtual void OnCacheSelected( |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 118 | int host_id, const AppCacheInfo& info) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 119 | virtual void OnStatusChanged(const std::vector<int>& host_ids, |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 120 | AppCacheStatus status) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 121 | virtual void OnEventRaised(const std::vector<int>& host_ids, |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 122 | AppCacheEventID event_id) = 0; |
[email protected] | 697af4a | 2010-05-25 21:15:31 | [diff] [blame] | 123 | virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
| 124 | const GURL& url, |
| 125 | int num_total, int num_complete) = 0; |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 126 | virtual void OnErrorEventRaised( |
| 127 | const std::vector<int>& host_ids, |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 128 | const AppCacheErrorDetails& details) = 0; |
[email protected] | 5c7d598 | 2010-07-12 09:12:59 | [diff] [blame] | 129 | virtual void OnContentBlocked(int host_id, |
| 130 | const GURL& manifest_url) = 0; |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 131 | virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level, |
[email protected] | 53c570b | 2010-06-18 02:02:05 | [diff] [blame] | 132 | const std::string& message) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 133 | virtual ~AppCacheFrontend() {} |
| 134 | }; |
| 135 | |
[email protected] | 19251af | 2010-05-13 18:24:46 | [diff] [blame] | 136 | // Interface used by frontend (renderer) to talk to backend (browser-process). |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 137 | class CONTENT_EXPORT AppCacheBackend { |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 138 | public: |
| 139 | virtual void RegisterHost(int host_id) = 0; |
| 140 | virtual void UnregisterHost(int host_id) = 0; |
[email protected] | e16b8af7 | 2011-03-21 22:11:42 | [diff] [blame] | 141 | virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 142 | virtual void SelectCache(int host_id, |
| 143 | const GURL& document_url, |
| 144 | const int64 cache_document_was_loaded_from, |
| 145 | const GURL& manifest_url) = 0; |
[email protected] | 19251af | 2010-05-13 18:24:46 | [diff] [blame] | 146 | virtual void SelectCacheForWorker( |
| 147 | int host_id, |
| 148 | int parent_process_id, |
| 149 | int parent_host_id) = 0; |
| 150 | virtual void SelectCacheForSharedWorker( |
| 151 | int host_id, |
| 152 | int64 appcache_id) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 153 | virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, |
| 154 | int64 cache_document_was_loaded_from) = 0; |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 155 | virtual AppCacheStatus GetStatus(int host_id) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 156 | virtual bool StartUpdate(int host_id) = 0; |
| 157 | virtual bool SwapCache(int host_id) = 0; |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 158 | virtual void GetResourceList( |
| 159 | int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 160 | |
[email protected] | 7ee2e88 | 2012-06-04 08:54:10 | [diff] [blame] | 161 | protected: |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 162 | virtual ~AppCacheBackend() {} |
| 163 | }; |
| 164 | |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 165 | // Useful string constants. |
| 166 | // Note: These are also defined elsewhere in the chrome code base in |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 167 | // url_contants.h .cc, however the content library can not have |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 168 | // any dependencies on the chrome library, so we can't use them in here. |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 169 | CONTENT_EXPORT extern const char kHttpScheme[]; |
| 170 | CONTENT_EXPORT extern const char kHttpsScheme[]; |
| 171 | CONTENT_EXPORT extern const char kHttpGETMethod[]; |
| 172 | CONTENT_EXPORT extern const char kHttpHEADMethod[]; |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 173 | |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame^] | 174 | // base::CommandLine flag to turn this experimental feature on. |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 175 | CONTENT_EXPORT extern const char kEnableExecutableHandlers[]; |
[email protected] | 8fb8eeb9 | 2013-04-17 18:50:43 | [diff] [blame] | 176 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 177 | CONTENT_EXPORT bool IsSchemeSupportedForAppCache(const GURL& url); |
| 178 | CONTENT_EXPORT bool IsMethodSupportedForAppCache( |
| 179 | const std::string& method); |
| 180 | CONTENT_EXPORT bool IsSchemeAndMethodSupportedForAppCache( |
[email protected] | 35456abfb | 2013-06-11 10:57:39 | [diff] [blame] | 181 | const net::URLRequest* request); |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 182 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 183 | CONTENT_EXPORT extern const base::FilePath::CharType |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 184 | kAppCacheDatabaseName[]; |
[email protected] | 4cccc22 | 2010-04-02 22:12:56 | [diff] [blame] | 185 | |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 186 | } // namespace |
| 187 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 188 | #endif // CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_ |