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
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_APPCACHE_INTERFACES_H_
6 #define CONTENT_COMMON_APPCACHE_INTERFACES_H_
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "content/public/common/appcache_info.h"
20 // Defines constants, types, and abstract classes used in the main
21 // process and in child processes.
23 enum AppCacheEventID
{
24 APPCACHE_CHECKING_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
35 // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
36 enum AppCacheLogLevel
{
37 APPCACHE_LOG_DEBUG
= 4,
38 APPCACHE_LOG_INFO
= 1,
39 APPCACHE_LOG_WARNING
= 2,
40 APPCACHE_LOG_ERROR
= 3,
43 enum AppCacheNamespaceType
{
44 APPCACHE_FALLBACK_NAMESPACE
,
45 APPCACHE_INTERCEPT_NAMESPACE
,
46 APPCACHE_NETWORK_NAMESPACE
49 enum AppCacheErrorReason
{
50 APPCACHE_MANIFEST_ERROR
,
51 APPCACHE_SIGNATURE_ERROR
,
52 APPCACHE_RESOURCE_ERROR
,
53 APPCACHE_CHANGED_ERROR
,
56 APPCACHE_POLICY_ERROR
,
57 APPCACHE_UNKNOWN_ERROR
,
58 APPCACHE_ERROR_REASON_LAST
= APPCACHE_UNKNOWN_ERROR
61 // Type to hold information about a single appcache resource.
62 struct CONTENT_EXPORT AppCacheResourceInfo
{
63 AppCacheResourceInfo();
64 ~AppCacheResourceInfo();
77 struct CONTENT_EXPORT AppCacheErrorDetails
{
78 AppCacheErrorDetails();
79 AppCacheErrorDetails(std::string message
,
80 AppCacheErrorReason reason
,
83 bool is_cross_origin
);
84 ~AppCacheErrorDetails();
87 AppCacheErrorReason reason
;
93 typedef std::vector
<AppCacheResourceInfo
> AppCacheResourceInfoVector
;
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();
103 bool IsMatch(const GURL
& url
) const;
105 AppCacheNamespaceType type
;
112 typedef std::vector
<AppCacheNamespace
> AppCacheNamespaceVector
;
114 // Interface used by backend (browser-process) to talk to frontend (renderer).
115 class CONTENT_EXPORT AppCacheFrontend
{
117 virtual void OnCacheSelected(
118 int host_id
, const AppCacheInfo
& info
) = 0;
119 virtual void OnStatusChanged(const std::vector
<int>& host_ids
,
120 AppCacheStatus status
) = 0;
121 virtual void OnEventRaised(const std::vector
<int>& host_ids
,
122 AppCacheEventID event_id
) = 0;
123 virtual void OnProgressEventRaised(const std::vector
<int>& host_ids
,
125 int num_total
, int num_complete
) = 0;
126 virtual void OnErrorEventRaised(
127 const std::vector
<int>& host_ids
,
128 const AppCacheErrorDetails
& details
) = 0;
129 virtual void OnContentBlocked(int host_id
,
130 const GURL
& manifest_url
) = 0;
131 virtual void OnLogMessage(int host_id
, AppCacheLogLevel log_level
,
132 const std::string
& message
) = 0;
133 virtual ~AppCacheFrontend() {}
136 // Interface used by frontend (renderer) to talk to backend (browser-process).
137 class CONTENT_EXPORT AppCacheBackend
{
139 virtual void RegisterHost(int host_id
) = 0;
140 virtual void UnregisterHost(int host_id
) = 0;
141 virtual void SetSpawningHostId(int host_id
, int spawning_host_id
) = 0;
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;
146 virtual void SelectCacheForWorker(
148 int parent_process_id
,
149 int parent_host_id
) = 0;
150 virtual void SelectCacheForSharedWorker(
152 int64 appcache_id
) = 0;
153 virtual void MarkAsForeignEntry(int host_id
, const GURL
& document_url
,
154 int64 cache_document_was_loaded_from
) = 0;
155 virtual AppCacheStatus
GetStatus(int host_id
) = 0;
156 virtual bool StartUpdate(int host_id
) = 0;
157 virtual bool SwapCache(int host_id
) = 0;
158 virtual void GetResourceList(
159 int host_id
, std::vector
<AppCacheResourceInfo
>* resource_infos
) = 0;
162 virtual ~AppCacheBackend() {}
165 // Useful string constants.
166 CONTENT_EXPORT
extern const char kHttpGETMethod
[];
167 CONTENT_EXPORT
extern const char kHttpHEADMethod
[];
169 // base::CommandLine flag to turn this experimental feature on.
170 CONTENT_EXPORT
extern const char kEnableExecutableHandlers
[];
172 CONTENT_EXPORT
bool IsSchemeSupportedForAppCache(const GURL
& url
);
173 CONTENT_EXPORT
bool IsMethodSupportedForAppCache(
174 const std::string
& method
);
175 CONTENT_EXPORT
bool IsSchemeAndMethodSupportedForAppCache(
176 const net::URLRequest
* request
);
178 CONTENT_EXPORT
extern const base::FilePath::CharType
179 kAppCacheDatabaseName
[];
183 #endif // CONTENT_COMMON_APPCACHE_INTERFACES_H_