| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/service_worker/service_worker_context_client.h" | 5 #include "content/renderer/service_worker/service_worker_context_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "content/public/renderer/document_state.h" | 44 #include "content/public/renderer/document_state.h" |
| 45 #include "content/renderer/devtools/devtools_agent.h" | 45 #include "content/renderer/devtools/devtools_agent.h" |
| 46 #include "content/renderer/render_thread_impl.h" | 46 #include "content/renderer/render_thread_impl.h" |
| 47 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h" | 47 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h" |
| 48 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 48 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 49 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h
" | 49 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h
" |
| 50 #include "content/renderer/service_worker/service_worker_type_converters.h" | 50 #include "content/renderer/service_worker/service_worker_type_converters.h" |
| 51 #include "content/renderer/service_worker/service_worker_type_util.h" | 51 #include "content/renderer/service_worker/service_worker_type_util.h" |
| 52 #include "ipc/ipc_message.h" | 52 #include "ipc/ipc_message.h" |
| 53 #include "ipc/ipc_message_macros.h" | 53 #include "ipc/ipc_message_macros.h" |
| 54 #include "net/http/http_response_headers.h" |
| 54 #include "third_party/WebKit/public/platform/URLConversion.h" | 55 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 55 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 56 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 56 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 57 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 57 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 58 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 58 #include "third_party/WebKit/public/platform/WebString.h" | 59 #include "third_party/WebKit/public/platform/WebString.h" |
| 59 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 60 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 60 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro
undFetchSettledFetch.h" | 61 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro
undFetchSettledFetch.h" |
| 61 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onData.h" | 62 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onData.h" |
| 62 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque
st.h" | 63 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque
st.h" |
| 63 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerClientQueryOptions.h" | 64 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerClientQueryOptions.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 response_ = base::MakeUnique<blink::WebURLResponse>(); | 369 response_ = base::MakeUnique<blink::WebURLResponse>(); |
| 369 // TODO(horo): Set report_security_info to true when DevTools is attached. | 370 // TODO(horo): Set report_security_info to true when DevTools is attached. |
| 370 const bool report_security_info = false; | 371 const bool report_security_info = false; |
| 371 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), | 372 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), |
| 372 report_security_info); | 373 report_security_info); |
| 373 MaybeReportResponseToClient(); | 374 MaybeReportResponseToClient(); |
| 374 } | 375 } |
| 375 | 376 |
| 376 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 377 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
| 377 const ResourceResponseHead& response_head) override { | 378 const ResourceResponseHead& response_head) override { |
| 379 DCHECK(!response_); |
| 380 DCHECK(net::HttpResponseHeaders::IsRedirectResponseCode( |
| 381 response_head.headers->response_code())); |
| 382 |
| 383 ServiceWorkerContextClient* client = |
| 384 ServiceWorkerContextClient::ThreadSpecificInstance(); |
| 385 if (!client) |
| 386 return; |
| 387 response_ = base::MakeUnique<blink::WebURLResponse>(); |
| 388 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), |
| 389 false /* report_security_info */); |
| 390 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_), |
| 391 nullptr); |
| 378 // This will delete |this|. | 392 // This will delete |this|. |
| 379 ReportErrorToClient( | 393 client->OnNavigationPreloadComplete(fetch_event_id_); |
| 380 "Service Worker navigation preload doesn't support redirects."); | |
| 381 } | 394 } |
| 382 | 395 |
| 383 void OnDataDownloaded(int64_t data_length, | 396 void OnDataDownloaded(int64_t data_length, |
| 384 int64_t encoded_data_length) override { | 397 int64_t encoded_data_length) override { |
| 385 NOTREACHED(); | 398 NOTREACHED(); |
| 386 } | 399 } |
| 387 | 400 |
| 388 void OnUploadProgress(int64_t current_position, | 401 void OnUploadProgress(int64_t current_position, |
| 389 int64_t total_size, | 402 int64_t total_size, |
| 390 const base::Closure& ack_callback) override { | 403 const base::Closure& ack_callback) override { |
| (...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 } | 1496 } |
| 1484 | 1497 |
| 1485 base::WeakPtr<ServiceWorkerContextClient> | 1498 base::WeakPtr<ServiceWorkerContextClient> |
| 1486 ServiceWorkerContextClient::GetWeakPtr() { | 1499 ServiceWorkerContextClient::GetWeakPtr() { |
| 1487 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1500 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1488 DCHECK(context_); | 1501 DCHECK(context_); |
| 1489 return context_->weak_factory.GetWeakPtr(); | 1502 return context_->weak_factory.GetWeakPtr(); |
| 1490 } | 1503 } |
| 1491 | 1504 |
| 1492 } // namespace content | 1505 } // namespace content |
| OLD | NEW |