| 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" |
| 11 #include "content/browser/service_worker/service_worker_provider_host.h" | 11 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 12 #include "content/browser/service_worker/service_worker_registration.h" | 12 #include "content/browser/service_worker/service_worker_registration.h" |
| 13 #include "content/browser/service_worker/service_worker_url_request_job.h" | 13 #include "content/browser/service_worker/service_worker_url_request_job.h" |
| 14 #include "content/browser/service_worker/service_worker_utils.h" | 14 #include "content/browser/service_worker/service_worker_utils.h" |
| 15 #include "content/common/service_worker/service_worker_types.h" | 15 #include "content/common/service_worker/service_worker_types.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_interceptor.h" | 17 #include "net/url_request/url_request_interceptor.h" |
| 18 #include "webkit/browser/blob/blob_storage_context.h" | 18 #include "storage/browser/blob/blob_storage_context.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 int kUserDataKey; // Key value is not important. | 24 int kUserDataKey; // Key value is not important. |
| 25 | 25 |
| 26 class ServiceWorkerRequestInterceptor | 26 class ServiceWorkerRequestInterceptor |
| 27 : public net::URLRequestInterceptor { | 27 : public net::URLRequestInterceptor { |
| 28 public: | 28 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 49 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { | 49 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { |
| 50 return request->url().SchemeIsHTTPOrHTTPS() && | 50 return request->url().SchemeIsHTTPOrHTTPS() && |
| 51 IsMethodSupportedForAppCache(request->method()); | 51 IsMethodSupportedForAppCache(request->method()); |
| 52 } | 52 } |
| 53 | 53 |
| 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 webkit_blob::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 ResourceType resource_type) { | 62 ResourceType resource_type) { |
| 63 if (!IsSchemeAndMethodSupportedForAppCache(request)) { | 63 if (!IsSchemeAndMethodSupportedForAppCache(request)) { |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 if (!context_wrapper || !context_wrapper->context() || | 67 if (!context_wrapper || !context_wrapper->context() || |
| 68 provider_id == kInvalidServiceWorkerProviderId) { | 68 provider_id == kInvalidServiceWorkerProviderId) { |
| 69 return; | 69 return; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 94 return scoped_ptr<net::URLRequestInterceptor>( | 94 return scoped_ptr<net::URLRequestInterceptor>( |
| 95 new ServiceWorkerRequestInterceptor); | 95 new ServiceWorkerRequestInterceptor); |
| 96 } | 96 } |
| 97 | 97 |
| 98 ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() { | 98 ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() { |
| 99 } | 99 } |
| 100 | 100 |
| 101 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( | 101 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( |
| 102 base::WeakPtr<ServiceWorkerContextCore> context, | 102 base::WeakPtr<ServiceWorkerContextCore> context, |
| 103 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 103 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 104 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, | 104 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 105 ResourceType resource_type) | 105 ResourceType resource_type) |
| 106 : context_(context), | 106 : context_(context), |
| 107 provider_host_(provider_host), | 107 provider_host_(provider_host), |
| 108 blob_storage_context_(blob_storage_context), | 108 blob_storage_context_(blob_storage_context), |
| 109 resource_type_(resource_type) { | 109 resource_type_(resource_type) { |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace content | 112 } // namespace content |
| OLD | NEW |