| OLD | NEW |
| 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_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ |
| 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/common/service_worker/service_worker_types.h" | 17 #include "content/common/service_worker/service_worker_types.h" |
| 18 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 18 |
| 19 namespace blink { |
| 20 class WebDataSource; |
| 21 class WebLocalFrame; |
| 22 } // namespace blink |
| 19 | 23 |
| 20 namespace content { | 24 namespace content { |
| 21 | 25 |
| 22 class ServiceWorkerProviderContext; | 26 class ServiceWorkerProviderContext; |
| 23 struct RequestNavigationParams; | 27 struct RequestNavigationParams; |
| 24 | 28 |
| 25 // A unique provider_id is generated for each instance. | 29 // A unique provider_id is generated for each instance. |
| 26 // Instantiated prior to the main resource load being started and remains | 30 // Instantiated prior to the main resource load being started and remains |
| 27 // allocated until after the last subresource load has occurred. | 31 // allocated until after the last subresource load has occurred. |
| 28 // This is used to track the lifetime of a Document to create | 32 // This is used to track the lifetime of a Document to create |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 static void AttachToDocumentState( | 43 static void AttachToDocumentState( |
| 40 base::SupportsUserData* document_state, | 44 base::SupportsUserData* document_state, |
| 41 std::unique_ptr<ServiceWorkerNetworkProvider> network_provider); | 45 std::unique_ptr<ServiceWorkerNetworkProvider> network_provider); |
| 42 | 46 |
| 43 static ServiceWorkerNetworkProvider* FromDocumentState( | 47 static ServiceWorkerNetworkProvider* FromDocumentState( |
| 44 base::SupportsUserData* document_state); | 48 base::SupportsUserData* document_state); |
| 45 | 49 |
| 46 static std::unique_ptr<ServiceWorkerNetworkProvider> CreateForNavigation( | 50 static std::unique_ptr<ServiceWorkerNetworkProvider> CreateForNavigation( |
| 47 int route_id, | 51 int route_id, |
| 48 const RequestNavigationParams& request_params, | 52 const RequestNavigationParams& request_params, |
| 49 blink::WebSandboxFlags sandbox_flags, | 53 blink::WebLocalFrame* frame, |
| 50 bool content_initiated); | 54 bool content_initiated); |
| 51 | 55 |
| 52 // PlzNavigate | 56 // PlzNavigate |
| 53 // The |browser_provider_id| is initialized by the browser for navigations. | 57 // The |browser_provider_id| is initialized by the browser for navigations. |
| 54 ServiceWorkerNetworkProvider(int route_id, | 58 ServiceWorkerNetworkProvider(int route_id, |
| 55 ServiceWorkerProviderType type, | 59 ServiceWorkerProviderType type, |
| 56 int browser_provider_id); | 60 int browser_provider_id, |
| 57 ServiceWorkerNetworkProvider(int route_id, ServiceWorkerProviderType type); | 61 bool is_parent_frame_secure); |
| 62 ServiceWorkerNetworkProvider(int route_id, |
| 63 ServiceWorkerProviderType type, |
| 64 bool is_parent_frame_secure); |
| 58 ServiceWorkerNetworkProvider(); | 65 ServiceWorkerNetworkProvider(); |
| 59 ~ServiceWorkerNetworkProvider() override; | 66 ~ServiceWorkerNetworkProvider() override; |
| 60 | 67 |
| 61 int provider_id() const { return provider_id_; } | 68 int provider_id() const { return provider_id_; } |
| 62 ServiceWorkerProviderContext* context() const { return context_.get(); } | 69 ServiceWorkerProviderContext* context() const { return context_.get(); } |
| 63 | 70 |
| 64 // This method is called for a provider that's associated with a | 71 // This method is called for a provider that's associated with a |
| 65 // running service worker script. The version_id indicates which | 72 // running service worker script. The version_id indicates which |
| 66 // ServiceWorkerVersion should be used. | 73 // ServiceWorkerVersion should be used. |
| 67 void SetServiceWorkerVersionId(int64_t version_id); | 74 void SetServiceWorkerVersionId(int64_t version_id); |
| 68 | 75 |
| 69 bool IsControlledByServiceWorker() const; | 76 bool IsControlledByServiceWorker() const; |
| 70 | 77 |
| 71 private: | 78 private: |
| 72 const int provider_id_; | 79 const int provider_id_; |
| 73 scoped_refptr<ServiceWorkerProviderContext> context_; | 80 scoped_refptr<ServiceWorkerProviderContext> context_; |
| 74 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider); | 81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerNetworkProvider); |
| 75 }; | 82 }; |
| 76 | 83 |
| 77 } // namespace content | 84 } // namespace content |
| 78 | 85 |
| 79 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ | 86 #endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_NETWORK_PROVIDER_H_ |
| OLD | NEW |