| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/service_worker/link_header_support.h" | 5 #include "content/browser/service_worker/link_header_support.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" | 
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" | 
| 10 #include "components/link_header_util/link_header_util.h" | 10 #include "components/link_header_util/link_header_util.h" | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 45       !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch")) { | 45       !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch")) { | 
| 46     // TODO(mek): Log attempt to use without having correct token? | 46     // TODO(mek): Log attempt to use without having correct token? | 
| 47     return; | 47     return; | 
| 48   } | 48   } | 
| 49 | 49 | 
| 50   if (ContainsKey(params, "anchor")) | 50   if (ContainsKey(params, "anchor")) | 
| 51     return; | 51     return; | 
| 52 | 52 | 
| 53   const ResourceRequestInfoImpl* request_info = | 53   const ResourceRequestInfoImpl* request_info = | 
| 54       ResourceRequestInfoImpl::ForRequest(request); | 54       ResourceRequestInfoImpl::ForRequest(request); | 
| 55   ResourceMessageFilter* filter = request_info->filter(); |  | 
| 56   ServiceWorkerContext* service_worker_context = | 55   ServiceWorkerContext* service_worker_context = | 
| 57       filter ? filter->service_worker_context() | 56       service_worker_context_for_testing | 
| 58              : service_worker_context_for_testing; | 57           ? service_worker_context_for_testing | 
| 59   if (IsBrowserSideNavigationEnabled() && | 58           : request_info->requester_info().service_worker_context(); | 
| 60       ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType()) && |  | 
| 61       !service_worker_context) { |  | 
| 62     service_worker_context = request_info->service_worker_context(); |  | 
| 63   } |  | 
| 64 | 59 | 
| 65   if (!service_worker_context) | 60   if (!service_worker_context) | 
| 66     return; | 61     return; | 
| 67 | 62 | 
| 68   ServiceWorkerProviderHost* provider_host = | 63   ServiceWorkerProviderHost* provider_host = | 
| 69       ServiceWorkerRequestHandler::GetProviderHost(request); | 64       ServiceWorkerRequestHandler::GetProviderHost(request); | 
| 70 | 65 | 
| 71   // If fetched from a service worker, make sure fetching service worker is | 66   // If fetched from a service worker, make sure fetching service worker is | 
| 72   // controlling at least one client to prevent a service worker from spawning | 67   // controlling at least one client to prevent a service worker from spawning | 
| 73   // new service workers in the background. | 68   // new service workers in the background. | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 172     const net::URLRequest* request, | 167     const net::URLRequest* request, | 
| 173     const std::string& link_header, | 168     const std::string& link_header, | 
| 174     ServiceWorkerContextWrapper* service_worker_context_for_testing) { | 169     ServiceWorkerContextWrapper* service_worker_context_for_testing) { | 
| 175   for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { | 170   for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { | 
| 176     ProcessLinkHeaderValueForRequest(request, value.first, value.second, | 171     ProcessLinkHeaderValueForRequest(request, value.first, value.second, | 
| 177                                      service_worker_context_for_testing); | 172                                      service_worker_context_for_testing); | 
| 178   } | 173   } | 
| 179 } | 174 } | 
| 180 | 175 | 
| 181 }  // namespace content | 176 }  // namespace content | 
| OLD | NEW | 
|---|