| 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 "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 8 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 9 #include "content/browser/service_worker/service_worker_provider_host.h" | 9 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 10 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 ServiceWorkerRequestHandler::GetHandler(request); | 33 ServiceWorkerRequestHandler::GetHandler(request); |
| 34 if (!handler) | 34 if (!handler) |
| 35 return NULL; | 35 return NULL; |
| 36 return handler->MaybeCreateJob(request, network_delegate); | 36 return handler->MaybeCreateJob(request, network_delegate); |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor); | 40 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 bool IsMethodSupported(const std::string& method) { | 43 bool IsMethodSupportedForAppCache(const std::string& method) { |
| 44 return (method == "GET") || (method == "HEAD"); | 44 return (method == "GET") || (method == "HEAD"); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool IsSchemeAndMethodSupported(const net::URLRequest* request) { | 47 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { |
| 48 return request->url().SchemeIsHTTPOrHTTPS() && | 48 return request->url().SchemeIsHTTPOrHTTPS() && |
| 49 IsMethodSupported(request->method()); | 49 IsMethodSupportedForAppCache(request->method()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 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 webkit_blob::BlobStorageContext* blob_storage_context, | 57 webkit_blob::BlobStorageContext* blob_storage_context, |
| 58 int process_id, | 58 int process_id, |
| 59 int provider_id, | 59 int provider_id, |
| 60 ResourceType::Type resource_type) { | 60 ResourceType::Type resource_type) { |
| 61 if (!IsSchemeAndMethodSupported(request)) { | 61 if (!IsSchemeAndMethodSupportedForAppCache(request)) { |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (!context_wrapper || !context_wrapper->context() || | 65 if (!context_wrapper || !context_wrapper->context() || |
| 66 provider_id == kInvalidServiceWorkerProviderId) { | 66 provider_id == kInvalidServiceWorkerProviderId) { |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 ServiceWorkerProviderHost* provider_host = | 70 ServiceWorkerProviderHost* provider_host = |
| 71 context_wrapper->context()->GetProviderHost(process_id, provider_id); | 71 context_wrapper->context()->GetProviderHost(process_id, provider_id); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 101 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 102 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, | 102 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, |
| 103 ResourceType::Type resource_type) | 103 ResourceType::Type resource_type) |
| 104 : context_(context), | 104 : context_(context), |
| 105 provider_host_(provider_host), | 105 provider_host_(provider_host), |
| 106 blob_storage_context_(blob_storage_context), | 106 blob_storage_context_(blob_storage_context), |
| 107 resource_type_(resource_type) { | 107 resource_type_(resource_type) { |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace content | 110 } // namespace content |
| OLD | NEW |