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

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

Issue 615493003: [ServiceWorker] Plumbing the request credentials mode to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } // namespace 54 } // namespace
55 55
56 void ServiceWorkerRequestHandler::InitializeHandler( 56 void ServiceWorkerRequestHandler::InitializeHandler(
57 net::URLRequest* request, 57 net::URLRequest* request,
58 ServiceWorkerContextWrapper* context_wrapper, 58 ServiceWorkerContextWrapper* context_wrapper,
59 storage::BlobStorageContext* blob_storage_context, 59 storage::BlobStorageContext* blob_storage_context,
60 int process_id, 60 int process_id,
61 int provider_id, 61 int provider_id,
62 bool skip_service_worker, 62 bool skip_service_worker,
63 FetchRequestMode request_mode, 63 FetchRequestMode request_mode,
64 FetchCredentialsMode credentials_mode,
64 ResourceType resource_type, 65 ResourceType resource_type,
65 scoped_refptr<ResourceRequestBody> body) { 66 scoped_refptr<ResourceRequestBody> body) {
66 if (!request->url().SchemeIsHTTPOrHTTPS() || 67 if (!request->url().SchemeIsHTTPOrHTTPS() ||
67 !IsMethodSupportedForServiceWroker(request->method())) { 68 !IsMethodSupportedForServiceWroker(request->method())) {
68 return; 69 return;
69 } 70 }
70 71
71 if (!context_wrapper || !context_wrapper->context() || 72 if (!context_wrapper || !context_wrapper->context() ||
72 provider_id == kInvalidServiceWorkerProviderId) { 73 provider_id == kInvalidServiceWorkerProviderId) {
73 return; 74 return;
74 } 75 }
75 76
76 ServiceWorkerProviderHost* provider_host = 77 ServiceWorkerProviderHost* provider_host =
77 context_wrapper->context()->GetProviderHost(process_id, provider_id); 78 context_wrapper->context()->GetProviderHost(process_id, provider_id);
78 if (!provider_host || !provider_host->IsContextAlive()) 79 if (!provider_host || !provider_host->IsContextAlive())
79 return; 80 return;
80 81
81 if (skip_service_worker) { 82 if (skip_service_worker) {
82 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) 83 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
83 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); 84 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
84 return; 85 return;
85 } 86 }
86 87
87 scoped_ptr<ServiceWorkerRequestHandler> handler( 88 scoped_ptr<ServiceWorkerRequestHandler> handler(
88 provider_host->CreateRequestHandler(request_mode, 89 provider_host->CreateRequestHandler(request_mode,
90 credentials_mode,
89 resource_type, 91 resource_type,
90 blob_storage_context->AsWeakPtr(), 92 blob_storage_context->AsWeakPtr(),
91 body)); 93 body));
92 if (!handler) 94 if (!handler)
93 return; 95 return;
94 96
95 request->SetUserData(&kUserDataKey, handler.release()); 97 request->SetUserData(&kUserDataKey, handler.release());
96 } 98 }
97 99
98 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( 100 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
(...skipping 16 matching lines...) Expand all
115 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 117 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
116 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 118 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
117 ResourceType resource_type) 119 ResourceType resource_type)
118 : context_(context), 120 : context_(context),
119 provider_host_(provider_host), 121 provider_host_(provider_host),
120 blob_storage_context_(blob_storage_context), 122 blob_storage_context_(blob_storage_context),
121 resource_type_(resource_type) { 123 resource_type_(resource_type) {
122 } 124 }
123 125
124 } // namespace content 126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698