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

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: 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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // 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.
46 // Must be called from the IO thread. 46 // Must be called from the IO thread.
47 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( 47 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent(
48 const std::set<std::string>& header_names); 48 const std::set<std::string>& header_names);
49 49
50 // 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.
51 // Must be called from the IO thread. 51 // Must be called from the IO thread.
52 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); 52 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name);
53 53
54 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: 54 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope:
55 // pattern}) from a renderer, except that |pattern| is an absolute URL instead 55 // pattern, bool: use_cache}) from a renderer, except that |pattern| is an
nhiroki 2017/03/24 00:33:42 "bool: use_cache" => "useCache: use_cache" ?
yuryu 2017/03/28 05:08:56 Done.
56 // of relative to some current origin. |callback| is passed true when the JS 56 // absolute URL instead of relative to some current origin. |callback| is
57 // promise is fulfilled or false when the JS promise is rejected. 57 // passed true when the JS promise is fulfilled or false when the JS promise
58 // is rejected.
58 // 59 //
59 // The registration can fail if: 60 // The registration can fail if:
60 // * |script_url| is on a different origin from |pattern| 61 // * |script_url| is on a different origin from |pattern|
61 // * Fetching |script_url| fails. 62 // * Fetching |script_url| fails.
62 // * |script_url| fails to parse or its top-level execution fails. 63 // * |script_url| fails to parse or its top-level execution fails.
63 // TODO: The error message for this needs to be available to developers. 64 // TODO: The error message for this needs to be available to developers.
64 // * Something unexpected goes wrong, like a renderer crash or a full disk. 65 // * Something unexpected goes wrong, like a renderer crash or a full disk.
65 // 66 //
66 // This function can be called from any thread, but the callback will always 67 // This function can be called from any thread, but the callback will always
67 // be called on the UI thread. 68 // be called on the UI thread.
68 virtual void RegisterServiceWorker(const Scope& pattern, 69 virtual void RegisterServiceWorker(const Scope& pattern,
69 const GURL& script_url, 70 const GURL& script_url,
71 bool use_cache,
falken 2017/03/24 04:06:19 Do we need to expose this use_cache to ServiceWork
yuryu 2017/03/24 04:45:55 https://cs.chromium.org/chromium/src/content/brows
falken 2017/03/27 06:15:37 Yes, you're right.
yuryu 2017/03/28 05:08:56 Acknowledged.
70 const ResultCallback& callback) = 0; 72 const ResultCallback& callback) = 0;
71 73
72 // Mechanism for embedder to increment/decrement ref count of a service 74 // Mechanism for embedder to increment/decrement ref count of a service
73 // worker. 75 // worker.
74 // Embedders can call StartingExternalRequest() while it is performing some 76 // Embedders can call StartingExternalRequest() while it is performing some
75 // work with the worker. The worker is considered to be working until embedder 77 // work with the worker. The worker is considered to be working until embedder
76 // calls FinishedExternalRequest(). This ensures that content/ does not 78 // calls FinishedExternalRequest(). This ensures that content/ does not
77 // shut the worker down while embedder is expecting the worker to be kept 79 // shut the worker down while embedder is expecting the worker to be kept
78 // alive. 80 // alive.
79 // 81 //
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const ResultCallback& callback) = 0; 158 const ResultCallback& callback) = 0;
157 159
158 protected: 160 protected:
159 ServiceWorkerContext() {} 161 ServiceWorkerContext() {}
160 virtual ~ServiceWorkerContext() {} 162 virtual ~ServiceWorkerContext() {}
161 }; 163 };
162 164
163 } // namespace content 165 } // namespace content
164 166
165 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 167 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698