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 28 matching lines...) Expand all Loading... |
39 // TODO(kinuko): While utilizing UserData to attach data to URLRequest | 39 // TODO(kinuko): While utilizing UserData to attach data to URLRequest |
40 // has some precedence, it might be better to attach this handler in a more | 40 // has some precedence, it might be better to attach this handler in a more |
41 // explicit way within content layer, e.g. have ResourceRequestInfoImpl | 41 // explicit way within content layer, e.g. have ResourceRequestInfoImpl |
42 // own it. | 42 // own it. |
43 static void InitializeHandler( | 43 static void InitializeHandler( |
44 net::URLRequest* request, | 44 net::URLRequest* request, |
45 ServiceWorkerContextWrapper* context_wrapper, | 45 ServiceWorkerContextWrapper* context_wrapper, |
46 webkit_blob::BlobStorageContext* blob_storage_context, | 46 webkit_blob::BlobStorageContext* blob_storage_context, |
47 int process_id, | 47 int process_id, |
48 int provider_id, | 48 int provider_id, |
49 ResourceType::Type resource_type); | 49 ResourceType resource_type); |
50 | 50 |
51 // Returns the handler attached to |request|. This may return NULL | 51 // Returns the handler attached to |request|. This may return NULL |
52 // if no handler is attached. | 52 // if no handler is attached. |
53 static ServiceWorkerRequestHandler* GetHandler( | 53 static ServiceWorkerRequestHandler* GetHandler( |
54 net::URLRequest* request); | 54 net::URLRequest* request); |
55 | 55 |
56 // Creates a protocol interceptor for ServiceWorker. | 56 // Creates a protocol interceptor for ServiceWorker. |
57 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); | 57 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor(); |
58 | 58 |
59 virtual ~ServiceWorkerRequestHandler(); | 59 virtual ~ServiceWorkerRequestHandler(); |
60 | 60 |
61 // Called via custom URLRequestJobFactory. | 61 // Called via custom URLRequestJobFactory. |
62 virtual net::URLRequestJob* MaybeCreateJob( | 62 virtual net::URLRequestJob* MaybeCreateJob( |
63 net::URLRequest* request, | 63 net::URLRequest* request, |
64 net::NetworkDelegate* network_delegate) = 0; | 64 net::NetworkDelegate* network_delegate) = 0; |
65 | 65 |
66 virtual void GetExtraResponseInfo( | 66 virtual void GetExtraResponseInfo( |
67 bool* was_fetched_via_service_worker, | 67 bool* was_fetched_via_service_worker, |
68 GURL* original_url_via_service_worker) const = 0; | 68 GURL* original_url_via_service_worker) const = 0; |
69 | 69 |
70 protected: | 70 protected: |
71 ServiceWorkerRequestHandler( | 71 ServiceWorkerRequestHandler( |
72 base::WeakPtr<ServiceWorkerContextCore> context, | 72 base::WeakPtr<ServiceWorkerContextCore> context, |
73 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 73 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
74 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, | 74 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, |
75 ResourceType::Type resource_type); | 75 ResourceType resource_type); |
76 | 76 |
77 base::WeakPtr<ServiceWorkerContextCore> context_; | 77 base::WeakPtr<ServiceWorkerContextCore> context_; |
78 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 78 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
79 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context_; | 79 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context_; |
80 ResourceType::Type resource_type_; | 80 ResourceType resource_type_; |
81 | 81 |
82 private: | 82 private: |
83 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 83 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace content | 86 } // namespace content |
87 | 87 |
88 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 88 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
OLD | NEW |