blob: ba5847e5c1eea2195f135b3bebdd70c709bd3ddc [file] [log] [blame]
[email protected]7ee2e882012-06-04 08:54:101// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]f430b5712009-08-21 21:46:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]98d6d4562014-06-25 20:57:555#ifndef CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_
6#define CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_
[email protected]f430b5712009-08-21 21:46:317
[email protected]7e8e3dd2009-09-18 01:05:098#include <string>
[email protected]ad677772013-06-29 14:18:389
[email protected]f430b5712009-08-21 21:46:3110#include "base/basictypes.h"
[email protected]57999812013-02-24 05:40:5211#include "base/files/file_path.h"
[email protected]98d6d4562014-06-25 20:57:5512#include "content/public/common/appcache_info.h"
[email protected]f430b5712009-08-21 21:46:3113
[email protected]edfe7fab2010-11-28 13:11:5214namespace net {
[email protected]7e8e3dd2009-09-18 01:05:0915class URLRequest;
[email protected]ad677772013-06-29 14:18:3816}
[email protected]f430b5712009-08-21 21:46:3117
[email protected]98d6d4562014-06-25 20:57:5518namespace content {
[email protected]f430b5712009-08-21 21:46:3119
20// Defines constants, types, and abstract classes used in the main
21// process and in child processes.
22
[email protected]45c6f682014-06-13 00:52:3423enum AppCacheEventID {
[email protected]10f110fa2014-06-15 23:32:4624 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]f430b5712009-08-21 21:46:3133};
34
[email protected]653889b2013-02-18 15:42:4335// Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
[email protected]45c6f682014-06-13 00:52:3436enum AppCacheLogLevel {
[email protected]10f110fa2014-06-15 23:32:4637 APPCACHE_LOG_DEBUG = 4,
38 APPCACHE_LOG_INFO = 1,
39 APPCACHE_LOG_WARNING = 2,
40 APPCACHE_LOG_ERROR = 3,
[email protected]53c570b2010-06-18 02:02:0541};
42
[email protected]45c6f682014-06-13 00:52:3443enum AppCacheNamespaceType {
[email protected]10f110fa2014-06-15 23:32:4644 APPCACHE_FALLBACK_NAMESPACE,
45 APPCACHE_INTERCEPT_NAMESPACE,
46 APPCACHE_NETWORK_NAMESPACE
[email protected]e2cadec82011-12-13 02:00:5347};
48
[email protected]45c6f682014-06-13 00:52:3449enum AppCacheErrorReason {
[email protected]10f110fa2014-06-15 23:32:4650 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]46aede52014-04-01 01:35:4459};
60
[email protected]20f0487a2010-09-30 20:06:3061// Type to hold information about a single appcache resource.
[email protected]98d6d4562014-06-25 20:57:5562struct CONTENT_EXPORT AppCacheResourceInfo {
[email protected]20f0487a2010-09-30 20:06:3063 AppCacheResourceInfo();
64 ~AppCacheResourceInfo();
65
[email protected]ec5c1922010-07-28 03:14:3766 GURL url;
67 int64 size;
68 bool is_master;
69 bool is_manifest;
[email protected]e2cadec82011-12-13 02:00:5370 bool is_intercept;
[email protected]ec5c1922010-07-28 03:14:3771 bool is_fallback;
72 bool is_foreign;
73 bool is_explicit;
[email protected]5e5bbf402011-07-12 23:34:1274 int64 response_id;
[email protected]ec5c1922010-07-28 03:14:3775};
76
[email protected]98d6d4562014-06-25 20:57:5577struct CONTENT_EXPORT AppCacheErrorDetails {
[email protected]45c6f682014-06-13 00:52:3478 AppCacheErrorDetails();
79 AppCacheErrorDetails(std::string message,
80 AppCacheErrorReason reason,
[email protected]46aede52014-04-01 01:35:4481 GURL url,
82 int status,
83 bool is_cross_origin);
[email protected]45c6f682014-06-13 00:52:3484 ~AppCacheErrorDetails();
[email protected]46aede52014-04-01 01:35:4485
86 std::string message;
[email protected]45c6f682014-06-13 00:52:3487 AppCacheErrorReason reason;
[email protected]46aede52014-04-01 01:35:4488 GURL url;
89 int status;
90 bool is_cross_origin;
91};
92
[email protected]5e5bbf402011-07-12 23:34:1293typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector;
94
[email protected]98d6d4562014-06-25 20:57:5595struct 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]e2cadec82011-12-13 02:00:53102
[email protected]34e7dc62013-03-30 00:32:42103 bool IsMatch(const GURL& url) const;
104
[email protected]45c6f682014-06-13 00:52:34105 AppCacheNamespaceType type;
[email protected]e2cadec82011-12-13 02:00:53106 GURL namespace_url;
107 GURL target_url;
[email protected]34e7dc62013-03-30 00:32:42108 bool is_pattern;
[email protected]8fb8eeb92013-04-17 18:50:43109 bool is_executable;
[email protected]e2cadec82011-12-13 02:00:53110};
111
[email protected]98d6d4562014-06-25 20:57:55112typedef std::vector<AppCacheNamespace> AppCacheNamespaceVector;
[email protected]e2cadec82011-12-13 02:00:53113
[email protected]19251af2010-05-13 18:24:46114// Interface used by backend (browser-process) to talk to frontend (renderer).
[email protected]98d6d4562014-06-25 20:57:55115class CONTENT_EXPORT AppCacheFrontend {
[email protected]f430b5712009-08-21 21:46:31116 public:
[email protected]ec5c1922010-07-28 03:14:37117 virtual void OnCacheSelected(
[email protected]98d6d4562014-06-25 20:57:55118 int host_id, const AppCacheInfo& info) = 0;
[email protected]f430b5712009-08-21 21:46:31119 virtual void OnStatusChanged(const std::vector<int>& host_ids,
[email protected]45c6f682014-06-13 00:52:34120 AppCacheStatus status) = 0;
[email protected]f430b5712009-08-21 21:46:31121 virtual void OnEventRaised(const std::vector<int>& host_ids,
[email protected]45c6f682014-06-13 00:52:34122 AppCacheEventID event_id) = 0;
[email protected]697af4a2010-05-25 21:15:31123 virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
124 const GURL& url,
125 int num_total, int num_complete) = 0;
[email protected]45c6f682014-06-13 00:52:34126 virtual void OnErrorEventRaised(
127 const std::vector<int>& host_ids,
[email protected]98d6d4562014-06-25 20:57:55128 const AppCacheErrorDetails& details) = 0;
[email protected]5c7d5982010-07-12 09:12:59129 virtual void OnContentBlocked(int host_id,
130 const GURL& manifest_url) = 0;
[email protected]45c6f682014-06-13 00:52:34131 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level,
[email protected]53c570b2010-06-18 02:02:05132 const std::string& message) = 0;
[email protected]f430b5712009-08-21 21:46:31133 virtual ~AppCacheFrontend() {}
134};
135
[email protected]19251af2010-05-13 18:24:46136// Interface used by frontend (renderer) to talk to backend (browser-process).
[email protected]98d6d4562014-06-25 20:57:55137class CONTENT_EXPORT AppCacheBackend {
[email protected]f430b5712009-08-21 21:46:31138 public:
139 virtual void RegisterHost(int host_id) = 0;
140 virtual void UnregisterHost(int host_id) = 0;
[email protected]e16b8af72011-03-21 22:11:42141 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0;
[email protected]f430b5712009-08-21 21:46:31142 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]19251af2010-05-13 18:24:46146 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]f430b5712009-08-21 21:46:31153 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url,
154 int64 cache_document_was_loaded_from) = 0;
[email protected]45c6f682014-06-13 00:52:34155 virtual AppCacheStatus GetStatus(int host_id) = 0;
[email protected]f430b5712009-08-21 21:46:31156 virtual bool StartUpdate(int host_id) = 0;
157 virtual bool SwapCache(int host_id) = 0;
[email protected]ec5c1922010-07-28 03:14:37158 virtual void GetResourceList(
159 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0;
[email protected]f430b5712009-08-21 21:46:31160
[email protected]7ee2e882012-06-04 08:54:10161 protected:
[email protected]f430b5712009-08-21 21:46:31162 virtual ~AppCacheBackend() {}
163};
164
[email protected]7e8e3dd2009-09-18 01:05:09165// Useful string constants.
166// Note: These are also defined elsewhere in the chrome code base in
[email protected]98d6d4562014-06-25 20:57:55167// url_contants.h .cc, however the content library can not have
[email protected]7e8e3dd2009-09-18 01:05:09168// any dependencies on the chrome library, so we can't use them in here.
[email protected]98d6d4562014-06-25 20:57:55169CONTENT_EXPORT extern const char kHttpScheme[];
170CONTENT_EXPORT extern const char kHttpsScheme[];
171CONTENT_EXPORT extern const char kHttpGETMethod[];
172CONTENT_EXPORT extern const char kHttpHEADMethod[];
[email protected]7e8e3dd2009-09-18 01:05:09173
avi83883c82014-12-23 00:08:49174// base::CommandLine flag to turn this experimental feature on.
[email protected]98d6d4562014-06-25 20:57:55175CONTENT_EXPORT extern const char kEnableExecutableHandlers[];
[email protected]8fb8eeb92013-04-17 18:50:43176
[email protected]98d6d4562014-06-25 20:57:55177CONTENT_EXPORT bool IsSchemeSupportedForAppCache(const GURL& url);
178CONTENT_EXPORT bool IsMethodSupportedForAppCache(
179 const std::string& method);
180CONTENT_EXPORT bool IsSchemeAndMethodSupportedForAppCache(
[email protected]35456abfb2013-06-11 10:57:39181 const net::URLRequest* request);
[email protected]7e8e3dd2009-09-18 01:05:09182
[email protected]98d6d4562014-06-25 20:57:55183CONTENT_EXPORT extern const base::FilePath::CharType
[email protected]a3ef4832013-02-02 05:12:33184 kAppCacheDatabaseName[];
[email protected]4cccc222010-04-02 22:12:56185
[email protected]f430b5712009-08-21 21:46:31186} // namespace
187
[email protected]98d6d4562014-06-25 20:57:55188#endif // CONTENT_COMMON_APPCACHE_APPCACHE_INTERFACES_H_