Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: content/browser/service_worker/link_header_support.cc

Issue 2116503004: Make Foreign Fetch an origin trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "content/browser/loader/resource_message_filter.h" 11 #include "content/browser/loader/resource_message_filter.h"
12 #include "content/browser/loader/resource_request_info_impl.h" 12 #include "content/browser/loader/resource_request_info_impl.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" 13 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "content/browser/service_worker/service_worker_request_handler.h" 14 #include "content/browser/service_worker/service_worker_request_handler.h"
15 #include "content/common/origin_trials/trial_token_validator.h"
15 #include "content/common/service_worker/service_worker_utils.h" 16 #include "content/common/service_worker/service_worker_utils.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/common/content_client.h" 19 #include "content/public/common/content_client.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/public/common/origin_util.h" 21 #include "content/public/common/origin_util.h"
21 #include "net/http/http_util.h" 22 #include "net/http/http_util.h"
22 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace { 27 namespace {
27 28
28 void RegisterServiceWorkerFinished(int64_t trace_id, bool result) { 29 void RegisterServiceWorkerFinished(int64_t trace_id, bool result) {
29 TRACE_EVENT_ASYNC_END1("ServiceWorker", 30 TRACE_EVENT_ASYNC_END1("ServiceWorker",
30 "LinkHeaderResourceThrottle::HandleServiceWorkerLink", 31 "LinkHeaderResourceThrottle::HandleServiceWorkerLink",
31 trace_id, "Success", result); 32 trace_id, "Success", result);
32 } 33 }
33 34
34 void HandleServiceWorkerLink( 35 void HandleServiceWorkerLink(
35 const net::URLRequest* request, 36 const net::URLRequest* request,
36 const std::string& url, 37 const std::string& url,
37 const std::unordered_map<std::string, base::Optional<std::string>>& params, 38 const std::unordered_map<std::string, base::Optional<std::string>>& params,
38 ServiceWorkerContextWrapper* service_worker_context_for_testing) { 39 ServiceWorkerContextWrapper* service_worker_context_for_testing) {
39 DCHECK_CURRENTLY_ON(BrowserThread::IO); 40 DCHECK_CURRENTLY_ON(BrowserThread::IO);
40 41
41 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 42 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
42 switches::kEnableExperimentalWebPlatformFeatures)) { 43 switches::kEnableExperimentalWebPlatformFeatures) &&
43 // TODO(mek): Integrate with experimental framework. 44 !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch")) {
45 // TODO(mek): Log attempt to use without having correct token?
44 return; 46 return;
45 } 47 }
46 48
47 if (ContainsKey(params, "anchor")) 49 if (ContainsKey(params, "anchor"))
48 return; 50 return;
49 51
50 const ResourceRequestInfoImpl* request_info = 52 const ResourceRequestInfoImpl* request_info =
51 ResourceRequestInfoImpl::ForRequest(request); 53 ResourceRequestInfoImpl::ForRequest(request);
52 ResourceMessageFilter* filter = request_info->filter(); 54 ResourceMessageFilter* filter = request_info->filter();
53 ServiceWorkerContext* service_worker_context = 55 ServiceWorkerContext* service_worker_context =
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const net::URLRequest* request, 155 const net::URLRequest* request,
154 const std::string& link_header, 156 const std::string& link_header,
155 ServiceWorkerContextWrapper* service_worker_context_for_testing) { 157 ServiceWorkerContextWrapper* service_worker_context_for_testing) {
156 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { 158 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) {
157 ProcessLinkHeaderValueForRequest(request, value.first, value.second, 159 ProcessLinkHeaderValueForRequest(request, value.first, value.second,
158 service_worker_context_for_testing); 160 service_worker_context_for_testing);
159 } 161 }
160 } 162 }
161 163
162 } // namespace content 164 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/foreign_fetch_request_handler.cc ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698