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 20 matching lines...) Expand all Loading... |
31 ServiceWorkerRequestHandler::GetHandler(request); | 31 ServiceWorkerRequestHandler::GetHandler(request); |
32 if (!handler) | 32 if (!handler) |
33 return NULL; | 33 return NULL; |
34 return handler->MaybeCreateJob(request, network_delegate); | 34 return handler->MaybeCreateJob(request, network_delegate); |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor); | 38 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestInterceptor); |
39 }; | 39 }; |
40 | 40 |
| 41 bool IsMethodSupported(const std::string& method) { |
| 42 return (method == "GET") || (method == "HEAD"); |
| 43 } |
| 44 |
| 45 bool IsSchemeAndMethodSupported(const net::URLRequest* request) { |
| 46 return request->url().SchemeIsHTTPOrHTTPS() && |
| 47 IsMethodSupported(request->method()); |
| 48 } |
| 49 |
41 } // namespace | 50 } // namespace |
42 | 51 |
43 void ServiceWorkerRequestHandler::InitializeHandler( | 52 void ServiceWorkerRequestHandler::InitializeHandler( |
44 net::URLRequest* request, | 53 net::URLRequest* request, |
45 ServiceWorkerContextWrapper* context_wrapper, | 54 ServiceWorkerContextWrapper* context_wrapper, |
46 int process_id, | 55 int process_id, |
47 int provider_id, | 56 int provider_id, |
48 ResourceType::Type resource_type) { | 57 ResourceType::Type resource_type) { |
49 if (!ServiceWorkerUtils::IsFeatureEnabled()) | 58 if (!ServiceWorkerUtils::IsFeatureEnabled() || |
| 59 !IsSchemeAndMethodSupported(request)) { |
50 return; | 60 return; |
| 61 } |
51 | 62 |
52 if (!context_wrapper || !context_wrapper->context() || | 63 if (!context_wrapper || !context_wrapper->context() || |
53 provider_id == kInvalidServiceWorkerProviderId) { | 64 provider_id == kInvalidServiceWorkerProviderId) { |
54 return; | 65 return; |
55 } | 66 } |
56 | 67 |
57 ServiceWorkerProviderHost* provider_host = | 68 ServiceWorkerProviderHost* provider_host = |
58 context_wrapper->context()->GetProviderHost(process_id, provider_id); | 69 context_wrapper->context()->GetProviderHost(process_id, provider_id); |
59 if (!provider_host) | 70 if (!provider_host) |
60 return; | 71 return; |
(...skipping 24 matching lines...) Expand all Loading... |
85 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( | 96 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( |
86 base::WeakPtr<ServiceWorkerContextCore> context, | 97 base::WeakPtr<ServiceWorkerContextCore> context, |
87 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 98 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
88 ResourceType::Type resource_type) | 99 ResourceType::Type resource_type) |
89 : context_(context), | 100 : context_(context), |
90 provider_host_(provider_host), | 101 provider_host_(provider_host), |
91 resource_type_(resource_type) { | 102 resource_type_(resource_type) { |
92 } | 103 } |
93 | 104 |
94 } // namespace content | 105 } // namespace content |
OLD | NEW |