| 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 12 matching lines...) Expand all Loading... |
| 23 namespace storage { | 23 namespace storage { |
| 24 class BlobStorageContext; | 24 class BlobStorageContext; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 class ResourceRequestBody; | 29 class ResourceRequestBody; |
| 30 class ServiceWorkerContextCore; | 30 class ServiceWorkerContextCore; |
| 31 class ServiceWorkerContextWrapper; | 31 class ServiceWorkerContextWrapper; |
| 32 class ServiceWorkerProviderHost; | 32 class ServiceWorkerProviderHost; |
| 33 enum FetchRequestMode; |
| 33 | 34 |
| 34 // Abstract base class for routing network requests to ServiceWorkers. | 35 // Abstract base class for routing network requests to ServiceWorkers. |
| 35 // Created one per URLRequest and attached to each request. | 36 // Created one per URLRequest and attached to each request. |
| 36 class CONTENT_EXPORT ServiceWorkerRequestHandler | 37 class CONTENT_EXPORT ServiceWorkerRequestHandler |
| 37 : public base::SupportsUserData::Data { | 38 : public base::SupportsUserData::Data { |
| 38 public: | 39 public: |
| 39 // Attaches a newly created handler if the given |request| needs to | 40 // Attaches a newly created handler if the given |request| needs to |
| 40 // be handled by ServiceWorker. | 41 // be handled by ServiceWorker. |
| 41 // TODO(kinuko): While utilizing UserData to attach data to URLRequest | 42 // TODO(kinuko): While utilizing UserData to attach data to URLRequest |
| 42 // has some precedence, it might be better to attach this handler in a more | 43 // has some precedence, it might be better to attach this handler in a more |
| 43 // explicit way within content layer, e.g. have ResourceRequestInfoImpl | 44 // explicit way within content layer, e.g. have ResourceRequestInfoImpl |
| 44 // own it. | 45 // own it. |
| 45 static void InitializeHandler( | 46 static void InitializeHandler( |
| 46 net::URLRequest* request, | 47 net::URLRequest* request, |
| 47 ServiceWorkerContextWrapper* context_wrapper, | 48 ServiceWorkerContextWrapper* context_wrapper, |
| 48 storage::BlobStorageContext* blob_storage_context, | 49 storage::BlobStorageContext* blob_storage_context, |
| 49 int process_id, | 50 int process_id, |
| 50 int provider_id, | 51 int provider_id, |
| 51 bool skip_service_worker, | 52 bool skip_service_worker, |
| 53 FetchRequestMode request_mode, |
| 52 ResourceType resource_type, | 54 ResourceType resource_type, |
| 53 scoped_refptr<ResourceRequestBody> body); | 55 scoped_refptr<ResourceRequestBody> body); |
| 54 | 56 |
| 55 // Returns the handler attached to |request|. This may return NULL | 57 // Returns the handler attached to |request|. This may return NULL |
| 56 // if no handler is attached. | 58 // if no handler is attached. |
| 57 static ServiceWorkerRequestHandler* GetHandler( | 59 static ServiceWorkerRequestHandler* GetHandler( |
| 58 net::URLRequest* request); | 60 net::URLRequest* request); |
| 59 | 61 |
| 60 // Creates a protocol interceptor for ServiceWorker. | 62 // Creates a protocol interceptor for ServiceWorker. |
| 61 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); | 63 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 88 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
| 87 ResourceType resource_type_; | 89 ResourceType resource_type_; |
| 88 | 90 |
| 89 private: | 91 private: |
| 90 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 92 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 } // namespace content | 95 } // namespace content |
| 94 | 96 |
| 95 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 97 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
| OLD | NEW |