OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 WebWorkerFetchContext_h | 5 #ifndef WebWorkerFetchContext_h |
6 #define WebWorkerFetchContext_h | 6 #define WebWorkerFetchContext_h |
7 | 7 |
8 namespace base { | 8 namespace base { |
9 class SingleThreadTaskRunner; | 9 class SingleThreadTaskRunner; |
10 } // namespace base | 10 } // namespace base |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
| 14 class WebURL; |
14 class WebURLLoader; | 15 class WebURLLoader; |
15 class WebURLRequest; | 16 class WebURLRequest; |
16 | 17 |
17 // WebWorkerFetchContext is a per-worker object created on the main thread, | 18 // WebWorkerFetchContext is a per-worker object created on the main thread, |
18 // passed to a worker (dedicated, shared and service worker) and initialized on | 19 // passed to a worker (dedicated, shared and service worker) and initialized on |
19 // the worker thread by InitializeOnWorkerThread(). It contains information | 20 // the worker thread by InitializeOnWorkerThread(). It contains information |
20 // about the resource fetching context (ex: service worker provider id), and is | 21 // about the resource fetching context (ex: service worker provider id), and is |
21 // used to create a new WebURLLoader instance in the worker thread. | 22 // used to create a new WebURLLoader instance in the worker thread. |
22 class WebWorkerFetchContext { | 23 class WebWorkerFetchContext { |
23 public: | 24 public: |
24 virtual ~WebWorkerFetchContext() {} | 25 virtual ~WebWorkerFetchContext() {} |
25 | 26 |
26 virtual void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) = 0; | 27 virtual void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) = 0; |
27 | 28 |
28 // Returns a new WebURLLoader instance which is associated with the worker | 29 // Returns a new WebURLLoader instance which is associated with the worker |
29 // thread. | 30 // thread. |
30 virtual std::unique_ptr<WebURLLoader> CreateURLLoader() = 0; | 31 virtual std::unique_ptr<WebURLLoader> CreateURLLoader() = 0; |
31 | 32 |
32 // Called when a request is about to be sent out to modify the request to | 33 // Called when a request is about to be sent out to modify the request to |
33 // handle the request correctly in the loading stack later. (Example: service | 34 // handle the request correctly in the loading stack later. (Example: service |
34 // worker) | 35 // worker) |
35 virtual void WillSendRequest(WebURLRequest&) = 0; | 36 virtual void WillSendRequest(WebURLRequest&) = 0; |
36 | 37 |
37 // Whether the fetch context is controlled by a service worker. | 38 // Whether the fetch context is controlled by a service worker. |
38 virtual bool IsControlledByServiceWorker() const = 0; | 39 virtual bool IsControlledByServiceWorker() const = 0; |
| 40 virtual int64_t ServiceWorkerID() const { return 0; }; |
| 41 virtual void DidRunContentWithCertificateErrors(const WebURL& url) {} |
| 42 virtual void DidDisplayContentWithCertificateErrors(const WebURL& url) {} |
| 43 |
| 44 // Set the information about the resource fetching context. Must be called on |
| 45 // the main thread. |
| 46 virtual void SetAppCacheHostID(int id) {} |
| 47 virtual void SetDataSaverEnabled(bool flag) {} |
39 }; | 48 }; |
40 | 49 |
41 } // namespace blink | 50 } // namespace blink |
42 | 51 |
43 #endif // WebWorkerFetchContext_h | 52 #endif // WebWorkerFetchContext_h |
OLD | NEW |