OLD | NEW |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 FetchCredentialsMode credentials_mode, |
65 ResourceType resource_type, | 65 ResourceType resource_type, |
| 66 RequestContextType request_context_type, |
| 67 RequestContextFrameType frame_type, |
66 scoped_refptr<ResourceRequestBody> body) { | 68 scoped_refptr<ResourceRequestBody> body) { |
67 if (!request->url().SchemeIsHTTPOrHTTPS() || | 69 if (!request->url().SchemeIsHTTPOrHTTPS() || |
68 !IsMethodSupportedForServiceWroker(request->method())) { | 70 !IsMethodSupportedForServiceWroker(request->method())) { |
69 return; | 71 return; |
70 } | 72 } |
71 | 73 |
72 if (!context_wrapper || !context_wrapper->context() || | 74 if (!context_wrapper || !context_wrapper->context() || |
73 provider_id == kInvalidServiceWorkerProviderId) { | 75 provider_id == kInvalidServiceWorkerProviderId) { |
74 return; | 76 return; |
75 } | 77 } |
76 | 78 |
77 ServiceWorkerProviderHost* provider_host = | 79 ServiceWorkerProviderHost* provider_host = |
78 context_wrapper->context()->GetProviderHost(process_id, provider_id); | 80 context_wrapper->context()->GetProviderHost(process_id, provider_id); |
79 if (!provider_host || !provider_host->IsContextAlive()) | 81 if (!provider_host || !provider_host->IsContextAlive()) |
80 return; | 82 return; |
81 | 83 |
82 if (skip_service_worker) { | 84 if (skip_service_worker) { |
83 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) | 85 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) |
84 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); | 86 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); |
85 return; | 87 return; |
86 } | 88 } |
87 | 89 |
88 scoped_ptr<ServiceWorkerRequestHandler> handler( | 90 scoped_ptr<ServiceWorkerRequestHandler> handler( |
89 provider_host->CreateRequestHandler(request_mode, | 91 provider_host->CreateRequestHandler(request_mode, |
90 credentials_mode, | 92 credentials_mode, |
91 resource_type, | 93 resource_type, |
| 94 request_context_type, |
| 95 frame_type, |
92 blob_storage_context->AsWeakPtr(), | 96 blob_storage_context->AsWeakPtr(), |
93 body)); | 97 body)); |
94 if (!handler) | 98 if (!handler) |
95 return; | 99 return; |
96 | 100 |
97 request->SetUserData(&kUserDataKey, handler.release()); | 101 request->SetUserData(&kUserDataKey, handler.release()); |
98 } | 102 } |
99 | 103 |
100 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( | 104 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( |
101 net::URLRequest* request) { | 105 net::URLRequest* request) { |
(...skipping 15 matching lines...) Expand all Loading... |
117 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 121 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
118 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 122 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
119 ResourceType resource_type) | 123 ResourceType resource_type) |
120 : context_(context), | 124 : context_(context), |
121 provider_host_(provider_host), | 125 provider_host_(provider_host), |
122 blob_storage_context_(blob_storage_context), | 126 blob_storage_context_(blob_storage_context), |
123 resource_type_(resource_type) { | 127 resource_type_(resource_type) { |
124 } | 128 } |
125 | 129 |
126 } // namespace content | 130 } // namespace content |
OLD | NEW |