| 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/payments/WebPaymentAppRespo
nse.h" | 64 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo
nse.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 response_ = base::MakeUnique<blink::WebURLResponse>(); | 375 response_ = base::MakeUnique<blink::WebURLResponse>(); |
| 375 // TODO(horo): Set report_security_info to true when DevTools is attached. | 376 // TODO(horo): Set report_security_info to true when DevTools is attached. |
| 376 const bool report_security_info = false; | 377 const bool report_security_info = false; |
| 377 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), | 378 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), |
| 378 report_security_info); | 379 report_security_info); |
| 379 MaybeReportResponseToClient(); | 380 MaybeReportResponseToClient(); |
| 380 } | 381 } |
| 381 | 382 |
| 382 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 383 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
| 383 const ResourceResponseHead& response_head) override { | 384 const ResourceResponseHead& response_head) override { |
| 385 DCHECK(!response_); |
| 386 DCHECK(net::HttpResponseHeaders::IsRedirectResponseCode( |
| 387 response_head.headers->response_code())); |
| 388 |
| 389 ServiceWorkerContextClient* client = |
| 390 ServiceWorkerContextClient::ThreadSpecificInstance(); |
| 391 if (!client) |
| 392 return; |
| 393 response_ = base::MakeUnique<blink::WebURLResponse>(); |
| 394 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), |
| 395 false /* report_security_info */); |
| 396 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_), |
| 397 nullptr); |
| 384 // This will delete |this|. | 398 // This will delete |this|. |
| 385 ReportErrorToClient( | 399 client->OnNavigationPreloadComplete(fetch_event_id_); |
| 386 "Service Worker navigation preload doesn't support redirects."); | |
| 387 } | 400 } |
| 388 | 401 |
| 389 void OnDataDownloaded(int64_t data_length, | 402 void OnDataDownloaded(int64_t data_length, |
| 390 int64_t encoded_data_length) override { | 403 int64_t encoded_data_length) override { |
| 391 NOTREACHED(); | 404 NOTREACHED(); |
| 392 } | 405 } |
| 393 | 406 |
| 394 void OnUploadProgress(int64_t current_position, | 407 void OnUploadProgress(int64_t current_position, |
| 395 int64_t total_size, | 408 int64_t total_size, |
| 396 const base::Closure& ack_callback) override { | 409 const base::Closure& ack_callback) override { |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 } | 1522 } |
| 1510 | 1523 |
| 1511 base::WeakPtr<ServiceWorkerContextClient> | 1524 base::WeakPtr<ServiceWorkerContextClient> |
| 1512 ServiceWorkerContextClient::GetWeakPtr() { | 1525 ServiceWorkerContextClient::GetWeakPtr() { |
| 1513 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1526 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1514 DCHECK(context_); | 1527 DCHECK(context_); |
| 1515 return context_->weak_factory.GetWeakPtr(); | 1528 return context_->weak_factory.GetWeakPtr(); |
| 1516 } | 1529 } |
| 1517 | 1530 |
| 1518 } // namespace content | 1531 } // namespace content |
| OLD | NEW |