| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace storage { | 28 namespace storage { |
| 29 class BlobStorageContext; | 29 class BlobStorageContext; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 | 33 |
| 34 class ResourceContext; | 34 class ResourceContext; |
| 35 class ResourceMessageFilter; | 35 class ResourceMessageFilter; |
| 36 class ResourceRequestBody; | 36 class ResourceRequestBodyImpl; |
| 37 class ServiceWorkerContextCore; | 37 class ServiceWorkerContextCore; |
| 38 class ServiceWorkerContextWrapper; | 38 class ServiceWorkerContextWrapper; |
| 39 class ServiceWorkerNavigationHandleCore; | 39 class ServiceWorkerNavigationHandleCore; |
| 40 class ServiceWorkerProviderHost; | 40 class ServiceWorkerProviderHost; |
| 41 | 41 |
| 42 // Abstract base class for routing network requests to ServiceWorkers. | 42 // Abstract base class for routing network requests to ServiceWorkers. |
| 43 // Created one per URLRequest and attached to each request. | 43 // Created one per URLRequest and attached to each request. |
| 44 class CONTENT_EXPORT ServiceWorkerRequestHandler | 44 class CONTENT_EXPORT ServiceWorkerRequestHandler |
| 45 : public base::SupportsUserData::Data { | 45 : public base::SupportsUserData::Data { |
| 46 public: | 46 public: |
| 47 // PlzNavigate | 47 // PlzNavigate |
| 48 // Attaches a newly created handler if the given |request| needs to be handled | 48 // Attaches a newly created handler if the given |request| needs to be handled |
| 49 // by ServiceWorker. | 49 // by ServiceWorker. |
| 50 static void InitializeForNavigation( | 50 static void InitializeForNavigation( |
| 51 net::URLRequest* request, | 51 net::URLRequest* request, |
| 52 ServiceWorkerNavigationHandleCore* navigation_handle_core, | 52 ServiceWorkerNavigationHandleCore* navigation_handle_core, |
| 53 storage::BlobStorageContext* blob_storage_context, | 53 storage::BlobStorageContext* blob_storage_context, |
| 54 bool skip_service_worker, | 54 bool skip_service_worker, |
| 55 ResourceType resource_type, | 55 ResourceType resource_type, |
| 56 RequestContextType request_context_type, | 56 RequestContextType request_context_type, |
| 57 RequestContextFrameType frame_type, | 57 RequestContextFrameType frame_type, |
| 58 scoped_refptr<ResourceRequestBody> body); | 58 scoped_refptr<ResourceRequestBodyImpl> body); |
| 59 | 59 |
| 60 // Attaches a newly created handler if the given |request| needs to | 60 // Attaches a newly created handler if the given |request| needs to |
| 61 // be handled by ServiceWorker. | 61 // be handled by ServiceWorker. |
| 62 // TODO(kinuko): While utilizing UserData to attach data to URLRequest | 62 // TODO(kinuko): While utilizing UserData to attach data to URLRequest |
| 63 // has some precedence, it might be better to attach this handler in a more | 63 // has some precedence, it might be better to attach this handler in a more |
| 64 // explicit way within content layer, e.g. have ResourceRequestInfoImpl | 64 // explicit way within content layer, e.g. have ResourceRequestInfoImpl |
| 65 // own it. | 65 // own it. |
| 66 static void InitializeHandler( | 66 static void InitializeHandler( |
| 67 net::URLRequest* request, | 67 net::URLRequest* request, |
| 68 ServiceWorkerContextWrapper* context_wrapper, | 68 ServiceWorkerContextWrapper* context_wrapper, |
| 69 storage::BlobStorageContext* blob_storage_context, | 69 storage::BlobStorageContext* blob_storage_context, |
| 70 int process_id, | 70 int process_id, |
| 71 int provider_id, | 71 int provider_id, |
| 72 bool skip_service_worker, | 72 bool skip_service_worker, |
| 73 FetchRequestMode request_mode, | 73 FetchRequestMode request_mode, |
| 74 FetchCredentialsMode credentials_mode, | 74 FetchCredentialsMode credentials_mode, |
| 75 FetchRedirectMode redirect_mode, | 75 FetchRedirectMode redirect_mode, |
| 76 ResourceType resource_type, | 76 ResourceType resource_type, |
| 77 RequestContextType request_context_type, | 77 RequestContextType request_context_type, |
| 78 RequestContextFrameType frame_type, | 78 RequestContextFrameType frame_type, |
| 79 scoped_refptr<ResourceRequestBody> body); | 79 scoped_refptr<ResourceRequestBodyImpl> body); |
| 80 | 80 |
| 81 // Returns the handler attached to |request|. This may return NULL | 81 // Returns the handler attached to |request|. This may return NULL |
| 82 // if no handler is attached. | 82 // if no handler is attached. |
| 83 static ServiceWorkerRequestHandler* GetHandler( | 83 static ServiceWorkerRequestHandler* GetHandler( |
| 84 net::URLRequest* request); | 84 net::URLRequest* request); |
| 85 | 85 |
| 86 // Creates a protocol interceptor for ServiceWorker. | 86 // Creates a protocol interceptor for ServiceWorker. |
| 87 static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor( | 87 static std::unique_ptr<net::URLRequestInterceptor> CreateInterceptor( |
| 88 ResourceContext* resource_context); | 88 ResourceContext* resource_context); |
| 89 | 89 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; | 128 std::unique_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; |
| 129 int old_process_id_; | 129 int old_process_id_; |
| 130 int old_provider_id_; | 130 int old_provider_id_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 132 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace content | 135 } // namespace content |
| 136 | 136 |
| 137 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 137 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
| OLD | NEW |