| 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/notifications/WebNotificati
onData.h" | 61 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onData.h" |
| 61 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque
st.h" | 62 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque
st.h" |
| 62 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerClientQueryOptions.h" | 63 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerClientQueryOptions.h" |
| 63 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerError.h" | 64 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerError.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 response_ = base::MakeUnique<blink::WebURLResponse>(); | 287 response_ = base::MakeUnique<blink::WebURLResponse>(); |
| 287 // TODO(horo): Set report_security_info to true when DevTools is attached. | 288 // TODO(horo): Set report_security_info to true when DevTools is attached. |
| 288 const bool report_security_info = false; | 289 const bool report_security_info = false; |
| 289 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), | 290 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), |
| 290 report_security_info); | 291 report_security_info); |
| 291 MaybeReportResponseToClient(); | 292 MaybeReportResponseToClient(); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | 295 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
| 295 const ResourceResponseHead& response_head) override { | 296 const ResourceResponseHead& response_head) override { |
| 297 DCHECK(!response_); |
| 298 DCHECK(net::HttpResponseHeaders::IsRedirectResponseCode( |
| 299 response_head.headers->response_code())); |
| 300 |
| 301 ServiceWorkerContextClient* client = |
| 302 ServiceWorkerContextClient::ThreadSpecificInstance(); |
| 303 if (!client) |
| 304 return; |
| 305 response_ = base::MakeUnique<blink::WebURLResponse>(); |
| 306 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), |
| 307 false /* report_security_info */); |
| 308 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_), |
| 309 nullptr); |
| 296 // This will delete |this|. | 310 // This will delete |this|. |
| 297 ReportErrorToClient( | 311 client->OnNavigationPreloadComplete(fetch_event_id_); |
| 298 "Service Worker navigation preload doesn't support redirects."); | |
| 299 } | 312 } |
| 300 | 313 |
| 301 void OnDataDownloaded(int64_t data_length, | 314 void OnDataDownloaded(int64_t data_length, |
| 302 int64_t encoded_data_length) override { | 315 int64_t encoded_data_length) override { |
| 303 NOTREACHED(); | 316 NOTREACHED(); |
| 304 } | 317 } |
| 305 | 318 |
| 306 void OnUploadProgress(int64_t current_position, | 319 void OnUploadProgress(int64_t current_position, |
| 307 int64_t total_size, | 320 int64_t total_size, |
| 308 const base::Closure& ack_callback) override { | 321 const base::Closure& ack_callback) override { |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 } | 1324 } |
| 1312 | 1325 |
| 1313 base::WeakPtr<ServiceWorkerContextClient> | 1326 base::WeakPtr<ServiceWorkerContextClient> |
| 1314 ServiceWorkerContextClient::GetWeakPtr() { | 1327 ServiceWorkerContextClient::GetWeakPtr() { |
| 1315 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1328 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1316 DCHECK(context_); | 1329 DCHECK(context_); |
| 1317 return context_->weak_factory.GetWeakPtr(); | 1330 return context_->weak_factory.GetWeakPtr(); |
| 1318 } | 1331 } |
| 1319 | 1332 |
| 1320 } // namespace content | 1333 } // namespace content |
| OLD | NEW |