| 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/common/service_worker/service_worker_status_code.h" | 12 #include "content/common/service_worker/service_worker_status_code.h" |
| 13 #include "net/url_request/url_request_job_factory.h" | 13 #include "net/url_request/url_request_job_factory.h" |
| 14 #include "webkit/common/resource_type.h" | 14 #include "webkit/common/resource_type.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class NetworkDelegate; | 17 class NetworkDelegate; |
| 18 class URLRequest; | 18 class URLRequest; |
| 19 class URLRequestInterceptor; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 23 class ServiceWorkerContextCore; | 24 class ServiceWorkerContextCore; |
| 24 class ServiceWorkerContextWrapper; | 25 class ServiceWorkerContextWrapper; |
| 25 class ServiceWorkerProviderHost; | 26 class ServiceWorkerProviderHost; |
| 26 | 27 |
| 27 // Abstract base class for routing network requests to ServiceWorkers. | 28 // Abstract base class for routing network requests to ServiceWorkers. |
| 28 // Created one per URLRequest and attached to each request. | 29 // Created one per URLRequest and attached to each request. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 int process_id, | 42 int process_id, |
| 42 int provider_id, | 43 int provider_id, |
| 43 ResourceType::Type resource_type); | 44 ResourceType::Type resource_type); |
| 44 | 45 |
| 45 // Returns the handler attached to |request|. This may return NULL | 46 // Returns the handler attached to |request|. This may return NULL |
| 46 // if no handler is attached. | 47 // if no handler is attached. |
| 47 static ServiceWorkerRequestHandler* GetHandler( | 48 static ServiceWorkerRequestHandler* GetHandler( |
| 48 net::URLRequest* request); | 49 net::URLRequest* request); |
| 49 | 50 |
| 50 // Creates a protocol interceptor for ServiceWorker. | 51 // Creates a protocol interceptor for ServiceWorker. |
| 51 static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 52 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); |
| 52 CreateInterceptor(); | |
| 53 | 53 |
| 54 virtual ~ServiceWorkerRequestHandler(); | 54 virtual ~ServiceWorkerRequestHandler(); |
| 55 | 55 |
| 56 // Called via custom URLRequestJobFactory. | 56 // Called via custom URLRequestJobFactory. |
| 57 virtual net::URLRequestJob* MaybeCreateJob( | 57 virtual net::URLRequestJob* MaybeCreateJob( |
| 58 net::URLRequest* request, | 58 net::URLRequest* request, |
| 59 net::NetworkDelegate* network_delegate) = 0; | 59 net::NetworkDelegate* network_delegate) = 0; |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 ServiceWorkerRequestHandler( | 62 ServiceWorkerRequestHandler( |
| 63 base::WeakPtr<ServiceWorkerContextCore> context, | 63 base::WeakPtr<ServiceWorkerContextCore> context, |
| 64 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 64 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 65 ResourceType::Type resource_type); | 65 ResourceType::Type resource_type); |
| 66 | 66 |
| 67 base::WeakPtr<ServiceWorkerContextCore> context_; | 67 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 68 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 68 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
| 69 ResourceType::Type resource_type_; | 69 ResourceType::Type resource_type_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace content | 74 } // namespace content |
| 75 | 75 |
| 76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
| OLD | NEW |