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

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

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: fix IPC Created 3 years, 4 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 {
16 enum class WebServiceWorkerUpdateViaCache;
17 } // namespace blink
18
15 namespace content { 19 namespace content {
16 20
17 class ServiceWorkerContextObserver; 21 class ServiceWorkerContextObserver;
18 22
19 enum class ServiceWorkerCapability { 23 enum class ServiceWorkerCapability {
20 NO_SERVICE_WORKER, 24 NO_SERVICE_WORKER,
21 SERVICE_WORKER_NO_FETCH_HANDLER, 25 SERVICE_WORKER_NO_FETCH_HANDLER,
22 SERVICE_WORKER_WITH_FETCH_HANDLER, 26 SERVICE_WORKER_WITH_FETCH_HANDLER,
23 }; 27 };
24 28
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); 78 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name);
75 79
76 // Returns true if |url| is within the service worker |scope|. 80 // Returns true if |url| is within the service worker |scope|.
77 CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url); 81 CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url);
78 82
79 // Observer methods are always dispatched on the UI thread. 83 // Observer methods are always dispatched on the UI thread.
80 virtual void AddObserver(ServiceWorkerContextObserver* observer) = 0; 84 virtual void AddObserver(ServiceWorkerContextObserver* observer) = 0;
81 virtual void RemoveObserver(ServiceWorkerContextObserver* observer) = 0; 85 virtual void RemoveObserver(ServiceWorkerContextObserver* observer) = 0;
82 86
83 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: 87 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope:
84 // pattern}) from a renderer, except that |pattern| is an absolute URL instead 88 // pattern, updateViaCache: update_via_cache}) from a renderer, except that
85 // of relative to some current origin. |callback| is passed true when the JS 89 // |pattern| is an absolute URL instead of relative to some current origin.
86 // promise is fulfilled or false when the JS promise is rejected. 90 // |callback| is passed true when the JS promise is fulfilled or false when
91 // the JS promise is rejected.
87 // 92 //
88 // The registration can fail if: 93 // The registration can fail if:
89 // * |script_url| is on a different origin from |pattern| 94 // * |script_url| is on a different origin from |pattern|
90 // * Fetching |script_url| fails. 95 // * Fetching |script_url| fails.
91 // * |script_url| fails to parse or its top-level execution fails. 96 // * |script_url| fails to parse or its top-level execution fails.
92 // TODO: The error message for this needs to be available to developers. 97 // TODO: The error message for this needs to be available to developers.
93 // * Something unexpected goes wrong, like a renderer crash or a full disk. 98 // * Something unexpected goes wrong, like a renderer crash or a full disk.
94 // 99 //
95 // This function can be called from any thread, but the callback will always 100 // This function can be called from any thread, but the callback will always
96 // be called on the UI thread. 101 // be called on the UI thread.
97 virtual void RegisterServiceWorker(const Scope& pattern, 102 virtual void RegisterServiceWorker(
98 const GURL& script_url, 103 const Scope& pattern,
99 const ResultCallback& callback) = 0; 104 const GURL& script_url,
105 blink::WebServiceWorkerUpdateViaCache update_via_cache,
106 const ResultCallback& callback) = 0;
100 107
101 // Mechanism for embedder to increment/decrement ref count of a service 108 // Mechanism for embedder to increment/decrement ref count of a service
102 // worker. 109 // worker.
103 // Embedders can call StartingExternalRequest() while it is performing some 110 // Embedders can call StartingExternalRequest() while it is performing some
104 // work with the worker. The worker is considered to be working until embedder 111 // work with the worker. The worker is considered to be working until embedder
105 // calls FinishedExternalRequest(). This ensures that content/ does not 112 // calls FinishedExternalRequest(). This ensures that content/ does not
106 // shut the worker down while embedder is expecting the worker to be kept 113 // shut the worker down while embedder is expecting the worker to be kept
107 // alive. 114 // alive.
108 // 115 //
109 // Must be called from the IO thread. Returns whether or not changing the ref 116 // Must be called from the IO thread. Returns whether or not changing the ref
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const StartServiceWorkerForNavigationHintCallback& callback) = 0; 196 const StartServiceWorkerForNavigationHintCallback& callback) = 0;
190 197
191 protected: 198 protected:
192 ServiceWorkerContext() {} 199 ServiceWorkerContext() {}
193 virtual ~ServiceWorkerContext() {} 200 virtual ~ServiceWorkerContext() {}
194 }; 201 };
195 202
196 } // namespace content 203 } // namespace content
197 204
198 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 205 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/common/service_worker/service_worker_types.cc ('k') | content/public/test/mock_service_worker_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698