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

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

Issue 1271733002: [2/3 chromium] Support redirect option of Request and "opaqueredirect" response type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add _MODE to avoid compile error at Windows. Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker_request_handler.h" 5 #include "content/browser/service_worker/service_worker_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void ServiceWorkerRequestHandler::InitializeHandler( 54 void ServiceWorkerRequestHandler::InitializeHandler(
55 net::URLRequest* request, 55 net::URLRequest* request,
56 ServiceWorkerContextWrapper* context_wrapper, 56 ServiceWorkerContextWrapper* context_wrapper,
57 storage::BlobStorageContext* blob_storage_context, 57 storage::BlobStorageContext* blob_storage_context,
58 int process_id, 58 int process_id,
59 int provider_id, 59 int provider_id,
60 bool skip_service_worker, 60 bool skip_service_worker,
61 FetchRequestMode request_mode, 61 FetchRequestMode request_mode,
62 FetchCredentialsMode credentials_mode, 62 FetchCredentialsMode credentials_mode,
63 FetchRedirectMode redirect_mode,
63 ResourceType resource_type, 64 ResourceType resource_type,
64 RequestContextType request_context_type, 65 RequestContextType request_context_type,
65 RequestContextFrameType frame_type, 66 RequestContextFrameType frame_type,
66 scoped_refptr<ResourceRequestBody> body) { 67 scoped_refptr<ResourceRequestBody> body) {
67 if (!OriginCanAccessServiceWorkers(request->url())) 68 if (!OriginCanAccessServiceWorkers(request->url()))
68 return; 69 return;
69 70
70 if (!context_wrapper || !context_wrapper->context() || 71 if (!context_wrapper || !context_wrapper->context() ||
71 provider_id == kInvalidServiceWorkerProviderId) { 72 provider_id == kInvalidServiceWorkerProviderId) {
72 return; 73 return;
73 } 74 }
74 75
75 ServiceWorkerProviderHost* provider_host = 76 ServiceWorkerProviderHost* provider_host =
76 context_wrapper->context()->GetProviderHost(process_id, provider_id); 77 context_wrapper->context()->GetProviderHost(process_id, provider_id);
77 if (!provider_host || !provider_host->IsContextAlive()) 78 if (!provider_host || !provider_host->IsContextAlive())
78 return; 79 return;
79 80
80 if (skip_service_worker) { 81 if (skip_service_worker) {
81 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) { 82 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) {
82 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); 83 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
83 provider_host->SetTopmostFrameUrl(request->first_party_for_cookies()); 84 provider_host->SetTopmostFrameUrl(request->first_party_for_cookies());
84 // A page load with skip_service_worker should be triggered by 85 // A page load with skip_service_worker should be triggered by
85 // shift-reload, so retain all live matching registrations. 86 // shift-reload, so retain all live matching registrations.
86 provider_host->AddAllMatchingRegistrations(); 87 provider_host->AddAllMatchingRegistrations();
87 } 88 }
88 return; 89 return;
89 } 90 }
90 91
91 scoped_ptr<ServiceWorkerRequestHandler> handler( 92 scoped_ptr<ServiceWorkerRequestHandler> handler(
92 provider_host->CreateRequestHandler(request_mode, 93 provider_host->CreateRequestHandler(
93 credentials_mode, 94 request_mode, credentials_mode, redirect_mode, resource_type,
94 resource_type, 95 request_context_type, frame_type, blob_storage_context->AsWeakPtr(),
95 request_context_type, 96 body));
96 frame_type,
97 blob_storage_context->AsWeakPtr(),
98 body));
99 if (!handler) 97 if (!handler)
100 return; 98 return;
101 99
102 request->SetUserData(&kUserDataKey, handler.release()); 100 request->SetUserData(&kUserDataKey, handler.release());
103 } 101 }
104 102
105 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( 103 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
106 net::URLRequest* request) { 104 net::URLRequest* request) {
107 return static_cast<ServiceWorkerRequestHandler*>( 105 return static_cast<ServiceWorkerRequestHandler*>(
108 request->GetUserData(&kUserDataKey)); 106 request->GetUserData(&kUserDataKey));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 ResourceType resource_type) 165 ResourceType resource_type)
168 : context_(context), 166 : context_(context),
169 provider_host_(provider_host), 167 provider_host_(provider_host),
170 blob_storage_context_(blob_storage_context), 168 blob_storage_context_(blob_storage_context),
171 resource_type_(resource_type), 169 resource_type_(resource_type),
172 old_process_id_(0), 170 old_process_id_(0),
173 old_provider_id_(kInvalidServiceWorkerProviderId) { 171 old_provider_id_(kInvalidServiceWorkerProviderId) {
174 } 172 }
175 173
176 } // namespace content 174 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698