blob: b3d9f0adce332a7b64b71bfd8634a98a0e260493 [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
tfarinabccc34c72015-02-27 21:32:155#ifndef CONTENT_COMMON_APPCACHE_INTERFACES_H_
6#define CONTENT_COMMON_APPCACHE_INTERFACES_H_
[email protected]f430b5712009-08-21 21:46:317
avia9aa7a82015-12-25 03:06:318#include <stdint.h>
9
[email protected]7e8e3dd2009-09-18 01:05:0910#include <string>
[email protected]ad677772013-06-29 14:18:3811
[email protected]57999812013-02-24 05:40:5212#include "base/files/file_path.h"
Nicholas Verne8a13f0052017-12-01 00:39:1913#include "content/common/appcache.mojom.h"
[email protected]98d6d4562014-06-25 20:57:5514#include "content/public/common/appcache_info.h"
Anantanarayanan Iyengar2130d272017-09-01 18:21:1415#include "mojo/public/cpp/system/message_pipe.h"
[email protected]f430b5712009-08-21 21:46:3116
[email protected]edfe7fab2010-11-28 13:11:5217namespace net {
[email protected]7e8e3dd2009-09-18 01:05:0918class URLRequest;
[email protected]ad677772013-06-29 14:18:3819}
[email protected]f430b5712009-08-21 21:46:3120
[email protected]98d6d4562014-06-25 20:57:5521namespace content {
[email protected]f430b5712009-08-21 21:46:3122
23// Defines constants, types, and abstract classes used in the main
24// process and in child processes.
25
Nicholas Verne8a13f0052017-12-01 00:39:1926using mojom::AppCacheEventID;
27using mojom::AppCacheErrorReason;
28using mojom::AppCacheResourceInfo;
29using mojom::AppCacheErrorDetails;
[email protected]f430b5712009-08-21 21:46:3130
[email protected]653889b2013-02-18 15:42:4331// Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
[email protected]45c6f682014-06-13 00:52:3432enum AppCacheLogLevel {
pfeldman2bcbc1222017-01-21 06:08:5433 APPCACHE_LOG_VERBOSE,
34 APPCACHE_LOG_INFO,
35 APPCACHE_LOG_WARNING,
36 APPCACHE_LOG_ERROR
[email protected]53c570b2010-06-18 02:02:0537};
38
[email protected]45c6f682014-06-13 00:52:3439enum AppCacheNamespaceType {
[email protected]10f110fa2014-06-15 23:32:4640 APPCACHE_FALLBACK_NAMESPACE,
41 APPCACHE_INTERCEPT_NAMESPACE,
42 APPCACHE_NETWORK_NAMESPACE
[email protected]e2cadec82011-12-13 02:00:5343};
44
[email protected]5e5bbf402011-07-12 23:34:1245typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector;
46
[email protected]98d6d4562014-06-25 20:57:5547struct CONTENT_EXPORT AppCacheNamespace {
48 AppCacheNamespace(); // Type is APPCACHE_FALLBACK_NAMESPACE by default.
49 AppCacheNamespace(AppCacheNamespaceType type, const GURL& url,
50 const GURL& target, bool is_pattern);
[email protected]98d6d4562014-06-25 20:57:5551 ~AppCacheNamespace();
[email protected]e2cadec82011-12-13 02:00:5352
[email protected]34e7dc62013-03-30 00:32:4253 bool IsMatch(const GURL& url) const;
54
[email protected]45c6f682014-06-13 00:52:3455 AppCacheNamespaceType type;
[email protected]e2cadec82011-12-13 02:00:5356 GURL namespace_url;
57 GURL target_url;
[email protected]34e7dc62013-03-30 00:32:4258 bool is_pattern;
[email protected]e2cadec82011-12-13 02:00:5359};
60
[email protected]98d6d4562014-06-25 20:57:5561typedef std::vector<AppCacheNamespace> AppCacheNamespaceVector;
[email protected]e2cadec82011-12-13 02:00:5362
[email protected]19251af2010-05-13 18:24:4663// Interface used by backend (browser-process) to talk to frontend (renderer).
[email protected]98d6d4562014-06-25 20:57:5564class CONTENT_EXPORT AppCacheFrontend {
[email protected]f430b5712009-08-21 21:46:3165 public:
[email protected]ec5c1922010-07-28 03:14:3766 virtual void OnCacheSelected(
[email protected]98d6d4562014-06-25 20:57:5567 int host_id, const AppCacheInfo& info) = 0;
[email protected]f430b5712009-08-21 21:46:3168 virtual void OnStatusChanged(const std::vector<int>& host_ids,
[email protected]45c6f682014-06-13 00:52:3469 AppCacheStatus status) = 0;
[email protected]f430b5712009-08-21 21:46:3170 virtual void OnEventRaised(const std::vector<int>& host_ids,
[email protected]45c6f682014-06-13 00:52:3471 AppCacheEventID event_id) = 0;
[email protected]697af4a2010-05-25 21:15:3172 virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
73 const GURL& url,
74 int num_total, int num_complete) = 0;
[email protected]45c6f682014-06-13 00:52:3475 virtual void OnErrorEventRaised(
76 const std::vector<int>& host_ids,
[email protected]98d6d4562014-06-25 20:57:5577 const AppCacheErrorDetails& details) = 0;
[email protected]5c7d5982010-07-12 09:12:5978 virtual void OnContentBlocked(int host_id,
79 const GURL& manifest_url) = 0;
[email protected]45c6f682014-06-13 00:52:3480 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level,
[email protected]53c570b2010-06-18 02:02:0581 const std::string& message) = 0;
Anantanarayanan Iyengar2130d272017-09-01 18:21:1482 // In the network service world, we pass the URLLoaderFactory instance to be
83 // used to issue subresource requeste in the |loader_factory_pipe_handle|
84 // parameter.
85 virtual void OnSetSubresourceFactory(
86 int host_id,
John Abd-El-Malekb165dc52018-01-18 17:12:1887 network::mojom::URLLoaderFactoryPtr url_loader_factory) = 0;
Anantanarayanan Iyengar2130d272017-09-01 18:21:1488
[email protected]f430b5712009-08-21 21:46:3189 virtual ~AppCacheFrontend() {}
90};
91
[email protected]19251af2010-05-13 18:24:4692// Interface used by frontend (renderer) to talk to backend (browser-process).
[email protected]98d6d4562014-06-25 20:57:5593class CONTENT_EXPORT AppCacheBackend {
[email protected]f430b5712009-08-21 21:46:3194 public:
95 virtual void RegisterHost(int host_id) = 0;
96 virtual void UnregisterHost(int host_id) = 0;
[email protected]e16b8af72011-03-21 22:11:4297 virtual void SetSpawningHostId(int host_id, int spawning_host_id) = 0;
[email protected]f430b5712009-08-21 21:46:3198 virtual void SelectCache(int host_id,
99 const GURL& document_url,
avia9aa7a82015-12-25 03:06:31100 const int64_t cache_document_was_loaded_from,
[email protected]f430b5712009-08-21 21:46:31101 const GURL& manifest_url) = 0;
avia9aa7a82015-12-25 03:06:31102 virtual void SelectCacheForSharedWorker(int host_id, int64_t appcache_id) = 0;
103 virtual void MarkAsForeignEntry(int host_id,
104 const GURL& document_url,
105 int64_t cache_document_was_loaded_from) = 0;
[email protected]45c6f682014-06-13 00:52:34106 virtual AppCacheStatus GetStatus(int host_id) = 0;
[email protected]f430b5712009-08-21 21:46:31107 virtual bool StartUpdate(int host_id) = 0;
108 virtual bool SwapCache(int host_id) = 0;
[email protected]ec5c1922010-07-28 03:14:37109 virtual void GetResourceList(
110 int host_id, std::vector<AppCacheResourceInfo>* resource_infos) = 0;
[email protected]f430b5712009-08-21 21:46:31111
[email protected]7ee2e882012-06-04 08:54:10112 protected:
[email protected]f430b5712009-08-21 21:46:31113 virtual ~AppCacheBackend() {}
114};
115
[email protected]7e8e3dd2009-09-18 01:05:09116// Useful string constants.
[email protected]98d6d4562014-06-25 20:57:55117CONTENT_EXPORT extern const char kHttpGETMethod[];
118CONTENT_EXPORT extern const char kHttpHEADMethod[];
[email protected]7e8e3dd2009-09-18 01:05:09119
avi83883c82014-12-23 00:08:49120// base::CommandLine flag to turn this experimental feature on.
[email protected]98d6d4562014-06-25 20:57:55121CONTENT_EXPORT extern const char kEnableExecutableHandlers[];
[email protected]8fb8eeb92013-04-17 18:50:43122
[email protected]98d6d4562014-06-25 20:57:55123CONTENT_EXPORT bool IsSchemeSupportedForAppCache(const GURL& url);
124CONTENT_EXPORT bool IsMethodSupportedForAppCache(
125 const std::string& method);
[email protected]7e8e3dd2009-09-18 01:05:09126
[email protected]98d6d4562014-06-25 20:57:55127CONTENT_EXPORT extern const base::FilePath::CharType
[email protected]a3ef4832013-02-02 05:12:33128 kAppCacheDatabaseName[];
[email protected]4cccc222010-04-02 22:12:56129
[email protected]f430b5712009-08-21 21:46:31130} // namespace
131
tfarinabccc34c72015-02-27 21:32:15132#endif // CONTENT_COMMON_APPCACHE_INTERFACES_H_