| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class URLRequest; | 22 class URLRequest; |
| 23 class URLRequestInterceptor; | 23 class URLRequestInterceptor; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace storage { | 26 namespace storage { |
| 27 class BlobStorageContext; | 27 class BlobStorageContext; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 | 31 |
| 32 class ResourceContext; |
| 32 class ResourceRequestBody; | 33 class ResourceRequestBody; |
| 33 class ServiceWorkerContextCore; | 34 class ServiceWorkerContextCore; |
| 34 class ServiceWorkerContextWrapper; | 35 class ServiceWorkerContextWrapper; |
| 35 class ServiceWorkerProviderHost; | 36 class ServiceWorkerProviderHost; |
| 36 | 37 |
| 37 // Abstract base class for routing network requests to ServiceWorkers. | 38 // Abstract base class for routing network requests to ServiceWorkers. |
| 38 // Created one per URLRequest and attached to each request. | 39 // Created one per URLRequest and attached to each request. |
| 39 class CONTENT_EXPORT ServiceWorkerRequestHandler | 40 class CONTENT_EXPORT ServiceWorkerRequestHandler |
| 40 : public base::SupportsUserData::Data { | 41 : public base::SupportsUserData::Data { |
| 41 public: | 42 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 RequestContextType request_context_type, | 59 RequestContextType request_context_type, |
| 59 RequestContextFrameType frame_type, | 60 RequestContextFrameType frame_type, |
| 60 scoped_refptr<ResourceRequestBody> body); | 61 scoped_refptr<ResourceRequestBody> body); |
| 61 | 62 |
| 62 // Returns the handler attached to |request|. This may return NULL | 63 // Returns the handler attached to |request|. This may return NULL |
| 63 // if no handler is attached. | 64 // if no handler is attached. |
| 64 static ServiceWorkerRequestHandler* GetHandler( | 65 static ServiceWorkerRequestHandler* GetHandler( |
| 65 net::URLRequest* request); | 66 net::URLRequest* request); |
| 66 | 67 |
| 67 // Creates a protocol interceptor for ServiceWorker. | 68 // Creates a protocol interceptor for ServiceWorker. |
| 68 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); | 69 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor( |
| 70 ResourceContext* resource_context); |
| 69 | 71 |
| 70 virtual ~ServiceWorkerRequestHandler(); | 72 virtual ~ServiceWorkerRequestHandler(); |
| 71 | 73 |
| 72 // Called via custom URLRequestJobFactory. | 74 // Called via custom URLRequestJobFactory. |
| 73 virtual net::URLRequestJob* MaybeCreateJob( | 75 virtual net::URLRequestJob* MaybeCreateJob( |
| 74 net::URLRequest* request, | 76 net::URLRequest* request, |
| 75 net::NetworkDelegate* network_delegate) = 0; | 77 net::NetworkDelegate* network_delegate, |
| 78 ResourceContext* context) = 0; |
| 76 | 79 |
| 77 virtual void GetExtraResponseInfo( | 80 virtual void GetExtraResponseInfo( |
| 78 bool* was_fetched_via_service_worker, | 81 bool* was_fetched_via_service_worker, |
| 79 bool* was_fallback_required_by_service_worker, | 82 bool* was_fallback_required_by_service_worker, |
| 80 GURL* original_url_via_service_worker, | 83 GURL* original_url_via_service_worker, |
| 81 base::TimeTicks* fetch_start_time, | 84 base::TimeTicks* fetch_start_time, |
| 82 base::TimeTicks* fetch_ready_time, | 85 base::TimeTicks* fetch_ready_time, |
| 83 base::TimeTicks* fetch_end_time) const = 0; | 86 base::TimeTicks* fetch_end_time) const = 0; |
| 84 | 87 |
| 85 protected: | 88 protected: |
| 86 ServiceWorkerRequestHandler( | 89 ServiceWorkerRequestHandler( |
| 87 base::WeakPtr<ServiceWorkerContextCore> context, | 90 base::WeakPtr<ServiceWorkerContextCore> context, |
| 88 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 91 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 89 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 92 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 90 ResourceType resource_type); | 93 ResourceType resource_type); |
| 91 | 94 |
| 92 base::WeakPtr<ServiceWorkerContextCore> context_; | 95 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 93 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 96 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
| 94 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 97 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
| 95 ResourceType resource_type_; | 98 ResourceType resource_type_; |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 101 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 } // namespace content | 104 } // namespace content |
| 102 | 105 |
| 103 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 106 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
| OLD | NEW |