[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 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 5 | #ifndef CONTENT_COMMON_APPCACHE_INTERFACES_H_ |
| 6 | #define CONTENT_COMMON_APPCACHE_INTERFACES_H_ |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 7 | |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 10 | #include <string> |
[email protected] | ad67777 | 2013-06-29 14:18:38 | [diff] [blame] | 11 | |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 12 | #include "base/files/file_path.h" |
Nicholas Verne | 8a13f005 | 2017-12-01 00:39:19 | [diff] [blame] | 13 | #include "content/common/appcache.mojom.h" |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 14 | #include "content/public/common/appcache_info.h" |
Anantanarayanan Iyengar | 2130d27 | 2017-09-01 18:21:14 | [diff] [blame] | 15 | #include "mojo/public/cpp/system/message_pipe.h" |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 16 | |
[email protected] | edfe7fab | 2010-11-28 13:11:52 | [diff] [blame] | 17 | namespace net { |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 18 | class URLRequest; |
[email protected] | ad67777 | 2013-06-29 14:18:38 | [diff] [blame] | 19 | } |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 20 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 21 | namespace content { |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 22 | |
| 23 | // Defines constants, types, and abstract classes used in the main |
| 24 | // process and in child processes. |
| 25 | |
Nicholas Verne | 8a13f005 | 2017-12-01 00:39:19 | [diff] [blame] | 26 | using mojom::AppCacheEventID; |
| 27 | using mojom::AppCacheErrorReason; |
| 28 | using mojom::AppCacheResourceInfo; |
| 29 | using mojom::AppCacheErrorDetails; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 30 | |
[email protected] | 653889b | 2013-02-18 15:42:43 | [diff] [blame] | 31 | // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 32 | enum AppCacheLogLevel { |
pfeldman | 2bcbc122 | 2017-01-21 06:08:54 | [diff] [blame] | 33 | APPCACHE_LOG_VERBOSE, |
| 34 | APPCACHE_LOG_INFO, |
| 35 | APPCACHE_LOG_WARNING, |
| 36 | APPCACHE_LOG_ERROR |
[email protected] | 53c570b | 2010-06-18 02:02:05 | [diff] [blame] | 37 | }; |
| 38 | |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 39 | enum AppCacheNamespaceType { |
[email protected] | 10f110fa | 2014-06-15 23:32:46 | [diff] [blame] | 40 | APPCACHE_FALLBACK_NAMESPACE, |
| 41 | APPCACHE_INTERCEPT_NAMESPACE, |
| 42 | APPCACHE_NETWORK_NAMESPACE |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 43 | }; |
| 44 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 45 | struct CONTENT_EXPORT AppCacheNamespace { |
| 46 | AppCacheNamespace(); // Type is APPCACHE_FALLBACK_NAMESPACE by default. |
| 47 | AppCacheNamespace(AppCacheNamespaceType type, const GURL& url, |
| 48 | const GURL& target, bool is_pattern); |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 49 | ~AppCacheNamespace(); |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 50 | |
[email protected] | 34e7dc6 | 2013-03-30 00:32:42 | [diff] [blame] | 51 | bool IsMatch(const GURL& url) const; |
| 52 | |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 53 | AppCacheNamespaceType type; |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 54 | GURL namespace_url; |
| 55 | GURL target_url; |
[email protected] | 34e7dc6 | 2013-03-30 00:32:42 | [diff] [blame] | 56 | bool is_pattern; |
[email protected] | e2cadec8 | 2011-12-13 02:00:53 | [diff] [blame] | 57 | }; |
| 58 | |
[email protected] | 19251af | 2010-05-13 18:24:46 | [diff] [blame] | 59 | // Interface used by backend (browser-process) to talk to frontend (renderer). |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 60 | class CONTENT_EXPORT AppCacheFrontend { |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 61 | public: |
[email protected] | ec5c192 | 2010-07-28 03:14:37 | [diff] [blame] | 62 | virtual void OnCacheSelected( |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 63 | int host_id, const AppCacheInfo& info) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 64 | virtual void OnStatusChanged(const std::vector<int>& host_ids, |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 65 | AppCacheStatus status) = 0; |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 66 | virtual void OnEventRaised(const std::vector<int>& host_ids, |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 67 | AppCacheEventID event_id) = 0; |
[email protected] | 697af4a | 2010-05-25 21:15:31 | [diff] [blame] | 68 | virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
| 69 | const GURL& url, |
| 70 | int num_total, int num_complete) = 0; |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 71 | virtual void OnErrorEventRaised( |
| 72 | const std::vector<int>& host_ids, |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 73 | const AppCacheErrorDetails& details) = 0; |
[email protected] | 5c7d598 | 2010-07-12 09:12:59 | [diff] [blame] | 74 | virtual void OnContentBlocked(int host_id, |
| 75 | const GURL& manifest_url) = 0; |
[email protected] | 45c6f68 | 2014-06-13 00:52:34 | [diff] [blame] | 76 | virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level, |
[email protected] | 53c570b | 2010-06-18 02:02:05 | [diff] [blame] | 77 | const std::string& message) = 0; |
Anantanarayanan Iyengar | 2130d27 | 2017-09-01 18:21:14 | [diff] [blame] | 78 | // In the network service world, we pass the URLLoaderFactory instance to be |
| 79 | // used to issue subresource requeste in the |loader_factory_pipe_handle| |
| 80 | // parameter. |
| 81 | virtual void OnSetSubresourceFactory( |
| 82 | int host_id, |
John Abd-El-Malek | b165dc5 | 2018-01-18 17:12:18 | [diff] [blame] | 83 | network::mojom::URLLoaderFactoryPtr url_loader_factory) = 0; |
Anantanarayanan Iyengar | 2130d27 | 2017-09-01 18:21:14 | [diff] [blame] | 84 | |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 85 | virtual ~AppCacheFrontend() {} |
| 86 | }; |
| 87 | |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 88 | // Useful string constants. |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 89 | CONTENT_EXPORT extern const char kHttpGETMethod[]; |
| 90 | CONTENT_EXPORT extern const char kHttpHEADMethod[]; |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 91 | |
[email protected] | 98d6d456 | 2014-06-25 20:57:55 | [diff] [blame] | 92 | CONTENT_EXPORT bool IsSchemeSupportedForAppCache(const GURL& url); |
| 93 | CONTENT_EXPORT bool IsMethodSupportedForAppCache( |
| 94 | const std::string& method); |
[email protected] | 7e8e3dd | 2009-09-18 01:05:09 | [diff] [blame] | 95 | |
[email protected] | f430b571 | 2009-08-21 21:46:31 | [diff] [blame] | 96 | } // namespace |
| 97 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 98 | #endif // CONTENT_COMMON_APPCACHE_INTERFACES_H_ |