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

Side by Side Diff: content/browser/service_worker/foreign_fetch_request_handler.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 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/browser/service_worker/foreign_fetch_request_handler.h" 5 #include "content/browser/service_worker/foreign_fetch_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 11 #include "content/browser/service_worker/service_worker_context_wrapper.h"
11 #include "content/browser/service_worker/service_worker_response_info.h" 12 #include "content/browser/service_worker/service_worker_response_info.h"
12 #include "content/browser/service_worker/service_worker_url_request_job.h" 13 #include "content/browser/service_worker/service_worker_url_request_job.h"
13 #include "content/common/resource_request_body_impl.h" 14 #include "content/common/resource_request_body_impl.h"
14 #include "content/common/service_worker/service_worker_utils.h" 15 #include "content/common/service_worker/service_worker_utils.h"
16 #include "content/public/common/content_client.h"
17 #include "content/public/common/content_switches.h"
18 #include "content/public/common/origin_trial_policy.h"
15 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
16 #include "net/url_request/url_request_interceptor.h" 20 #include "net/url_request/url_request_interceptor.h"
17 #include "storage/browser/blob/blob_storage_context.h" 21 #include "storage/browser/blob/blob_storage_context.h"
18 22
19 namespace content { 23 namespace content {
20 24
21 namespace { 25 namespace {
22 26
23 int kUserDataKey; // Only address is used. 27 int kUserDataKey; // Only address is used.
24 28
(...skipping 13 matching lines...) Expand all
38 resource_context_); 42 resource_context_);
39 } 43 }
40 44
41 private: 45 private:
42 ResourceContext* resource_context_; 46 ResourceContext* resource_context_;
43 DISALLOW_COPY_AND_ASSIGN(ForeignFetchRequestInterceptor); 47 DISALLOW_COPY_AND_ASSIGN(ForeignFetchRequestInterceptor);
44 }; 48 };
45 49
46 } // namespace 50 } // namespace
47 51
52 bool ForeignFetchRequestHandler::IsForeignFetchEnabled() {
53 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
54 switches::kEnableExperimentalWebPlatformFeatures)) {
55 return true;
56 }
57 OriginTrialPolicy* origin_trial_policy =
58 GetContentClient()->GetOriginTrialPolicy();
59 return origin_trial_policy &&
60 !origin_trial_policy->IsFeatureDisabled("ForeignFetch");
61 }
62
48 void ForeignFetchRequestHandler::InitializeHandler( 63 void ForeignFetchRequestHandler::InitializeHandler(
49 net::URLRequest* request, 64 net::URLRequest* request,
50 ServiceWorkerContextWrapper* context_wrapper, 65 ServiceWorkerContextWrapper* context_wrapper,
51 storage::BlobStorageContext* blob_storage_context, 66 storage::BlobStorageContext* blob_storage_context,
52 int process_id, 67 int process_id,
53 int provider_id, 68 int provider_id,
54 SkipServiceWorker skip_service_worker, 69 SkipServiceWorker skip_service_worker,
55 FetchRequestMode request_mode, 70 FetchRequestMode request_mode,
56 FetchCredentialsMode credentials_mode, 71 FetchCredentialsMode credentials_mode,
57 FetchRedirectMode redirect_mode, 72 FetchRedirectMode redirect_mode,
58 ResourceType resource_type, 73 ResourceType resource_type,
59 RequestContextType request_context_type, 74 RequestContextType request_context_type,
60 RequestContextFrameType frame_type, 75 RequestContextFrameType frame_type,
61 scoped_refptr<ResourceRequestBodyImpl> body, 76 scoped_refptr<ResourceRequestBodyImpl> body,
62 bool initiated_in_secure_context) { 77 bool initiated_in_secure_context) {
78 if (!IsForeignFetchEnabled())
79 return;
80
63 if (!context_wrapper) 81 if (!context_wrapper)
64 return; 82 return;
65 83
66 if (skip_service_worker == SkipServiceWorker::ALL) 84 if (skip_service_worker == SkipServiceWorker::ALL)
67 return; 85 return;
68 86
69 if (!initiated_in_secure_context) 87 if (!initiated_in_secure_context)
70 return; 88 return;
71 89
72 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) 90 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 246 }
229 return target_worker_.get(); 247 return target_worker_.get();
230 } 248 }
231 249
232 void ForeignFetchRequestHandler::ClearJob() { 250 void ForeignFetchRequestHandler::ClearJob() {
233 job_.reset(); 251 job_.reset();
234 target_worker_ = nullptr; 252 target_worker_ = nullptr;
235 } 253 }
236 254
237 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/foreign_fetch_request_handler.h ('k') | content/browser/service_worker/link_header_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698