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 (!ServiceWorkerUtils::IsFeatureEnabled() || | 61 if (!ServiceWorkerUtils::IsFeatureEnabled() || |
62 !IsSchemeAndMethodSupported(request)) { | 62 !IsSchemeAndMethodSupportedForAppCache(request)) { |
63 return; | 63 return; |
64 } | 64 } |
65 | 65 |
66 if (!context_wrapper || !context_wrapper->context() || | 66 if (!context_wrapper || !context_wrapper->context() || |
67 provider_id == kInvalidServiceWorkerProviderId) { | 67 provider_id == kInvalidServiceWorkerProviderId) { |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 ServiceWorkerProviderHost* provider_host = | 71 ServiceWorkerProviderHost* provider_host = |
72 context_wrapper->context()->GetProviderHost(process_id, provider_id); | 72 context_wrapper->context()->GetProviderHost(process_id, provider_id); |
(...skipping 29 matching lines...) Expand all Loading... |
102 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 102 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
103 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, | 103 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, |
104 ResourceType::Type resource_type) | 104 ResourceType::Type resource_type) |
105 : context_(context), | 105 : context_(context), |
106 provider_host_(provider_host), | 106 provider_host_(provider_host), |
107 blob_storage_context_(blob_storage_context), | 107 blob_storage_context_(blob_storage_context), |
108 resource_type_(resource_type) { | 108 resource_type_(resource_type) { |
109 } | 109 } |
110 | 110 |
111 } // namespace content | 111 } // namespace content |
OLD | NEW |