Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "content/browser/service_worker/service_worker_registration.h" | 21 #include "content/browser/service_worker/service_worker_registration.h" |
| 22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 23 #include "content/common/service_worker/service_worker_provider.h" | |
| 23 #include "content/common/service_worker/service_worker_types.h" | 24 #include "content/common/service_worker/service_worker_types.h" |
| 24 #include "content/public/common/request_context_frame_type.h" | 25 #include "content/public/common/request_context_frame_type.h" |
| 25 #include "content/public/common/request_context_type.h" | 26 #include "content/public/common/request_context_type.h" |
| 26 #include "content/public/common/resource_type.h" | 27 #include "content/public/common/resource_type.h" |
| 27 | 28 |
| 28 namespace storage { | 29 namespace storage { |
| 29 class BlobStorageContext; | 30 class BlobStorageContext; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 // ServiceWorkerNetworkProvider will later be created in the renderer, should | 65 // ServiceWorkerNetworkProvider will later be created in the renderer, should |
| 65 // the navigation succeed. |is_parent_frame_is_secure| should be true for main | 66 // the navigation succeed. |is_parent_frame_is_secure| should be true for main |
| 66 // frames. Otherwise it is true iff all ancestor frames of this frame have a | 67 // frames. Otherwise it is true iff all ancestor frames of this frame have a |
| 67 // secure origin. |web_contents_getter| indicates the tab where the navigation | 68 // secure origin. |web_contents_getter| indicates the tab where the navigation |
| 68 // is occurring. | 69 // is occurring. |
| 69 static std::unique_ptr<ServiceWorkerProviderHost> PreCreateNavigationHost( | 70 static std::unique_ptr<ServiceWorkerProviderHost> PreCreateNavigationHost( |
| 70 base::WeakPtr<ServiceWorkerContextCore> context, | 71 base::WeakPtr<ServiceWorkerContextCore> context, |
| 71 bool are_ancestors_secure, | 72 bool are_ancestors_secure, |
| 72 const WebContentsGetter& web_contents_getter); | 73 const WebContentsGetter& web_contents_getter); |
| 73 | 74 |
| 75 // Used to create a ServiceWorkerProviderHost when the renderer-side provider | |
| 76 // is created. This ProviderHost will be created for the process specified by | |
| 77 // |process_id|. | |
| 78 static std::unique_ptr<ServiceWorkerProviderHost> Create( | |
| 79 int process_id, | |
| 80 ServiceWorkerProviderHostInfo info, | |
| 81 base::WeakPtr<ServiceWorkerContextCore> context, | |
| 82 ServiceWorkerDispatcherHost* dispatcher_host); | |
| 83 | |
| 84 static std::unique_ptr<ServiceWorkerProviderHost> CreateForTesting( | |
|
horo
2017/01/26 02:40:23
How about adding "bool is_parent_frame_secure" arg
falken
2017/01/26 05:15:43
Can this be moved to a file like service_worker/te
shimazu
2017/01/26 09:27:23
Acknowledged.
shimazu
2017/02/07 08:47:02
Done.
| |
| 85 int process_id, | |
| 86 int provider_id, | |
| 87 ServiceWorkerProviderType type, | |
| 88 base::WeakPtr<ServiceWorkerContextCore> context, | |
| 89 int route_id = MSG_ROUTING_NONE, | |
| 90 ServiceWorkerDispatcherHost* dispatcher_host = nullptr); | |
|
falken
2017/01/26 05:15:43
The style guide discourages default arguments. Cou
shimazu
2017/01/26 09:27:23
Acknowledged.
shimazu
2017/02/07 08:47:02
I've tried to add CreateForXXX to test_utils and u
| |
| 91 | |
| 74 enum class FrameSecurityLevel { UNINITIALIZED, INSECURE, SECURE }; | 92 enum class FrameSecurityLevel { UNINITIALIZED, INSECURE, SECURE }; |
| 75 | 93 |
| 76 // When this provider host is for a Service Worker context, |route_id| is | |
| 77 // MSG_ROUTING_NONE. When this provider host is for a Document, | |
| 78 // |route_id| is the frame ID of the Document. When this provider host is for | |
| 79 // a Shared Worker, |route_id| is the Shared Worker route ID. | |
| 80 // |provider_type| gives additional information whether the provider is | |
| 81 // created for controller (ServiceWorker) or controllee (Document or | |
| 82 // SharedWorker). | |
| 83 ServiceWorkerProviderHost(int render_process_id, | |
| 84 int route_id, | |
| 85 int provider_id, | |
| 86 ServiceWorkerProviderType provider_type, | |
| 87 FrameSecurityLevel parent_frame_security_level, | |
| 88 base::WeakPtr<ServiceWorkerContextCore> context, | |
| 89 ServiceWorkerDispatcherHost* dispatcher_host); | |
| 90 virtual ~ServiceWorkerProviderHost(); | 94 virtual ~ServiceWorkerProviderHost(); |
| 91 | 95 |
| 92 const std::string& client_uuid() const { return client_uuid_; } | 96 const std::string& client_uuid() const { return client_uuid_; } |
| 93 int process_id() const { return render_process_id_; } | 97 int process_id() const { return render_process_id_; } |
| 94 int provider_id() const { return provider_id_; } | 98 int provider_id() const { return provider_id_; } |
| 95 int frame_id() const; | 99 int frame_id() const; |
| 96 int route_id() const { return route_id_; } | 100 int route_id() const { return route_id_; } |
| 97 const WebContentsGetter& web_contents_getter() const { | 101 const WebContentsGetter& web_contents_getter() const { |
| 98 return web_contents_getter_; | 102 return web_contents_getter_; |
| 99 } | 103 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 | 244 |
| 241 // |registration| claims the document to be controlled. | 245 // |registration| claims the document to be controlled. |
| 242 void ClaimedByRegistration(ServiceWorkerRegistration* registration); | 246 void ClaimedByRegistration(ServiceWorkerRegistration* registration); |
| 243 | 247 |
| 244 // Called by dispatcher host to get the registration for the "ready" property. | 248 // Called by dispatcher host to get the registration for the "ready" property. |
| 245 // Returns false if there's a completed or ongoing request for the document. | 249 // Returns false if there's a completed or ongoing request for the document. |
| 246 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#navigator- service-worker-ready | 250 // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#navigator- service-worker-ready |
| 247 bool GetRegistrationForReady(const GetRegistrationForReadyCallback& callback); | 251 bool GetRegistrationForReady(const GetRegistrationForReadyCallback& callback); |
| 248 | 252 |
| 249 // Methods to support cross site navigations. | 253 // Methods to support cross site navigations. |
| 250 void PrepareForCrossSiteTransfer(); | 254 std::unique_ptr<ServiceWorkerProviderHost> PrepareForCrossSiteTransfer(); |
| 251 void CompleteCrossSiteTransfer( | 255 void CompleteCrossSiteTransfer( |
| 252 int new_process_id, | 256 int new_process_id, |
| 253 int new_frame_id, | 257 int new_frame_id, |
| 254 int new_provider_id, | 258 int new_provider_id, |
| 255 ServiceWorkerProviderType new_provider_type, | 259 ServiceWorkerProviderType new_provider_type, |
| 256 ServiceWorkerDispatcherHost* dispatcher_host); | 260 ServiceWorkerDispatcherHost* dispatcher_host); |
| 257 ServiceWorkerDispatcherHost* dispatcher_host() const { | 261 ServiceWorkerDispatcherHost* dispatcher_host() const { |
| 258 return dispatcher_host_; | 262 return dispatcher_host_; |
| 259 } | 263 } |
| 260 | 264 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 | 321 |
| 318 struct OneShotGetReadyCallback { | 322 struct OneShotGetReadyCallback { |
| 319 GetRegistrationForReadyCallback callback; | 323 GetRegistrationForReadyCallback callback; |
| 320 bool called; | 324 bool called; |
| 321 | 325 |
| 322 explicit OneShotGetReadyCallback( | 326 explicit OneShotGetReadyCallback( |
| 323 const GetRegistrationForReadyCallback& callback); | 327 const GetRegistrationForReadyCallback& callback); |
| 324 ~OneShotGetReadyCallback(); | 328 ~OneShotGetReadyCallback(); |
| 325 }; | 329 }; |
| 326 | 330 |
| 331 ServiceWorkerProviderHost(int render_process_id, | |
| 332 int route_id, | |
| 333 int provider_id, | |
| 334 ServiceWorkerProviderType provider_type, | |
| 335 FrameSecurityLevel parent_frame_security_level, | |
| 336 base::WeakPtr<ServiceWorkerContextCore> context, | |
| 337 ServiceWorkerDispatcherHost* dispatcher_host); | |
| 338 | |
| 327 // ServiceWorkerRegistration::Listener overrides. | 339 // ServiceWorkerRegistration::Listener overrides. |
| 328 void OnVersionAttributesChanged( | 340 void OnVersionAttributesChanged( |
| 329 ServiceWorkerRegistration* registration, | 341 ServiceWorkerRegistration* registration, |
| 330 ChangedVersionAttributesMask changed_mask, | 342 ChangedVersionAttributesMask changed_mask, |
| 331 const ServiceWorkerRegistrationInfo& info) override; | 343 const ServiceWorkerRegistrationInfo& info) override; |
| 332 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; | 344 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; |
| 333 void OnRegistrationFinishedUninstalling( | 345 void OnRegistrationFinishedUninstalling( |
| 334 ServiceWorkerRegistration* registration) override; | 346 ServiceWorkerRegistration* registration) override; |
| 335 void OnSkippedWaiting(ServiceWorkerRegistration* registration) override; | 347 void OnSkippedWaiting(ServiceWorkerRegistration* registration) override; |
| 336 | 348 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 bool allow_association_; | 418 bool allow_association_; |
| 407 | 419 |
| 408 std::vector<base::Closure> queued_events_; | 420 std::vector<base::Closure> queued_events_; |
| 409 | 421 |
| 410 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 422 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
| 411 }; | 423 }; |
| 412 | 424 |
| 413 } // namespace content | 425 } // namespace content |
| 414 | 426 |
| 415 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 427 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| OLD | NEW |