Chromium Code Reviews| 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 CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| 7 | 7 |
| 8 #include "content/common/service_worker/service_worker_types.h" | 8 #include "content/common/service_worker/service_worker_types.h" |
| 9 #include "content/common/worker_url_loader_factory_provider.mojom.h" | 9 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| 11 #include "mojo/public/cpp/bindings/associated_binding.h" | 11 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 12 #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" | 12 #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class SingleThreadTaskRunner; | 15 class SingleThreadTaskRunner; |
| 16 } // namespace base | 16 } // namespace base |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class ResourceDispatcher; | 20 class ResourceDispatcher; |
| 21 | 21 |
| 22 // This class is used while fetching resource requests on workers (dedicated | |
| 23 // worker and shared worker) when off-main-thread-fetch is enabled. This class | |
| 24 // is created on the main thread and passed to the worker thread. | |
|
falken
2017/05/18 02:14:13
Can you add "This class is not used for service wo
horo
2017/05/18 03:59:53
Done.
| |
| 22 class WorkerFetchContextImpl : public blink::WebWorkerFetchContext, | 25 class WorkerFetchContextImpl : public blink::WebWorkerFetchContext, |
| 23 public mojom::ServiceWorkerWorkerClient { | 26 public mojom::ServiceWorkerWorkerClient { |
| 24 public: | 27 public: |
| 25 explicit WorkerFetchContextImpl( | 28 explicit WorkerFetchContextImpl( |
| 26 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info); | 29 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info); |
| 27 ~WorkerFetchContextImpl() override; | 30 ~WorkerFetchContextImpl() override; |
| 28 | 31 |
| 29 // blink::WebWorkerFetchContext implementation: | 32 // blink::WebWorkerFetchContext implementation: |
| 30 void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) override; | 33 void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) override; |
| 31 std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override; | 34 std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override; |
| 32 void WillSendRequest(blink::WebURLRequest&) override; | 35 void WillSendRequest(blink::WebURLRequest&) override; |
| 33 bool IsControlledByServiceWorker() const override; | 36 bool IsControlledByServiceWorker() const override; |
| 34 void SetDataSaverEnabled(bool) override; | 37 void SetDataSaverEnabled(bool) override; |
| 35 bool IsDataSaverEnabled() const override; | 38 bool IsDataSaverEnabled() const override; |
| 36 | 39 |
| 37 // mojom::ServiceWorkerWorkerClient implementation: | 40 // mojom::ServiceWorkerWorkerClient implementation: |
| 38 void SetControllerServiceWorker(int64_t controller_version_id) override; | 41 void SetControllerServiceWorker(int64_t controller_version_id) override; |
| 39 | 42 |
| 40 // Sets the service worker status of the parent frame. | 43 // Sets the fetch context status copied from the frame; the parent frame for a |
| 44 // dedicated worker, the main frame of the shadow page for a shared worker. | |
| 41 void set_service_worker_provider_id(int id); | 45 void set_service_worker_provider_id(int id); |
| 42 void set_is_controlled_by_service_worker(bool flag); | 46 void set_is_controlled_by_service_worker(bool flag); |
| 43 void set_parent_frame_id(int id); | 47 void set_parent_frame_id(int id); |
| 48 // Set whether the worker context is a secure context. | |
| 49 // https://www.w3.org/TR/secure-contexts/ | |
|
falken
2017/05/18 02:14:13
https://w3c.github.io/webappsec-secure-contexts/ i
horo
2017/05/18 03:59:53
Done.
| |
| 50 void set_is_secure_context(bool flag); | |
| 44 | 51 |
| 45 private: | 52 private: |
| 46 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info_; | 53 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info_; |
| 47 int service_worker_provider_id_ = kInvalidServiceWorkerProviderId; | 54 int service_worker_provider_id_ = kInvalidServiceWorkerProviderId; |
| 48 bool is_controlled_by_service_worker_ = false; | 55 bool is_controlled_by_service_worker_ = false; |
| 49 | 56 |
| 50 // Initialized on the worker thread when InitializeOnWorkerThread() is called. | 57 // Initialized on the worker thread when InitializeOnWorkerThread() is called. |
| 51 std::unique_ptr<ResourceDispatcher> resource_dispatcher_; | 58 std::unique_ptr<ResourceDispatcher> resource_dispatcher_; |
| 52 std::unique_ptr<mojo::AssociatedBinding<mojom::ServiceWorkerWorkerClient>> | 59 std::unique_ptr<mojo::AssociatedBinding<mojom::ServiceWorkerWorkerClient>> |
| 53 binding_; | 60 binding_; |
| 54 mojom::WorkerURLLoaderFactoryProviderPtr provider_; | 61 mojom::WorkerURLLoaderFactoryProviderPtr provider_; |
| 55 mojom::URLLoaderFactoryAssociatedPtr url_loader_factory_; | 62 mojom::URLLoaderFactoryAssociatedPtr url_loader_factory_; |
| 56 | 63 |
| 57 // Updated when mojom::ServiceWorkerWorkerClient::SetControllerServiceWorker() | 64 // Updated when mojom::ServiceWorkerWorkerClient::SetControllerServiceWorker() |
| 58 // is called from the browser process via mojo IPC. | 65 // is called from the browser process via mojo IPC. |
| 59 int controller_version_id_ = kInvalidServiceWorkerVersionId; | 66 int controller_version_id_ = kInvalidServiceWorkerVersionId; |
| 60 | 67 |
| 61 bool is_data_saver_enabled_ = false; | 68 bool is_data_saver_enabled_ = false; |
| 62 int parent_frame_id_ = MSG_ROUTING_NONE; | 69 int parent_frame_id_ = MSG_ROUTING_NONE; |
| 70 bool is_secure_context_ = false; | |
| 63 }; | 71 }; |
| 64 | 72 |
| 65 } // namespace content | 73 } // namespace content |
| 66 | 74 |
| 67 #endif // CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ | 75 #endif // CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| OLD | NEW |