| 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 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 blink::WebURLRequest::ServiceWorkerMode::kNone) { | 100 blink::WebURLRequest::ServiceWorkerMode::kNone) { |
| 101 request.SetServiceWorkerMode( | 101 request.SetServiceWorkerMode( |
| 102 blink::WebURLRequest::ServiceWorkerMode::kForeign); | 102 blink::WebURLRequest::ServiceWorkerMode::kForeign); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool IsControlledByServiceWorker() override { | 106 bool IsControlledByServiceWorker() override { |
| 107 return provider_->IsControlledByServiceWorker(); | 107 return provider_->IsControlledByServiceWorker(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 int GetProviderID() const override { return provider_->provider_id(); } |
| 111 |
| 110 int64_t ServiceWorkerID() override { | 112 int64_t ServiceWorkerID() override { |
| 111 if (provider_->context()->controller()) | 113 if (provider_->context()->controller()) |
| 112 return provider_->context()->controller()->version_id(); | 114 return provider_->context()->controller()->version_id(); |
| 113 return kInvalidServiceWorkerVersionId; | 115 return kInvalidServiceWorkerVersionId; |
| 114 } | 116 } |
| 115 | 117 |
| 116 private: | 118 private: |
| 117 std::unique_ptr<ServiceWorkerNetworkProvider> provider_; | 119 std::unique_ptr<ServiceWorkerNetworkProvider> provider_; |
| 118 const bool is_secure_context_; | 120 const bool is_secure_context_; |
| 119 }; | 121 }; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // (crbug.com/723553) | 280 // (crbug.com/723553) |
| 279 // https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-2.1.2 | 281 // https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-2.1.2 |
| 280 worker_fetch_context->set_first_party_for_cookies(url_); | 282 worker_fetch_context->set_first_party_for_cookies(url_); |
| 281 // TODO(horo): Currently we treat the worker context as secure if the origin | 283 // TODO(horo): Currently we treat the worker context as secure if the origin |
| 282 // of the shared worker script url is secure. But according to the spec, if | 284 // of the shared worker script url is secure. But according to the spec, if |
| 283 // the creation context is not secure, we should treat the worker as | 285 // the creation context is not secure, we should treat the worker as |
| 284 // non-secure. crbug.com/723575 | 286 // non-secure. crbug.com/723575 |
| 285 // https://w3c.github.io/webappsec-secure-contexts/#examples-shared-workers | 287 // https://w3c.github.io/webappsec-secure-contexts/#examples-shared-workers |
| 286 worker_fetch_context->set_is_secure_context(IsOriginSecure(url_)); | 288 worker_fetch_context->set_is_secure_context(IsOriginSecure(url_)); |
| 287 if (web_network_provider) { | 289 if (web_network_provider) { |
| 288 ServiceWorkerNetworkProvider* network_provider = | |
| 289 ServiceWorkerNetworkProvider::FromWebServiceWorkerNetworkProvider( | |
| 290 web_network_provider); | |
| 291 worker_fetch_context->set_service_worker_provider_id( | 290 worker_fetch_context->set_service_worker_provider_id( |
| 292 network_provider->provider_id()); | 291 web_network_provider->GetProviderID()); |
| 293 worker_fetch_context->set_is_controlled_by_service_worker( | 292 worker_fetch_context->set_is_controlled_by_service_worker( |
| 294 network_provider->IsControlledByServiceWorker()); | 293 web_network_provider->IsControlledByServiceWorker()); |
| 295 } | 294 } |
| 296 return std::move(worker_fetch_context); | 295 return std::move(worker_fetch_context); |
| 297 } | 296 } |
| 298 | 297 |
| 299 void EmbeddedSharedWorkerStub::Shutdown() { | 298 void EmbeddedSharedWorkerStub::Shutdown() { |
| 300 // WebSharedWorker must be already deleted in the blink side | 299 // WebSharedWorker must be already deleted in the blink side |
| 301 // when this is called. | 300 // when this is called. |
| 302 impl_ = nullptr; | 301 impl_ = nullptr; |
| 303 delete this; | 302 delete this; |
| 304 } | 303 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 329 } | 328 } |
| 330 } | 329 } |
| 331 | 330 |
| 332 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 331 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
| 333 // After this we wouldn't get any IPC for this stub. | 332 // After this we wouldn't get any IPC for this stub. |
| 334 running_ = false; | 333 running_ = false; |
| 335 impl_->TerminateWorkerContext(); | 334 impl_->TerminateWorkerContext(); |
| 336 } | 335 } |
| 337 | 336 |
| 338 } // namespace content | 337 } // namespace content |
| OLD | NEW |