Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: content/public/browser/service_worker_context.h

Issue 2751343002: Adds a basic offline check to InstallableManager. (Closed)
Patch Set: Updated tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "content/public/browser/service_worker_usage_info.h" 12 #include "content/public/browser/service_worker_usage_info.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace blink { 15 namespace blink {
16 enum class WebNavigationHintType; 16 enum class WebNavigationHintType;
17 } 17 }
18 18
19 namespace content { 19 namespace content {
20 20
21 enum class ServiceWorkerStatus {
falken 2017/03/17 07:54:37 I'm a bit worried we have too many types named "St
piotrs 2017/03/21 00:00:44 It's not just about existence but about the extent
falken 2017/03/21 01:53:24 SGTM.
22 NO_SERVICE_WORKER,
23 SERVICE_WORKER_NO_FETCH_HANDLER,
24 SERVICE_WORKER_WITH_FETCH_HANDLER,
25 };
26
21 // Represents the per-StoragePartition ServiceWorker data. 27 // Represents the per-StoragePartition ServiceWorker data.
22 class ServiceWorkerContext { 28 class ServiceWorkerContext {
23 public: 29 public:
24 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: 30 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope:
25 // roughly, must be of the form "<origin>/<path>/*". 31 // roughly, must be of the form "<origin>/<path>/*".
26 using Scope = GURL; 32 using Scope = GURL;
27 33
28 using ResultCallback = base::Callback<void(bool success)>; 34 using ResultCallback = base::Callback<void(bool success)>;
29 35
30 using GetUsageInfoCallback = base::Callback<void( 36 using GetUsageInfoCallback = base::Callback<void(
31 const std::vector<ServiceWorkerUsageInfo>& usage_info)>; 37 const std::vector<ServiceWorkerUsageInfo>& usage_info)>;
32 38
33 using CheckHasServiceWorkerCallback = 39 using CheckServiceWorkerStatusCallback =
34 base::Callback<void(bool has_service_worker)>; 40 base::Callback<void(ServiceWorkerStatus status)>;
35 41
36 using CountExternalRequestsCallback = 42 using CountExternalRequestsCallback =
37 base::Callback<void(size_t external_request_count)>; 43 base::Callback<void(size_t external_request_count)>;
38 44
39 // Registers the header name which should not be passed to the ServiceWorker. 45 // Registers the header name which should not be passed to the ServiceWorker.
40 // Must be called from the IO thread. 46 // Must be called from the IO thread.
41 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( 47 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent(
42 const std::set<std::string>& header_names); 48 const std::set<std::string>& header_names);
43 49
44 // Returns true if the header name should not be passed to the ServiceWorker. 50 // Returns true if the header name should not be passed to the ServiceWorker.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; 104 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0;
99 105
100 // This function can be called from any thread, but the callback will always 106 // This function can be called from any thread, but the callback will always
101 // be called on the IO thread. 107 // be called on the IO thread.
102 virtual void DeleteForOrigin(const GURL& origin_url, 108 virtual void DeleteForOrigin(const GURL& origin_url,
103 const ResultCallback& callback) = 0; 109 const ResultCallback& callback) = 0;
104 110
105 // Returns true if a Service Worker registration exists that matches |url|, 111 // Returns true if a Service Worker registration exists that matches |url|,
106 // and if |other_url| falls inside the scope of the same registration. Note 112 // and if |other_url| falls inside the scope of the same registration. Note
107 // this still returns true even if there is a Service Worker registration 113 // this still returns true even if there is a Service Worker registration
108 // which has a longer match for |other_url|. 114 // which has a longer match for |other_url|.
falken 2017/03/17 07:54:37 It'd be worth clarifying in this comment what the
piotrs 2017/03/21 00:00:44 Good point, I've rewritten it a bit as well, as I
109 // 115 //
110 // This function can be called from any thread, but the callback will always 116 // This function can be called from any thread, but the callback will always
111 // be called on the UI thread. 117 // be called on the UI thread.
112 virtual void CheckHasServiceWorker( 118 virtual void CheckServiceWorkerStatus(
falken 2017/03/17 07:54:37 I think the original name may be clearer.
piotrs 2017/03/21 00:00:44 Reverted, Done.
113 const GURL& url, 119 const GURL& url,
114 const GURL& other_url, 120 const GURL& other_url,
115 const CheckHasServiceWorkerCallback& callback) = 0; 121 const CheckServiceWorkerStatusCallback& callback) = 0;
116 122
117 // Returns the pending external request count for the worker with the 123 // Returns the pending external request count for the worker with the
118 // specified |origin| via |callback|. 124 // specified |origin| via |callback|.
119 virtual void CountExternalRequestsForTest( 125 virtual void CountExternalRequestsForTest(
120 const GURL& origin, 126 const GURL& origin,
121 const CountExternalRequestsCallback& callback) = 0; 127 const CountExternalRequestsCallback& callback) = 0;
122 128
123 // Stops all running workers on the given |origin|. 129 // Stops all running workers on the given |origin|.
124 // 130 //
125 // This function can be called from any thread. 131 // This function can be called from any thread.
(...skipping 20 matching lines...) Expand all
146 const ResultCallback& callback) = 0; 152 const ResultCallback& callback) = 0;
147 153
148 protected: 154 protected:
149 ServiceWorkerContext() {} 155 ServiceWorkerContext() {}
150 virtual ~ServiceWorkerContext() {} 156 virtual ~ServiceWorkerContext() {}
151 }; 157 };
152 158
153 } // namespace content 159 } // namespace content
154 160
155 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 161 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698